Can multiple methods be scripted in the terraform?
When using AWS console, I’m able to create ANY
method, that uses authorization, and a separate POST
method without it. However, I can’t script it in TF - it generates an error when ran saying that the method already exists:
Error: Error creating API Gateway Method: ConflictException: Method already exists for this resource
on terraform.tf line 9872, in resource "aws_api_gateway_method" "app_integrations_post":
9872: resource "aws_api_gateway_method" "app_integrations_post" {
This is how I’ve tried to script it. Can this be done with terraform it’s this is a limitation and I have to create separate endpoints? Any help much appreciated.
resource "aws_api_gateway_method" "app_integrations" {
rest_api_id = aws_api_gateway_rest_api.app_api.id
resource_id = aws_api_gateway_resource.app_integrations.id
http_method = "ANY"
authorization = "COGNITO_USER_POOLS"
authorizer_id = aws_cloudformation_stack.app_api_authorizer.outputs["AuthorizerId"]
request_parameters = {
"method.request.path.proxy" = true
}
depends_on = [
aws_api_gateway_rest_api.app_api
]
}
resource "aws_api_gateway_method" "app_integrations_post" {
rest_api_id = aws_api_gateway_rest_api.app_api.id
resource_id = aws_api_gateway_resource.app_integrations.id
http_method = "POST"
authorization = "NONE"
request_parameters = {
"method.request.path.proxy" = true
}
depends_on = [
aws_api_gateway_rest_api.app_api
]
}