Terraform v0.6.16
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 = "GET"
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}"
type = "MOCK"
}
resource "aws_api_gateway_method_response" "200" {
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}"
status_code = "200"
}
resource "aws_api_gateway_integration_response" "MyDemoIntegrationResponse" {
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}"
status_code = "${aws_api_gateway_method_response.200.status_code}"
}
resource "aws_api_gateway_deployment" "MyDemoDeployment" {
rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
stage_name = "api"
variables = {
"answer" = "42"
}
}
Error applying plan:
1 error(s) occurred:
* aws_api_gateway_deployment.MyDemoDeployment: Error creating API Gateway Deployment: BadRequestException: The REST API doesn't contain any methods
status code: 400, request id: 8b5a1dc1-47aa-11e6-9cb2-853ff7a02b06
The api should have been created with a stage and deployment.
The api is created without a stage or deployment until a second terraform apply is performed.
terraform apply terraform applyterraform applynone
Discovered while updating documentation GH-7586
This is due to a missing required depends_on = ["aws_api_gateway_method.MyDemoMethod"] in the aws_api_gateway_deployment.
How should this be avoided when defining the API with a Swagger document? I have no terraform object to depend on.
Having the same issue as @robyoung. I'm trying to create a new stage in my api-gateway using deployment. The deployment looks for an integration in the "depends_on" field, and the integration in turn looks for a method to reference, but all my methods are defined in other folders within the gateway, so I don't have a method in my main terraform file to reference .
I have the same issue as @robyoung, would be nice to find a workaround for this.
I got around this by depending on the aws_api_gateway_rest_api resource itself.
In case the stage name had space .. :+1:
Hi all,
Because this closed issue is generating notifications for subscribers, I am going to lock it and encourage anyone experiencing issues with the aws provider to open tickets there.
Please continue to open issues here for any other terraform issues you encounter, and thanks!
Most helpful comment
How should this be avoided when defining the API with a Swagger document? I have no terraform object to depend on.