-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
providers/aws: Add support for policy on S3 bucket #1992
Conversation
|
||
if v := out.Policy; v == nil { | ||
if policy != "" { | ||
return fmt.Errorf("bad policy, found nil, expected: %s", policy) |
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 currently fails due to aws/aws-sdk-go#236
I believe @m-s-austin also ran into this in iJoinSolutions@cd45e45
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.
That does indeed appear to be bugged in the sdk, I had not had a chance to test it directly yet.
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 has been resolved in aws/aws-sdk-go@c37b3cb
1dfec5a
to
cb62645
Compare
|
@justincampbell I have been testing your code today, and one thing I noticed, in the version I was working on with a separate resource for the policy, I could delete the policy resource from the tf file, and then terraform apply would also delete the policy from the bucket. It seems that in this version I can not achieve the same functionality? Deleting the argument has no action and if I try to explicitly set policy = "" I get an error policy: "" => "Error parsing JSON: unexpected end of JSON input" leaving me with no way to remove a policy from tf. |
|
@m-s-austin Are you using the latest code from this PR? It seems to remove properly for me. The I'm not sure what to do here. We could change |
@catsby You may need to update aws-sdk-go |
@justincampbell that did help, thanks 😄 It seems though that I have invalid JSON:
I do not want that policy applied 😸 |
That issue aside, I used a valid policy JSON doc (from a file) and it seemed to apply / remove as expected. @justincampbell did you test this with in-line policies? That's where I got the parsing error, I wonder if Go or HCL did something there. If you anticipate most people using from a file, we should provide show the Other than that, 👍 |
@justincampbell sorry that was my bad I forgot to update sdk. Seems to be working now |
@catsby Does a heredoc work? Otherwise you would have to escape all of the quotes |
I have tested with this format it works fine:
|
@m-s-austin Thanks for testing! |
AWS always returns a compressed JSON body, without spaces or newlines, so we round-trip the JSON before storing in the state.
@catsby Added |
LGTM 👍 |
providers/aws: Add support for policy on S3 bucket
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Adds support for policies on S3 buckets: http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html