-
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 data source for listing S3 objects #6968
Conversation
fdbcd13
to
56be4b7
Compare
56be4b7
to
0746877
Compare
@bflad Is there any adjust you'd like to see on this? |
Any chance this will be merged soon? That will allow us to improve our code a lot. |
@bflad I've done the following on this PR:
$ make testacc TESTARGS='-run=TestAccDataSourceAWSS3BucketObjects_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccDataSourceAWSS3BucketObjects_ -timeout 120m
? github.com/terraform-providers/terraform-provider-aws [no test files]
=== RUN TestAccDataSourceAWSS3BucketObjects_basic
=== PAUSE TestAccDataSourceAWSS3BucketObjects_basic
=== RUN TestAccDataSourceAWSS3BucketObjects_all
=== PAUSE TestAccDataSourceAWSS3BucketObjects_all
=== RUN TestAccDataSourceAWSS3BucketObjects_prefixes
=== PAUSE TestAccDataSourceAWSS3BucketObjects_prefixes
=== RUN TestAccDataSourceAWSS3BucketObjects_encoded
=== PAUSE TestAccDataSourceAWSS3BucketObjects_encoded
=== RUN TestAccDataSourceAWSS3BucketObjects_maxKeys
=== PAUSE TestAccDataSourceAWSS3BucketObjects_maxKeys
=== RUN TestAccDataSourceAWSS3BucketObjects_startAfter
=== PAUSE TestAccDataSourceAWSS3BucketObjects_startAfter
=== RUN TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== PAUSE TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== CONT TestAccDataSourceAWSS3BucketObjects_basic
=== CONT TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== CONT TestAccDataSourceAWSS3BucketObjects_startAfter
=== CONT TestAccDataSourceAWSS3BucketObjects_encoded
=== CONT TestAccDataSourceAWSS3BucketObjects_all
=== CONT TestAccDataSourceAWSS3BucketObjects_maxKeys
=== CONT TestAccDataSourceAWSS3BucketObjects_prefixes
--- PASS: TestAccDataSourceAWSS3BucketObjects_startAfter (33.67s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_encoded (33.79s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_fetchOwner (33.92s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_all (34.07s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_prefixes (34.20s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_basic (34.38s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_maxKeys (34.39s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 34.677s |
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.
Hey again @YakDriver 👋 Excited to see this making progress! Left some feedback items below -- please reach out with any questions or if you do not have time to implement them.
@bflad Eventual consistency is killing the acceptance tests. The S3 service doesn't return the correct responses until a while after s3 resource creation. The s3 object should have a wait state but that's a separate issue. 😞 |
@YakDriver This could be related to https://github.com/terraform-providers/terraform-provider-aws/pull/6968/files#r309787429 as well -- a workaround pattern you can use is a "two step" apply in the testing, which ensures all the resources are applied first and introduces a slight delay in the testing before trying to call the data source, e.g. Steps: []resource.TestStep{
{
Config: testAccAWSDataSourceS3ObjectsConfigResources(rInt), // NOTE: contains no data source
// Does not need Check
},
{
Config: testAccAWSDataSourceS3ObjectsConfigBasic(rInt), // NOTE: contains data source
Check: /* ... */,
},
} |
@bflad Genius! $ make testacc TESTARGS='-run=TestAccDataSourceAWSS3BucketObjects_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccDataSourceAWSS3BucketObjects_ -timeout 120m
? github.com/terraform-providers/terraform-provider-aws [no test files]
=== RUN TestAccDataSourceAWSS3BucketObjects_basic
=== PAUSE TestAccDataSourceAWSS3BucketObjects_basic
=== RUN TestAccDataSourceAWSS3BucketObjects_all
=== PAUSE TestAccDataSourceAWSS3BucketObjects_all
=== RUN TestAccDataSourceAWSS3BucketObjects_prefixes
=== PAUSE TestAccDataSourceAWSS3BucketObjects_prefixes
=== RUN TestAccDataSourceAWSS3BucketObjects_encoded
=== PAUSE TestAccDataSourceAWSS3BucketObjects_encoded
=== RUN TestAccDataSourceAWSS3BucketObjects_maxKeys
=== PAUSE TestAccDataSourceAWSS3BucketObjects_maxKeys
=== RUN TestAccDataSourceAWSS3BucketObjects_startAfter
=== PAUSE TestAccDataSourceAWSS3BucketObjects_startAfter
=== RUN TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== PAUSE TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== CONT TestAccDataSourceAWSS3BucketObjects_basic
=== CONT TestAccDataSourceAWSS3BucketObjects_maxKeys
=== CONT TestAccDataSourceAWSS3BucketObjects_all
=== CONT TestAccDataSourceAWSS3BucketObjects_encoded
=== CONT TestAccDataSourceAWSS3BucketObjects_prefixes
=== CONT TestAccDataSourceAWSS3BucketObjects_fetchOwner
=== CONT TestAccDataSourceAWSS3BucketObjects_startAfter
--- PASS: TestAccDataSourceAWSS3BucketObjects_basic (51.04s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_prefixes (51.05s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_startAfter (51.30s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_maxKeys (51.31s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_encoded (51.39s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_fetchOwner (51.52s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_all (51.70s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 51.768s |
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.
Looks great, @YakDriver, thanks! 🚀
--- PASS: TestAccDataSourceAWSS3BucketObjects_basic (18.48s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_maxKeys (18.69s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_fetchOwner (18.80s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_encoded (18.81s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_prefixes (18.85s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_startAfter (18.97s)
--- PASS: TestAccDataSourceAWSS3BucketObjects_all (19.02s)
This has been released in version 2.23.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! |
Fixes #2634
Changes proposed in this pull request:
aws_s3_bucket_objects
to list objects in an S3 bucketExample usage:
The result is a list of object keys:
data.aws_s3_bucket_objects.yesh.keys
Output from acceptance testing: