Reputation: 162
I have an API Gateway setup using Terraform. I need to be able to visit the API Gateway on the base path, i.e, without the stage name appended to the base URL.
https://{api_id}.execute-api.{region}.amazonaws.com/
<- acceptable
https://{api_id}.execute-api.{region}.amazonaws.com/{StageName}
<- not acceptable
I would do this from the console by creating a default deployment stage like here.
I looked but could not find anything in the terraform documentation here for stages
I want to be able to do this by creating the default stage, not using a aws_api_gateway_domain_name resource
Upvotes: 11
Views: 6948
Reputation: 1002
From the AWS documentation:
You can create a
$default
stage that is served from the base of your API's URL—for example,https://{api_id}.execute-api.{region}.amazonaws.com/
. You use this URL to invoke an API stage.
The Terraform documentation doesn't mention this, but you can create a stage with $default
as the stage name. Calling the base path should then use that stage.
resource "aws_apigatewayv2_stage" "example" {
api_id = aws_apigatewayv2_api.example.id
name = "$default"
}
Upvotes: 15
Reputation: 238209
aws_api_gateway_domain_name
is for REST API which does not have a default stage. To create such a stage you have to use HTTP API which in terraform is provided by the family of apigatewayv2 methods.
Upvotes: 5