hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.71k stars 9.07k forks source link

[Bug]: aws_apigatewayv2_deployment not working for socket api #36078

Open diegogonzalezfe opened 5 months ago

diegogonzalezfe commented 5 months ago

Terraform Core Version

1.7.4

AWS Provider Version

5.38.0

Affected Resource(s)

aws_apigatewayv2_deployment

Expected Behavior

On creation/redeployment, the resource is created correctly.

Actual Behavior

Stage deployment is not performed.

Relevant Error/Panic Output Snippet

Terraform log:

...
module.socket-api-order-gateway.aws_apigatewayv2_deployment.xxx: Creating...
module.socket-api-order-gateway.aws_apigatewayv2_deployment.xxx: Creation complete after 1s [id=of9zuj]

AWS Console (API Stage):

Active deployment
-

Terraform Configuration Files

resource "aws_apigatewayv2_api" "xxx" {
  name                       = "xxx"
  protocol_type              = "WEBSOCKET"
  route_selection_expression = "xxx"
}

resource "aws_apigatewayv2_stage" "xxx" {
  api_id = aws_apigatewayv2_api.xxx.id
  name   = xxx
}

resource "aws_apigatewayv2_deployment" "xxx" {
  api_id = xxx

  depends_on = [
    aws_apigatewayv2_route.xxx
  ]

  triggers = {
    redeployment = sha1(join(",", tolist([
      jsonencode(aws_apigatewayv2_route.xxx),
      jsonencode(aws_apigatewayv2_integration.xxx),
      jsonencode(aws_apigatewayv2_model.xxx),
      jsonencode(aws_apigatewayv2_route_response.xxx)
    ])))
  }
}

Steps to Reproduce

terraform init terraform apply

Debug Output

NA

Panic Output

NA

Important Factoids

Our issue is that in the creation of the deployment for the stage, the terraform execution seems correct but it has no effect, our API Gateway is a websocket.

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 5 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 5 months ago

Hey @diegogonzalezfe 👋 Thank you for taking the time to raise this! My initial thought it that given that there aren't any errors being thrown, this may be configuration related rather than a bug with the provider. Are you able to supply debug logs (redacted as needed)?

bryantbiggs commented 3 months ago

@diegogonzalezfe you need to add the deployment_id into your stage:

resource "aws_apigatewayv2_stage" "xxx" {
  api_id        = aws_apigatewayv2_api.xxx.id
+ deployment_id = aws_apigatewayv2_deployment.xxx.id
  name          = xxx
}
justinretzolk commented 1 month ago

@diegogonzalezfe 👋 Were you able to test the suggestion above to see if it resolves your issue?