-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
fix s3 bucket versioning #77
Conversation
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.
Bridgecrew has found 2 infrastructure configuration errors in this PR ⬇️
@@ -8,8 +8,12 @@ resource "aws_s3_bucket" "default" { | |||
policy = var.policy | |||
tags = module.this.tags | |||
|
|||
versioning { | |||
enabled = var.versioning_enabled | |||
dynamic "versioning" { |
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.
Error Description: Ensure all data stored in the S3 bucket is securely encrypted at rest
Category: Storage | Severity: HIGH
Resource: aws_s3_bucket [default], lines: 1 - 156
@@ -8,8 +8,12 @@ resource "aws_s3_bucket" "default" { | |||
policy = var.policy | |||
tags = module.this.tags | |||
|
|||
versioning { | |||
enabled = var.versioning_enabled | |||
dynamic "versioning" { |
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.
Error Description: Ensure all data stored in the S3 bucket have versioning enabled
Category: Storage | Severity: HIGH
Resource: aws_s3_bucket [default], lines: 1 - 156
This pull request is now in conflict. Could you fix it @imunhatep? 🙏 |
This pull request is now in conflict. Could you fix it @imunhatep? 🙏 |
versioning { | ||
enabled = var.versioning_enabled | ||
dynamic "versioning" { | ||
for_each = var.bucket_versioning ? [1] : [0] |
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.
Why have two separate boolean variables here?
Let's use the original version_enabled in the dynamic and when setting the value
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.
Long time ago, but as I remember... cause versioning can be enabled or disabled for bucket. In case versioning is enabled, it could be set to suspended.
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.
I don't think that's relevant here tho as you can still suspend versioning on the bucket by toggling version_enabled = false
if versioning_enabled
was used in the for_each
instead of bucket_versioning
.
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.
Hmm after fully understanding the aws provider issue you linked to, perhaps I'm mistaken. This seems to be a workaround for an upstream bug but I don't know if we want to support this workaround or wait for the bug to be fixed upstream.
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.
If you are referring to aws provider issue, well it's more then 3y old, I wouldn't expect it to be fixed. And as I mentioned there are 4 states of versioning for S3 buckets, aws provider seems reflects exactly that behavior. So I'm not sure if it's a bug at all..
I think I understand this PR a little more after some discussion with the author. I'd like to see some changes before I'm comfortable with this PR.
@imunhatep if you have time. |
@imunhatep thank you for the submission and sorry for not being able to merge this in (it's been almost a year). A few things:
I'm going to close this because of 2. However, this PR also extends the |
Fixes #76
yet this change will break BC and there is no possibility to suspend bucket versioning.
updated: now it should be back-compatible