-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
add acl validator to aws s3 bucket resource #15327
Conversation
Thank you for your contribution! 🚀 Please note that typically Go dependency changes are handled in this repository by Renovate Bot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the Additional details:
|
d88cc16
to
0544ae1
Compare
@@ -76,6 +76,14 @@ func resourceAwsS3Bucket() *schema.Resource { | |||
Default: "private", | |||
Optional: true, | |||
ConflictsWith: []string{"grant"}, | |||
ValidateFunc: validation.StringInSlice([]string{ |
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.
Instead of hardcoding them, how about just using s3.BucketCannedACL_Values()
?
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 dont really have a preference. But, looking at other validation functions, they seem to list out all the values. I dont think I want to go against the style?
https://github.com/terraform-providers/terraform-provider-aws/blob/0544ae1fe0f788616cc483df8d0e68d3dd36a0ed/aws/resource_aws_s3_bucket.go#L120
https://github.com/terraform-providers/terraform-provider-aws/blob/0544ae1fe0f788616cc483df8d0e68d3dd36a0ed/aws/resource_aws_s3_bucket.go#L406
https://github.com/terraform-providers/terraform-provider-aws/blob/0544ae1fe0f788616cc483df8d0e68d3dd36a0ed/aws/resource_aws_s3_bucket.go#L453
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.
Hi @NikolaeVarius. We've actually been changing over to the _Values()
functions so that new values are automatically picked up when we update the AWS SDK. We're tracking this in #14601
The _Values()
functions were actually added by one of our maintainers in aws/aws-sdk-go#3447 🙂
s3.BucketCannedACLPublicReadWrite, | ||
s3.BucketCannedACLAWSExecRead, | ||
s3.BucketCannedACLAuthenticatedRead, | ||
s3.BucketCannedACLLogDeliveryWrite, |
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.
This doesn't seem to exist?
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.
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.
as in the other comment, yeah you're correct
s3.BucketCannedACLPrivate, | ||
s3.BucketCannedACLPublicRead, | ||
s3.BucketCannedACLPublicReadWrite, | ||
s3.BucketCannedACLAWSExecRead, |
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 this exists for buckets... For objects, there's ObjectCannedACLAwsExecRead
.
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.
https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
It seems to say it works on both
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 SDK doesn't seem to support it. See https://docs.aws.amazon.com/sdk-for-go/api/service/s3/#pkg-constants. Or if you look at the code directly (https://raw.githubusercontent.com/aws/aws-sdk-go/master/service/s3/api.go), you can take a look at the BucketCannedACL_Values()
function.
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 see you're correct. Those values are exist at the ObjectCannedACL_Values() function. I dont know the behavior just yet, and would need to test, but in this case, would it be wise to add this validator in if the upstream SDK doesn't support all possible values for a bucket? Wouldn't want to return a validation error when the ACL is perfectly valid.
// ObjectCannedACL_Values returns all elements of the ObjectCannedACL enum
func ObjectCannedACL_Values() []string {
return []string{
ObjectCannedACLPrivate,
ObjectCannedACLPublicRead,
ObjectCannedACLPublicReadWrite,
ObjectCannedACLAuthenticatedRead,
ObjectCannedACLAwsExecRead,
ObjectCannedACLBucketOwnerRead,
ObjectCannedACLBucketOwnerFullControl,
}
}
It seems the outdated canned acls in the go SDK are a known issue Further linked report terraform-linters/tflint#341 (comment) |
// BucketCannedACLAWSExecRead is a BucketCannedACL enum value | ||
BucketCannedACLAWSExecRead = "aws-exec-read" | ||
|
||
// BucketCannedACLAuthenticatedRead is a BucketCannedACL enum value | ||
BucketCannedACLAuthenticatedRead = "authenticated-read" | ||
|
||
// BucketCannedACLLogDeliveryWrite is a BucketCannedACL enum value | ||
BucketCannedACLLogDeliveryWrite = "log-delivery-write" |
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.
Unfortunately, we can't make changes in the vendored dependencies, because they'll be wiped out the next time we update the AWS SDK. When we run into missing constants, the first thing to do is double-check that they haven't been added in a new version of the SDK. If they haven't, then we can define our own constants in the directory aws/internal/service/s3
and also file an issue with AWS either on the SDK or with support
HI @NikolaeVarius, this PR looks like a good start. Is there anything you need from us to move it forward? |
This has been released in version 3.15.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
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! |
Community Note
Closes #15304
Release note for CHANGELOG:
Output from acceptance testing: