-
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 constantly updates resource policy on API Gateway #5549
Comments
Updating a resource policy should also trigger deployment of new stages/deployments of the REST API in order for the resource policy to take effect according to https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-create-attach.html
Ugh 😱 😱 😱 |
I have the same issue with the following template :
|
I include my In this case, perhaps the |
Anyone found a workaround for this yet? For a workaround, I'd be fine with some method that creates aws_api_gateway_rest_api and then requires another terraform run to correct the policy. I haven't been able to come up with anything yet that doesn't create a circular dependency on aws_api_gateway_rest_api.myapi.root_resource_id |
@sfdc-afraley : There is a workaround. You can set a E.g.
I believe you could then explicitly taint the |
I just ran into the same cycle issue... but decided to just set the policy resources to "*" (it's attached only to this particular rest_api object anyway, so it can't effect anything else...) |
I have some workarounds to force the stage to be deployed and I thought I would try similar with the policy. I tested improvements to
This looks like the same as issue #576 where for Elasticsearch a |
any update on this? |
I have a feeling that the resource reference is wrong in example given originally:
it should be:
Judging from: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html Any idea how to trigger trigger deployment in order for the resource policy to take effect ? |
@Constantin07 no, these two patterns are different. |
@sergei-ivanov thanks for explanation, indeed terraform tries to change the resource ARN every time is applied which is annoying.
|
...for which I already have a linked PR (#10986), which needs some attention from the project team. |
nice work @sergei-ivanov, much appreciated! |
I'm encountering an issue in v0.11.14 whereby the resource policy for API Gateway is not getting created at all during the first terraform apply. If I re-run terraform apply immediately afterwards the policy gets created and attached but now the API itself doesn't get updated and requires a manual deploy through the AWS console in order for the policy to take effect. |
A Terraform equivalent of this command in AWS CLI is what we're looking for. That would allow to define the Resource Policy outside of the API and then 'attach' it and 'deploy' the API afterwards (all within Terraform) aws apigateway update-rest-api |
Is there any security risk or concern using I implemented this approach as I do not want to ignore policy updates or have to remember to always |
I have run into the same cycle issue. Is there no other solution than to use |
Hi folks 👋 Similar to other services that support resource policies, we have opted to provide support for a new This functionality will release in version 3.16.0 of the Terraform AWS Provider later this week. Thank you to @sergei-ivanov and @DrFaust92 for their implementation efforts. 👍 |
This has been released in version 3.16.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
We're seeing an issue where Terraform constantly updates the resource policy of an API gateway:
In our terraform module we want to apply a resource policy our API gateway, so we have the following:
According to the Amazon docs we can use this
execute-api:/stage/method/part
short hand and AWS will expand this to the full ARN of theaws_api_gateway_rest_api
instance.Ideally we'd like to be able to change the
resources
part of the resource policy to reference the ARN of theaws_api_gateway_rest_api
instance directly, like so:except that this introduces a cycle between the resource policy and the REST API as both require each other to exist before they can be created:
This appears to be due to the unfortunate way that resource policies are stored in AWS. Reading the docs it looks like resource policies don't exist as entities themselves but only as things that hang off a REST API.
At the moment we're working around this by ignoring policy changes - it'd be great if there were a nicer way to do this.
Community Note
Terraform Version
0.11.7
1.31.0
Affected Resource(s)
The text was updated successfully, but these errors were encountered: