-
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
Add aws_s3_access_point resource #11276
Conversation
3d8e6f2
to
1d9aa45
Compare
775e8c2
to
d8ff62f
Compare
Removed WIP. For |
Test 'aws_s3_bucket_object' with bucket set to access point ARN. Add access point domain name. Delete all access points associated with a bucket in test sweeper.
d8ff62f
to
5b57db7
Compare
Any chance this will be reviewed/merged/released soon? |
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 looks great, thanks so much, @ewbankkit 🚀 Will handle the minor nits on merge.
Output from acceptance testing:
--- PASS: TestAccAWSS3AccessPoint_basic (25.18s)
--- PASS: TestAccAWSS3AccessPoint_bucketDisappears (16.15s)
--- PASS: TestAccAWSS3AccessPoint_disappears (21.58s)
--- PASS: TestAccAWSS3AccessPoint_Policy (56.65s)
--- PASS: TestAccAWSS3AccessPoint_PublicAccessBlockConfiguration (25.37s)
--- PASS: TestAccAWSS3AccessPoint_VpcConfiguration (23.90s)
--- PASS: TestAccAWSS3BucketObject_updatesWithVersioningViaAccessPoint (35.50s)
--- PASS: TestAccDataSourceAWSS3BucketObject_basicViaAccessPoint (27.07s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_basicViaAccessPoint (40.23s)
@@ -87,6 +88,45 @@ func testSweepS3Buckets(region string) error { | |||
continue | |||
} | |||
|
|||
// "Before you can delete this bucket, you must first delete all access points associated with this bucket." |
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.
Nit: This sweeper code can be self-contained with the aws_s3_access_point
testing code and the aws_s3_bucket
sweeper can depend on aws_s3_access_point
. 👍 We only limit the aws_s3_bucket
sweeper due to some legacy S3 things remaining in the HashiCorp testing account.
} | ||
|
||
resource "aws_s3_access_point" "example" { | ||
account_id = data.aws_caller_identity.current.account_id |
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.
Nit: For basic usage, most folks should not need the data source. 👍
} | ||
} | ||
|
||
func testAccCheckAWSS3AccessPointDomainName(n string, key string) resource.TestCheckFunc { |
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.
Nit: This custom check function can be replaced with testAccMatchResourceAttrRegionalHostname()
(or a new non-regex version of that function)
d.Set("account_id", accountId) | ||
d.Set("arn", arn.String()) | ||
d.Set("bucket", output.Bucket) | ||
d.Set("domain_name", fmt.Sprintf("%s-%s.s3-accesspoint.%s.amazonaws.com", name, accountId, meta.(*AWSClient).region)) |
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.
Nit: Instead of hardcoding the partition DNS suffix, we should likely try to future-proof this with the DNS suffix in the provider configuration.
d.Set("domain_name", fmt.Sprintf("%s-%s.s3-accesspoint.%s.amazonaws.com", name, accountId, meta.(*AWSClient).region)) | |
d.Set("domain_name", fmt.Sprintf("%s-%s.s3-accesspoint.%s.%s", name, accountId, meta.(*AWSClient).region), meta.(*AWSClient).dnsSuffix) |
Potentially worth creating a receiver method on AWSClient
itself for this and other usage:
func (client *AWSClient) RegionalHostname(prefix string) string {
return fmt.Sprintf("%s.%s.%s", prefix, client.region, client.dnsSuffix)
}
I'll create a tracking issue for this as I'd like to ensure there is a covering code linter for this going forward.
Reference: #11276 (review) Output from sweeper in AWS Commercial: ``` 2020/02/23 16:19:05 Sweeper Tests ran successfully: - aws_s3_access_point ``` Output from sweeper in AWS GovCloud (US): ``` 2020/02/23 16:19:23 Sweeper Tests ran successfully: - aws_s3_access_point ``` Output from acceptance testing: ``` --- PASS: TestAccAWSS3AccessPoint_basic (36.70s) ```
This has been released in version 2.51.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 #11123.
Release note for CHANGELOG:
Output from acceptance testing:
aws_s3_access_point resource
aws_s3_bucket_object resource
aws_s3_bucket_object data source
aws_s3_bucket_objects data source
aws_s3_bucket sweeper