Skip to content
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

Document permissions required to read resource metadata #17433

Closed
iainelder opened this issue Feb 3, 2021 · 3 comments
Closed

Document permissions required to read resource metadata #17433

iainelder opened this issue Feb 3, 2021 · 3 comments
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service.

Comments

@iainelder
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I'm using an S3 bucket as an example, but I believe this applies to all resources.

My use case: I'm trying to refer to a centralized audit bucket in the delegated administrator account of AWS Config so that I can set up the config recorders in the member accounts to deliver config changes to that bucket.

I'm using the terraform-aws-secure-baseline module to do this (see its organizations example). It uses a data source to refer get metadata for the bucket. Becuase the bucket is in the delegated administrator account and by default does not allow other accounts to access it, reading the metadata from the member account fails.

Error: Failed getting S3 bucket: Forbidden: Forbidden
	status code: 403, request id: 96120BB4E7D053AB, host id: wUZJa464AcyhMENVFS8bV5Z5oAhKxXlU4j5Uug+yj0QqAFKoJHQVpj+Psq+NZMRjXMKBAPGx65g= Bucket: "example-bucket-abc"

I couldn't find the permissions required to set this up in the documentation. I figured them out by reading the source code for terraform-provider-aws and then referencing the AWS documentation (links below). It's an inconvenient way to work with Terraform when the documentation is normally so good.

I may have missed something, but I believe the API methods called by resourceAwsS3BucketRead are:

  • HeadBucket (also via GetBucketRegionWithClient)
  • GetBucketPolicy
  • GetBucketAcl
  • GetBucketCors
  • GetBucketWebsite
  • GetBucketVersioning
  • GetBucketLifecycleConfiguration
  • GetBucketReplication
  • GetObjectLockConfiguration (via readS3ObjectLockConfiguration)
  • GetBucketTagging (via S3BucketListTags)

Most of the methods use IAM actions with the same name, but there are exceptions:

  • HeadBucket: s3:ListBucket
  • GetBucketLifecycleConfiguration: s3:GetLifecycleConfiguration
  • GetBucketReplication: s3:GetReplicationConfiguration
  • GetBucketCors: s3:GetBucketCORS (spelling differs only in case, and IAM is
    insensitive)
  • GetObjectLockConfiguration: s3:GetBucketObjectLockConfiguration

After

New or Affected Resource(s)

  • aws_s3_bucket
  • all others?

Potential Terraform Configuration

data "aws_s3_bucket" "external" {
  bucket = "bucket-in-another-account"
}

References

@iainelder iainelder added the enhancement Requests to existing resources that expand the functionality or scope. label Feb 3, 2021
@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Feb 3, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 3, 2021
@ewbankkit ewbankkit added documentation Introduces or discusses updates to documentation. and removed needs-triage Waiting for first response or review from a maintainer. labels Feb 3, 2021
@ewbankkit
Copy link
Contributor

@iainelder Thanks for raising this issue.
There is Roadmap item (#9154) that you may want to check out that is gathering requirements and feedback on such a feature.

@iainelder
Copy link
Author

Perfect. Fine to close this as a duplicate :-)

@ghost
Copy link

ghost commented Mar 6, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
Development

No branches or pull requests

2 participants