-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aws v4 refactor #113
Aws v4 refactor #113
Changes from 5 commits
74f0073
262efce
5859338
5fa3013
0ca2673
d74b938
60b2bb2
4755c25
e690d54
d98ff72
4fc2d1f
6e7ef98
28bab71
96b31cb
bdccbe8
5e476c1
274ced3
6b09b65
270de7e
44a51f3
76a2067
e50293e
78522f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,53 +2,44 @@ data "aws_caller_identity" "default" {} | |||||
|
||||||
data "aws_region" "default" {} | ||||||
|
||||||
resource "aws_s3_bucket" "cache_bucket" { | ||||||
module "cache_bucket" { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually when we create a breaking change like this, we release a "minor" release but we also include with it some kind of "migration" document which we create by first applying the current release, then running through terraform state moves and other API changes, then we can apply the new version (this version) and make sure it returns "no changes". Those steps are documented inside of docs/ and added to the README.yaml so other people will know how to safely migrate from version 0.x to version 0.y. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran the tests below just to make sure you were on the correct path with the current proposed changes but I think a migration doc is the right way to go. cc: @Nuru There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a migration doc @nitrocode |
||||||
#bridgecrew:skip=BC_AWS_S3_13:Skipping `Enable S3 Bucket Logging` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776). | ||||||
#bridgecrew:skip=BC_AWS_S3_14:Skipping `Ensure all data stored in the S3 bucket is securely encrypted at rest` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776). | ||||||
#bridgecrew:skip=CKV_AWS_52:Skipping `Ensure S3 bucket has MFA delete enabled` due to issue in terraform (https://github.com/hashicorp/terraform-provider-aws/issues/629). | ||||||
count = module.this.enabled && local.create_s3_cache_bucket ? 1 : 0 | ||||||
bucket = local.cache_bucket_name_normalised | ||||||
acl = "private" | ||||||
force_destroy = true | ||||||
tags = module.this.tags | ||||||
|
||||||
versioning { | ||||||
enabled = var.versioning_enabled | ||||||
source = "cloudposse/s3-bucket/aws" | ||||||
version = "2.0.3" | ||||||
|
||||||
count = module.this.enabled && local.create_s3_cache_bucket ? 1 : 0 | ||||||
bucket_name = local.cache_bucket_name_normalised | ||||||
|
||||||
acl = true | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
force_destroy = true | ||||||
tags = module.this.tags | ||||||
versioning_enabled = var.versioning_enabled | ||||||
logging = { | ||||||
bucket_name = var.access_log_bucket_name | ||||||
prefix = "logs/${module.this.id}/" | ||||||
} | ||||||
|
||||||
dynamic "logging" { | ||||||
for_each = var.access_log_bucket_name != "" ? [1] : [] | ||||||
content { | ||||||
target_bucket = var.access_log_bucket_name | ||||||
target_prefix = "logs/${module.this.id}/" | ||||||
} | ||||||
} | ||||||
|
||||||
lifecycle_rule { | ||||||
id = "codebuildcache" | ||||||
enabled = true | ||||||
|
||||||
prefix = "/" | ||||||
tags = module.this.tags | ||||||
|
||||||
expiration { | ||||||
days = var.cache_expiration_days | ||||||
} | ||||||
} | ||||||
|
||||||
dynamic "server_side_encryption_configuration" { | ||||||
for_each = var.encryption_enabled ? ["true"] : [] | ||||||
|
||||||
content { | ||||||
rule { | ||||||
apply_server_side_encryption_by_default { | ||||||
sse_algorithm = "AES256" | ||||||
} | ||||||
lifecycle_configuration_rules = [ | ||||||
# Be sure to cover https://github.com/cloudposse/terraform-aws-s3-bucket/issues/137 | ||||||
{ | ||||||
enabled = true | ||||||
id = "codebuildcache" | ||||||
abort_incomplete_multipart_upload_days = 1 | ||||||
prefix = "/" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
tags = module.this.tags | ||||||
filter_and = {} | ||||||
noncurrent_version_expiration = {} | ||||||
noncurrent_version_transition = [] | ||||||
transition = [{}] | ||||||
expiration = { | ||||||
days = var.cache_expiration_days | ||||||
expired_object_delete_marker = null | ||||||
} | ||||||
} | ||||||
} | ||||||
] | ||||||
bucket_key_enabled = true | ||||||
} | ||||||
|
||||||
resource "random_string" "bucket_prefix" { | ||||||
count = module.this.enabled ? 1 : 0 | ||||||
length = 12 | ||||||
|
@@ -71,7 +62,7 @@ locals { | |||||
|
||||||
s3_cache_enabled = var.cache_type == "S3" | ||||||
create_s3_cache_bucket = local.s3_cache_enabled && var.s3_cache_bucket_name == null | ||||||
s3_bucket_name = local.create_s3_cache_bucket ? join("", aws_s3_bucket.cache_bucket.*.bucket) : var.s3_cache_bucket_name | ||||||
s3_bucket_name = local.create_s3_cache_bucket ? join("", module.cache_bucket.*.bucket) : var.s3_cache_bucket_name | ||||||
|
||||||
## This is the magic where a map of a list of maps is generated | ||||||
## and used to conditionally add the cache bucket option to the | ||||||
|
@@ -265,8 +256,8 @@ data "aws_iam_policy_document" "permissions_cache_bucket" { | |||||
effect = "Allow" | ||||||
|
||||||
resources = [ | ||||||
join("", aws_s3_bucket.cache_bucket.*.arn), | ||||||
"${join("", aws_s3_bucket.cache_bucket.*.arn)}/*", | ||||||
join("", module.cache_bucket.*.bucket_arn), | ||||||
"${join("", module.cache_bucket.*.bucket_arn)}/*", | ||||||
] | ||||||
} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.