-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
terraform plan wants to modify api_gateway resource policy unnecessarily #15602
Comments
HI, Kit:
I have looked at both issues #5549 and #15602 which were closed years ago
and don't seem to be related with the issue I was reporting at all and I am
using Terraform 0.13.4.
Would you mind review my original report again to make sure it is properly
triaged and tracked accordingly?
Thanks
Yiping
…On Tue, Oct 13, 2020 at 8:21 AM Kit Ewbank ***@***.***> wrote:
Closed #15602
<#15602>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15602 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZF547I3UFAYLFRYHR3QUDSKRV7VANCNFSM4SM556IA>
.
|
This does seem to still be an issue. It is related to #5549, where it was claimed that using the new resource
|
It is resource "aws_api_gateway_rest_api_policy" "this" {
rest_api_id = aws_api_gateway_rest_api.this.id
policy = data.aws_iam_policy_document.this.json
triggers = {
redeployment = sha1(data.aws_iam_policy_document.this.json)
}
lifecycle {
ignore_changes = [policy]
}
} In this way, I think we'd avoid changes to the policy unless the source of that policy actually changed. |
The solution is to use a full ARN of the API gateway in the policy document. Previously it was not possible, because it would have created a dependency cycle. With a separate resources = ["${aws_api_gateway_rest_api.this.arn}/*/*/*"] instead of: resources = ["execute-api:/*/*/*"] |
Outstanding. It wasn't clear to me at all from reading the other linked issue. Thank you for spelling it out for me in black and white. I have implemented this and verified it works precisely as you suggest. |
For posterity, in case anybody shows up here down the line, this should be: resources = ["${aws_api_gateway_rest_api.this.execution_arn}/*/*/*"] if you want to control callers that can invoke the api. The regular |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
This issue was originally opened by @ypz as hashicorp/terraform#26541. It was migrated here as a result of the provider split. The original body of the issue is below.
I created an apigateway with a resource policy using following code. Once created, subsequent 'terraform plan' still wants to modify the apigateway due to some policy changes:
Here is the output from "terraform plan" command:
The root cause seems to be that the resource string "execute-api:/*" given in the configure file has been replaced with the actual apigateway's execute_arn in the applied policy to the apigateway in the states file. This replacement is seen as a configure change by "terraform plan" and therefore it wants to modify the apigatway unnecessarily.
Expected behavior: terraform plan should not suggest such unnecessary modification to apigateway
The text was updated successfully, but these errors were encountered: