-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
api_gatewayv2 integration throws 500 unless I detach/reattach #13625
Comments
@Vermyndax Thanks for raising this; I can't reproduce getting an HTTP 500 when applying the example configuration, but a subsequent $ terraform12 plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_apigatewayv2_api.sc_api: Refreshing state... [id=ekmqhtlds3]
aws_apigatewayv2_integration.sc_api_integration: Refreshing state... [id=jhsl38o]
aws_apigatewayv2_stage.sc_api_default_stage: Refreshing state... [id=$default]
aws_apigatewayv2_route.sc_api_create_route: Refreshing state... [id=l00v2m1]
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_apigatewayv2_integration.sc_api_integration will be updated in-place
~ resource "aws_apigatewayv2_integration" "sc_api_integration" {
api_id = "ekmqhtlds3"
connection_type = "INTERNET"
description = "Lambda SC Kicker"
id = "jhsl38o"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:example-apigw/invocations"
+ passthrough_behavior = "WHEN_NO_MATCH"
payload_format_version = "2.0"
request_templates = {}
timeout_milliseconds = 29000
}
# aws_apigatewayv2_stage.sc_api_default_stage will be updated in-place
~ resource "aws_apigatewayv2_stage" "sc_api_default_stage" {
api_id = "ekmqhtlds3"
arn = "arn:aws:apigateway:us-west-2::/apis/ekmqhtlds3/stages/$default"
auto_deploy = true
- deployment_id = "y2dz0a" -> null
id = "$default"
invoke_url = "https://ekmqhtlds3.execute-api.us-west-2.amazonaws.com/"
name = "$default"
stage_variables = {}
tags = {}
default_route_settings {
data_trace_enabled = false
detailed_metrics_enabled = false
throttling_burst_limit = 0
throttling_rate_limit = 0
}
}
Plan: 0 to add, 2 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run. The integration The perpetual diff on the stage looks like a bug caused by not handling a calculated |
Using AWS provider 2.65. Thanks for checking into this :) |
We see the same passthrough_behavior "WHEN_NO_MATCH" in every plan |
FYI, I have been doing some heavy modification to the lambda script that required a destroy/recreate. On recreate, the integration says it was attached in the console from the API's viewpoint, but the Lambda console disagreed. I went into the API gateway console and manually detached the integration, then reattached it and everything was fine again. |
I am having a similar issue. Like @Vermyndax, if I detach and reattach the integration, everything is resolved and works. I also have similar issues with the
Similar can be applied to the |
@Vermyndax - I have been investigating this issue further in order to find a workaround and I think I have found the problem... The issue is around Lambda permissions - You will note that if you detach and re-attach the integration, the permissions for your Lambda function with change. Generic code to set the permission is as follows:
Suggest that the issue can be closed... |
Thanks, @adatoo looks like the workaround did the trick! |
I added an aws_lambda_permission like that, and my API started working. Then I removed the permission, reapplied, and it stayed working! In fact, now I cannot figure out how to get it to go back to broken again. The aws_lambda_permission will not go away. |
Suggest that you delete the API Gateway completely and re-apply the stack. That should clear everything... |
Thanks @adatoo ! That worked, but are you saying it is a permanent clear up, or will glitchy-ness return to this permission for the gatewayv2 situation? BTW, my short term objective was accomplished, which was adding vital info to the access_log_settings of the stage -- which now looks like this (with the permission error being intentional at this point):
I wish that I had found and added $context.integrationErrorMessage to the access_log_settings when I started with my gatewayv2 exploration. |
Hi @warrenstephens. I suspect that this issue will persist. My reasoning is that the permission is implicitly declared when attaching the integration via the AWS Console and I suspect this creates some form of cached copy. I don't understand the inner workings sufficiently to be able to comment. Whilst deleting and re-creating the API gateway did clear it, I would guess the minimum you would need to do to clear this would be to delete the integration in addition to the permission. |
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! |
Community Note
Terraform Version
Using hashicorp/terraform:light (latest) so assume it's 12.26 :)
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Should have deployed a working API gateway
Actual Behavior
The integration doesn't work properly. When trying to use it, it throws an Internal Server Error 500. If I go to the console and detach the integration, then reattach it, it works fine.
Steps to Reproduce
terraform apply
Important Factoids
Running terraform in a Codebuild job
References
The text was updated successfully, but these errors were encountered: