-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
r/s3: add public access block resource #6607
Conversation
Getting some inconsistencies when running acceptance tests - it appears there's a delay between when the PutPublicAccessBlock API endpoint is called, and when GetPublicAccessBlock will actually return that the public access block is created. Gonna see if there's something I can do on the read end, or if I need to add a StateChangeConf. Given that the acceptance tests sometimes succeed and sometimes fail, it seems that the delay is fairly short (maybe a couple of seconds). @bflad is there some way I'm not familiar with to handle the delay between create and read? Or is the StateChangeConf the right way to go about handling it? |
Very interested in an update on status and if need any AWS help on this, I'm an AWS employee in the ProServe org and willing to help in any way, including testing, working with AWS support or service team, etc. |
@FireballDWF I think i've got the code correct, I just need to figure out why the tests don't seem to work right. |
@acburdine sorry for not replying sooner, I wanted to get a fresh take on handling eventual consistency issues. You might find some inspiration in the resource code and acceptance testing of #6851 -- |
Oh! One thing, its not possible to workaround this acceptance test failure at the moment: That will require an update upstream in the provider SDK acceptance testing framework to allow refresh retries. As long as the acceptance testing for this resource includes |
@bflad went through and re-did this resource based on what you'd done in #6851. Still getting some acceptance test errors related to the state not updating correctly though 😕
|
Ah shucks, I really wish I saw your note yesterday as this likely could have gone out. That error is "acceptable" for now: #6607 (comment) The only bits missing from this pull request are around retrying for |
@bflad I can get this finished up then, will work on it now unless you've already got something in the works. |
@acburdine go for it! |
fixes hashicorp#6489 - add new s3_bucket_public_access_block_resource and tests
72c4592
to
ad7aabc
Compare
output, err = s3conn.GetPublicAccessBlock(input) | ||
|
||
if d.IsNewResource() && (isAWSErr(err, s3control.ErrCodeNoSuchPublicAccessBlockConfiguration, "") || | ||
isAWSErr(err, s3.ErrCodeNoSuchBucket, "")) { |
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.
The only bits missing from this pull request are around retrying for s3.ErrCodeNoSuchBucket on Create and d.IsNewResource() in Read because S3 eventual consistency is a pain.
@bflad was this what you meant?
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.
Yes! And in the Create
:
log.Printf("[DEBUG] S3 bucket: %s, public access block: %v", bucket, input.PublicAccessBlockConfiguration)
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := s3conn.PutPublicAccessBlock(input)
if isAWSErr(err, s3.ErrCodeNoSuchBucket, "") {
return resource.RetryableError(err)
}
if err != nil {
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return fmt.Errorf("error creating public access block policy for S3 bucket (%s): %s", bucket, err)
}
💯
@bflad should be good now - let me know if it needs anything else 😄 |
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.
Awesome work, @acburdine! LGTM 🚀
--- PASS: TestAccAWSS3BucketPublicAccessBlock_basic (28.71s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_BlockPublicAcls (68.06s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_BlockPublicPolicy (62.44s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_disappears (35.51s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_IgnorePublicAcls (63.38s)
--- PASS: TestAccAWSS3BucketPublicAccessBlock_RestrictPublicBuckets (61.18s)
This has been released in version 1.54.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
fixes #6489
Output from acceptance testing:
TODO: