-
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
aws provider: normalize json of cloudwatch event_pattern before updating terraform #6025
aws provider: normalize json of cloudwatch event_pattern before updating terraform #6025
Conversation
Normalise the event_pattern of the aws_cloudwatch_event_rule resource before uploading it to AWS. AWS seems to accept a event_pattern with a JSON with new lines, but then the rule does not seem to work. Creating the rule in the AWS console works, but will setup the pattern as a json without newlines or spaces, and display a formatted JSON.
Hi @keymon Thanks for the PR - this looks good. Just a FYI, there is some of the cloudformation that handles the JSON in exactly the same way before pushing it to AWS so nice job here.
Thanks Paul |
FYI, the AWS client uploads using new lines, but I found that it trims the json removing newlines after the JSON.
Meanwhile, the object created by terraform (see the PR summary) contains a new line at the end:
|
UpdatedThe original issue reported in this PR was a misinterpretation from my side: I was testing this by using a SNS target added it manually using the web console, but I was unaware that the web interface automatically updates the target to add the required policies This miss-leaded me and I assumed that it was an issue in the cloudwatch definition, not a permission issue, as reported originally. Anyway, this PR is still a good addition as:
I will update the PR and comments to reflect my findings, and cross what is not true. As follow ups, we might:
|
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. |
Summary
Normalise the event_pattern of the aws_cloudwatch_event_rule resource
before uploading it to AWS.
AWS seems to accept a event_pattern with a JSON with new lines, but thenthe rule does not seem to work. Creating the rule in the AWS console works,
but will setup the pattern as a json without newlines or spaces, and
display a formatted JSON.
Detailed problem description
Given a config like this:
Terraform runs cleanly, and even in the interface you can see the rule created and everything fine.
But it does not work. But then, if you create it manually, it does work!But I found the issue running aws cli:
You can see that the rule created manually has not newlines.
But in the
terraform.tfstate
, the rule has no new lines:Expected result
It should work even with new lines, but I think that is a bug in AWS itself. We should file a bug if somebody can confirm that behaviour.Meanwhile, I think terraform should send a json without new lines. as done in this PR.
Terraform should push to AWS the same json it stores in the tfstate and that is uploaded when using the console, that is, without newlines and/or spaces.