https://pulumi.com logo
Title
m

mysterious-belgium-44686

06/05/2021, 9:23 PM
👋 Hey all, having a great experience with Pulumi so far. I had a question about API Gateway, wondering if I'm misunderstanding or if maybe this is a limitation in Pulumi. The AWS API Gateway docs state that you can specify
$default
as a stage name, which will let you route via
/
- I'd like to do that.
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}.<http://amazonaws.com/|amazonaws.com/>. You use this URL to invoke an API stage.
I set that in my pulumi code:
stage = aws.apigateway.Stage(
            f"{self.rest_api._name}-prod-stage",
            deployment=deployment.id,
            rest_api=self.rest_api.id,
            stage_name="$default",
            opts=pulumi.ResourceOptions(parent=self),
        )
but I get this error:
aws:apigateway:Stage (api-gateway-prod-stage):
    error: 1 error occurred:
    	* Error creating API Gateway Stage: BadRequestException: Stage name only allows a-zA-Z0-9_
From the error + docs it looks like Pulumi doesn't seem to support this?
Each API Gateway deployment is associated with a so-called stage. A stage is simply a version of your API, such as stage, prod, v1, or v2. For simple APIs, you will likely just have one. You can always define a custom stage name, but if you leave it off, a default of stage will be chosen.
e

echoing-zebra-28421

06/05/2021, 9:26 PM
@mysterious-belgium-44686 I think you are setting the stage name as "stage name =" $ default "," that "$" is a wrong character
m

mysterious-belgium-44686

06/05/2021, 9:27 PM
Yeah, I'm trying to set the stage name to
$default
- in the AWS API Gateway docs they indicate that
$default
is a special stage name that will let you route via
/
Oh darn, I forgot to link the docs.
b

billowy-army-68599

06/05/2021, 10:28 PM
@mysterious-belgium-44686 I'm not entirely sure because I'm on my phone not laptop, but I think the
$default
only applies to apiGateway v2, and you're using the v1 resource
m

mysterious-belgium-44686

06/05/2021, 10:28 PM
Aha, that would explain it - thanks 👍
b

billowy-army-68599

06/05/2021, 10:28 PM
the v1 API docs don't reference
$stage
at all: https://docs.aws.amazon.com/apigateway/api-reference/resource/stage/
m

mysterious-belgium-44686

06/05/2021, 10:29 PM
Very interesting, this gives me something to dig into then - thanks for the help.