Skip to content
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

aws_api_gateway_deployment: Error creating API Gateway Deployment: BadRequestException: No integration defined for method #21210

Closed
kwhitejr opened this issue Oct 8, 2021 · 2 comments
Labels
service/apigateway Issues and PRs that pertain to the apigateway service.

Comments

@kwhitejr
Copy link

kwhitejr commented Oct 8, 2021

This error message feels like a perennial issue for aws_api_gateway_deployment. I want to deploy an API Gateway REST API with OpenAPI Spec. I've followed the official example and advice as closely as possible, and read through previous reports (11344 and official reply), but I still encounter error Error creating API Gateway Deployment: BadRequestException: No integration defined for method with the following setup. This is not a production app (yet), so I can freely destroy and (re-)apply, but hasn't helped yet.

I also gave it a try with a depends_on block in the deployment, but it made no difference.

Versions

Terraform v1.0.8
hashicorp/aws v3.62.0. <-- fwiw, I also gave v2.x.x a go and same result

modules/api-gateway/main.tf

resource "aws_api_gateway_rest_api" "rest_api" {
  name           = "${var.application_name} API"
  description    = var.description
  api_key_source = "HEADER"
  body = templatefile("${path.module}/../../../docs/api.yaml", {
    region         = var.region
    lambda_arn     = var.lambda_arn
    lambda_timeout = 29000
  })

  endpoint_configuration {
    types = ["REGIONAL"]
  }
}

resource "aws_api_gateway_deployment" "deployment" {
  rest_api_id = aws_api_gateway_rest_api.rest_api.id

  lifecycle {
    create_before_destroy = true
  }

  triggers = {
    redeployment = sha1(jsonencode(aws_api_gateway_rest_api.rest_api.body))
  }
}

resource "aws_api_gateway_stage" "stage" {
  deployment_id = aws_api_gateway_deployment.deployment.id
  rest_api_id   = aws_api_gateway_rest_api.rest_api.id
  stage_name    = var.stage_name
}

Error Output

...
module.topics_useast1.module.api_gateway.aws_api_gateway_rest_api.rest_api: Creating...
module.topics_useast1.module.api_gateway.aws_api_gateway_rest_api.rest_api: Creation complete after 3s [id=pdtajs9c1m]
module.topics_useast1.module.api_gateway.aws_lambda_permission.apig_to_lambda: Creating...
module.topics_useast1.module.api_gateway.aws_api_gateway_deployment.deployment: Creating...
module.topics_useast1.module.api_gateway.aws_lambda_permission.apig_to_lambda: Creation complete after 1s [id=AllowExecutionFromAPIGateway]
╷
│ Error: Error creating API Gateway Deployment: BadRequestException: No integration defined for method
│
│   with module.topics_useast1.module.api_gateway.aws_api_gateway_deployment.deployment,
│   on ../../../modules/api-gateway/main.tf line 16, in resource "aws_api_gateway_deployment" "deployment":
│   16: resource "aws_api_gateway_deployment" "deployment" {

@bflad am I taking crazy pills?

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/apigateway Issues and PRs that pertain to the apigateway service. labels Oct 8, 2021
@kwhitejr
Copy link
Author

kwhitejr commented Oct 8, 2021

Naturally, my mistake surfaced after I cried wolf. Turns out that my OpenAPI Spec lacked the proper x-amazon-apigateway-integration blocks.

I leave this here as a testament to my shame.

@kwhitejr kwhitejr closed this as completed Oct 8, 2021
@github-actions github-actions bot removed the needs-triage Waiting for first response or review from a maintainer. label Oct 8, 2021
@github-actions
Copy link

github-actions bot commented Jun 3, 2022

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
Development

No branches or pull requests

1 participant