-
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_elasticsearch_domain access_policies keeps reapplying #3634
Comments
it appears to be changing it from unsorted to sorted over and over, but I tried updating the policy to match the output here, and it still changes it. access_policies: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"ES\",
\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",
\"Resource\":\"arn:aws:es:us-east-1:xxxx:domain/test/*\",
\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":[\"127.0.0.1\",\"127.0.0.2\"]}}}]}" =>
"{\"Statement\":[{\"Action\":\"es:*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":
[\"127.0.0.1\",\"127.0.0.2\"]}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},
\"Resource\":\"arn:aws:es:us-east-1:xxxx:domain/test/*\",\"Sid\":\"ES\"}],
\"Version\":\"2012-10-17\"}" |
Having the same issue here, tried the same solution. |
Same issue here too |
I'm seeing the same issue. I tried moving the policy to a |
This is a general problem with all IAM policies in AWS which keeps appearing in many different places, it's probably best to follow this thread: TL;DR The issue is that we don't (de)serialise the JSON before/after sending it to AWS and AWS returns the JSON in a different format - either different ordering or list with 1 member instead of a string or visa versa. I don't think we can/should be solving this on the resource level, I'm mentioning a potential solution in the linked thread #3124 (comment) |
#4245 has fixed some of the cases |
This is fixed now. You need to compare the proposed changes and you will realise amazon reformats the input you give it, just match the output from amazon to the correct format in your policy and its all ok. |
@willejs fixed in HEAD or in a release? As of Terraform 0.6.9 it still changes each time, even after reformatting to match AWS output |
@steveh latest release. |
this still exists in Terraform v0.6.15 |
Also exists in |
@willejs I think matching amazon output doesn't always work. For example, this policy allows {
"Statement": [{
"Action": "es:*",
"Effect": "Allow",
"Principal": {
"AWS: [
"arn:aws:iam::123456789012:user/user1",
"arn:aws:iam::123456789012:user/user2",
"arn:aws:iam::123456789012:user/user3"
]
},
"Resource": "arn:aws:es:us-east-1:123456789012:domain/some-es-cluster/*"
}],
"Version": "2012-10-17"
} However, if you query the api repeatedly, you will notice the ordering of the users array is not deterministic. So, it's possible to get I'm not sure what' the best approach to solve this, but maybe we can parse the returned JSON and sort the array? ( Seems pretty hacky though... ) For now, I'm using:
as a temporary workaround. |
I have a fix in #7785. |
What's the status of this? I've seen some fixes landed, but terraform built from master still always shows changes when I run plan. |
Hi all I believe that this has been fixed as of Terraform 0.7.3 We introduced a feature that will allow us to compare the structure of IAM Policy documents The line:
Should be fixing anything that is considered equivalent. This is things like ordering, single array values as strings etc Please let me know if this is not the case for you Paul |
@stack72 this does not fix our
Here is our sns delivery_policy
|
Just to verify
|
Terraform v0.7.3 aws_elasticsearch_domain access_policies are still being applied on each run. |
@stack72 can we remove the 'waiting-response' tag and possibly see some work on this bug? |
@aerickson hi there! Are you suggesting you are going to spent some time looking into the issue Alternatively, I urge your to remain polite and vigilant of inappropriate comments, and have some patience. I am sure that this issue is going to be fixed in an upcoming releases, so stay put! |
Hi all! Thanks for the investigation and workarounds here. IAM policies have been an ongoing source of stress for Terraform due to each service normalizing them in a slightly different way. We recently added some mechanisms to be able to "normalize" diffs to take care of this sort of thing, but there hasn't yet been a specific change to address this ElasticSearch-specific weirdness, so this remains a problem as of this writing. I'm going to close this out in favor of the later ticket #5067, because there's been further discussion and investigation on that one that could aid in resolution and I think it'd be best to consolidate discussion over there. |
as workaround I use ingnore_changes for now: |
This is closed buy I'll leave this comment here in case somebody runs across it having a sim issue: If the principal is an account number the ES service will change it to this format:
Change the policy in terraform or it will see it as different every time. |
@ProTip you're absolutely right, I did notice a few acc test failures in the past weeks. Oddly they were intermittent, but they don't affect just ES policy, but all policies. The trouble is that we can't translate |
@radeksimko I think I'm not following your example there; is the API here really normalizing a specific role into the whole AWS account? That seems problematic, since it would grant broader access than otherwise and thus isn't semantically equivalent. My read of @ProTip's comment made me think it was something more managable: "Principal": {"AWS": "1234567"} ...normalizes to... "Principal": {"AWS": "arn:aws:iam::1234567:root"} If that's right then this at least should be possible to normalize without any further API calls. These two are documented as being equivalent in the |
@apparentlymart No, but it is flapping between ARN and "unique ID" of a role/user. I think you just mentioned 3rd format the Principal accepts - AWS account ID and yes - that can be swapped for ARN ending in The trouble is that people don't always grant access to the whole account (nor they should), but to a specific user or a role. Check out this test failure from yesterday:
|
Ahh, okay... understood. Was missing that context, and indeed didn't even know that roles had ids like that. Fair enough! I wonder if in this case we could convince AWS to consider this a bug; given that role unique ids and ARNs are so dissimilar, even putting Terraform's diffing needs aside it seems like a UX problem to replace something human-understandable (an ARN with the human-selected role name embedded) with something human-opaque that requires further API queries to understand. |
@mnothic I don't think ignoring
main.tf
template file
|
Is this still being managed by #5067 ? This thread seems like the latest conversation and I am still getting problems with terraform 'flip-flopping' using I've used, the not ideal, lifecycle workaround but should this still be happening? |
@Puneeth-n No, mainly as I've been sticking with using Happy to stick with |
FYI Still happening on Terraform v0.10.7, best shot is what @Puneeth-n wrote here |
FYI v0.10.8 still has this issue. |
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. |
I have
The access_policies section keeps reapplying on every run. I can verify in AWS that the correct policy is applied. I suspect it is this line master...lancehudson:patch-1
The text was updated successfully, but these errors were encountered: