-
-
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
Allow specifying aws_s3_bucket_ownership_controls #109
Changes from 8 commits
7528b3c
37cb788
f956ff9
8b56780
56fa639
3980180
8be598a
06ebb1e
1332e23
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 | ||||
---|---|---|---|---|---|---|
|
@@ -388,3 +388,22 @@ resource "aws_s3_bucket_public_access_block" "default" { | |||||
ignore_public_acls = var.ignore_public_acls | ||||||
restrict_public_buckets = var.restrict_public_buckets | ||||||
} | ||||||
|
||||||
# Per https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html | ||||||
resource "aws_s3_bucket_ownership_controls" "default" { | ||||||
count = local.enabled ? 1 : 0 | ||||||
bucket = join("", aws_s3_bucket.default.*.id) | ||||||
|
||||||
rule { | ||||||
object_ownership = var.s3_object_ownership | ||||||
} | ||||||
depends_on = [time_sleep.wait_for_aws_s3_bucket_settings] | ||||||
} | ||||||
|
||||||
# Workaround S3 eventual consistency for settings objects | ||||||
resource "time_sleep" "wait_for_aws_s3_bucket_settings" { | ||||||
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. can we set the name as default like all the others?
Suggested change
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. Will leave as is, as its more readable. Also I'm afraid there will be more sleeps 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. S3 went a weird way introducing a separate api/resource for every setting, which then get merged on the backend and races occur |
||||||
count = local.enabled ? 1 : 0 | ||||||
depends_on = [aws_s3_bucket_public_access_block.default, aws_s3_bucket_policy.default] | ||||||
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. what happens when the sleep is removed? does s3 bucket ownership controls resource error out? 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. yes S3 api race condition 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. also when destroying, the aws_s3_bucket_public_access_block resource errors out - a reverse race |
||||||
create_duration = "30s" | ||||||
destroy_duration = "30s" | ||||||
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. if time sleep has to be used here, can we make these configurable? 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 have doubts it's needed. The test covers this pretty well, if it ever fails we'd notice that. In my own tests even 3s was enough to avoid it, this should be bulletproof. I crashes when you have two near-simultaneous requests 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 wouldn't want people to experiment with increasing timeouts if they have errors related to this. 99% this will be another new resource race in S3, not the timeout itself. |
||||||
} |
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.
what if users do not want to specify the s3 bucket ownership controls? can we make this toggleable and default it to false to maintain backwards compatibility?
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.
It's always specified implicitly to the value which is the default here. So creating this with default is equal to not creating at all