terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

"Error creating API Gateway Integration Response: NotFoundException: Invalid Resource identifier specified" but other resources work

Open DamonStamper opened this issue 2 years ago • 0 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

terraform -v
Terraform v1.2.4
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v4.25.0

Affected Resource(s)

  • aws_api_gateway_integration_response

Terraform Configuration Files

# The resource for the endpoint. IE http:\\foo\${path_part}
resource "aws_api_gateway_resource" "lambda" {
  path_part   = "${var.name}" #TODO: Define specific URL path. Use "{proxy+}" to respond to any path.
  parent_id   = var.APIGateway_root_id
  rest_api_id = var.APIGateway_id
}

# How the gateway will be interacted from client
resource "aws_api_gateway_method" "any" {
  rest_api_id = var.APIGateway_id
  resource_id = aws_api_gateway_resource.lambda.id
  http_method = "ANY"
  authorization = "NONE"
}

# Integration between lambda and APIG
resource "aws_api_gateway_integration" "any" {
  rest_api_id = var.APIGateway_id
  resource_id = aws_api_gateway_resource.lambda.id
  http_method = aws_api_gateway_method.any.http_method
  integration_http_method = "ANY"
  type                    = "AWS"
  uri                     = aws_lambda_function.lambda.invoke_arn
}

resource "aws_api_gateway_method_response" "any_response_200" {
  rest_api_id = var.APIGateway_id
  resource_id = aws_api_gateway_resource.lambda.id
  http_method = aws_api_gateway_method.any.http_method
  status_code = "200"
  # response_parameters = { "method.response.header.X-Some-Header" = true }

  response_parameters = {
    "method.response.header.Access-Control-Allow-Origin" = true
  }

  response_models = {
    "application/json" = "Empty"
  }
}

resource "aws_api_gateway_integration_response" "any" {
  rest_api_id = var.APIGateway_id
  resource_id = aws_api_gateway_resource.lambda.id
  http_method = aws_api_gateway_method.any.http_method
  status_code = aws_api_gateway_method_response.any_response_200.status_code

  depends_on = [
    aws_api_gateway_integration.any,
    aws_api_gateway_resource.lambda
  ]
}

Expected Behavior

aws_api_gateway_integration_response creates without issue

Actual Behavior

aws_api_gateway_integration_response fails to create stating

module.lambda_elastic_search.aws_api_gateway_integration_response.any: Creating...
╷
│ Error: Error creating API Gateway Integration Response: NotFoundException: Invalid Resource identifier specified
│
│   with module.lambda_elastic_search.aws_api_gateway_integration_response.any,
│   on modules\lambda_elastic_access\lamdba_apig_post.tf line 41, in resource "aws_api_gateway_integration_response" "any":
│   41: resource "aws_api_gateway_integration_response" "any" {

Important Factoids

  • Other resources that reference that resource_id do so without issue.
  • depends_on has been specified so I know that resource exists first.
  • I've commented out the aws_api_gateway_integration_response resource, ran Terraform, then uncommented the resource and gotten the same error, thus double checking that the resource exists.

References

DamonStamper avatar Aug 08 '22 21:08 DamonStamper