-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
failed getting S3 bucket policy: couldn't find resource #32453
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
Hey @jorge-gonzalez-webbeds 👋 Can you give me a better idea of your use case? I'm not sure that I follow what you're attempting to accomplish with your use case. |
Hii! @justinretzolk What I have done is to create a module to configure a bucket as I want, this configuration tries to apply a policy to be able to access to that bucker and enable the bucket. But the problem is that there are buckets that already exist and I should not change the policy that already exists. So in that module, I add a statement to that policy that already exists to not change the initial configuration. In the case that it does not have only, I add the new one. |
@jorge-gonzalez-webbeds Are you able to supply a sample Terraform configuration and steps to reproduce? I think that would help me to get a better idea of what you're attempting; unfortunately, I'm still not quite following, but would love to help. |
Hello @justinretzolk, the project it's so big. I give you a piece of the code.
Think about the case that you do not have the variable |
This issue was meant to be resolved in v5.19 but I'm still facing this today. |
Description
I am trying to get the policy of a s3 bucket with this data:
To do this, I first import the bucket because that bucket already exists. The case may be that this bucket does not have any policy and when I try to get the policy I get the error that it could not get it. My idea was to take the policy with the resource of S3 and if it existed to make the data, but it jumps me that this attribute is deprecated. So I propose that in the case that the data of the policy of the s3 does not exist, it should return null and not to jump an error.
Error:
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: failed getting S3 bucket policy (BUCKET_NAME): couldn't find resource
│
│ with module.source_bucket["BUCKET_NAME"].data.aws_s3_bucket_policy.this,
│ on modules/s3-bucket-configuration/aws_s3.tf line 65, in data "aws_s3_bucket_policy" "this":
│ 65: data "aws_s3_bucket_policy" "this" {
References
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket_policy
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#policy
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: