Newly created API Gateway integration resource being deleted on replace operation · Issue #21907 · hashicorp/terraform-provider-aws

How do I integrate an AWS service by using API Gateway as a proxy?
How do I integrate an AWS service by using API Gateway as a proxy?

Newly created API Gateway integration resource being deleted on replace operation #21907

Newly created API Gateway integration resource being deleted on replace operation #21907

Comments

LukasReinauer
commented
Nov 25, 2021

Community Note Terraform CLI and Terraform AWS Provider Version Affected Resource(s) Terraform Configuration Files

resource “aws_api_gateway_rest_api” “MyDemoAPI” { name = “MyDemoAPI” description = “This is my API for demonstration purposes” } resource “aws_api_gateway_resource” “MyDemoResource” { rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id parent_id = aws_api_gateway_rest_api.MyDemoAPI.root_resource_id path_part = “mydemoresource” } resource “aws_api_gateway_method” “MyDemoMethod” { rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id resource_id = aws_api_gateway_resource.MyDemoResource.id http_method = “POST” authorization = “NONE” } resource “aws_api_gateway_integration” “MyDemoIntegration” { rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id resource_id = aws_api_gateway_resource.MyDemoResource.id http_method = aws_api_gateway_method.MyDemoMethod.http_method integration_http_method = “GET” type = “AWS” uri = “ANY Lambda Invocation URI” timeout_milliseconds = 29000 request_parameters = { “integration.request.header.X-Authorization” = “‘static'” } # Transforms the incoming XML request to JSON request_templates = { “application/xml” = <<EOF { “body” : $input.json(‘$’) } EOF } } resource “aws_api_gateway_deployment” “example” { rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id triggers = { redeployment = sha1(jsonencode([ aws_api_gateway_resource.MyDemoResource.id, aws_api_gateway_method.MyDemoMethod.id, aws_api_gateway_integration.MyDemoIntegration.id, ])) } lifecycle { create_before_destroy = true } } resource “aws_api_gateway_stage” “example” { deployment_id = aws_api_gateway_deployment.example.id rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id stage_name = “example” }

Debug Output

https://gist.github.com/LukasReinauer/5572a875bc93b3538a518c974d277e72

Expected Behavior

First apply: creates all resources

Second apply:

Actual Behavior

First apply: creates all resources

Second apply:

Third apply:

aws_api_gateway_integration.MyDemoIntegration: Creating…

Steps to Reproduce

The text was updated successfully, but these errors were encountered:

justinretzolk
commented
Dec 9, 2021

Hey @LukasReinauer 👋 Thank you for taking the time to raise this issue! Would it be possible to provide the plan output as well, so that we can get an idea of what’s causing Terraform to want to replace the resource(s)?

n2N8Z
commented
Mar 31, 2022

@LukasReinauer thanks for having identified this.

@justinretzolk here the requested plan output that results in the integration being deleted as @LukasReinauer pointed out.

Update the aws_api_gateway_integration credentials to cause a replace.

The aws_api_gateway_integration is destroyed at the end leaving a broken API.

Indigenuity
commented
Apr 7, 2022

I’m seeing the same behavior

Here’s the order things happen in during the apply

I see this behavior when the integration is replaced for any reason, whether it’s

I’m on AWS provider 4.8.0 and terraform 1.0.0

ernestol0817
commented
Jul 7, 2022

Folks, I’m running into the exact same scenario.

Apologies as I can not share my code or even my output due to some privacy restrictions.

radubuciuceanu
commented
Apr 11, 2023

Having the same problem. On second apply, the integration’s being removed (with same ID) when creds arn changes. Second plan’s gonna show the missing resources.

You are watching: Newly created API Gateway integration resource being deleted on replace operation · Issue #21907 · hashicorp/terraform-provider-aws. Info created by THVinhTuy selection and synthesis along with other related topics.

Rate this post

Related Posts