Hello.
I am creating an API Gateway using AWS SAM.
At that time, I am trying to name "dev" as "StageName".
However, when I actually deploy it, a stage named "Prod" is created.
Is it not possible to set a custom name for an API Gateway stage in AWS SAM?
I checked the GitHub issue below, but the issue was not resolved.
https://github.com/aws/serverless-application-model/issues/191
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Api:
OpenApiVersion: 3.0.2
Parameters:
Stage:
Type: String
Default: dev
Resources:
ServerlessRestApi:
Type: AWS::Serverless::Api
Properties:
OpenApiVersion: 3.0.2
StageName: !Ref Stage
Name: !Sub "${Stage}-Api"
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.9
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
RestApiId: !Ref ServerlessRestApi
Outputs:
CsrfTokenApiUrl:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/${Stage}/hello"
samconfig.toml is as follows.
version=0.1
[development.deploy.parameters]
stack_name = "dev-api-stack"
resolve_s3 = true
s3_prefix = "dev-api-stack"
region = "ap-northeast-1"
confirm_changeset = true
capabilities = "CAPABILITY_IAM"
disable_rollback = true
parameter_overrides = [
"Stage=dev"
]
image_repositories = []
app.py looks like this:
def lambda_handler(event, context):
return {
"statusCode": 200,
"body":"message: hello world",
}
Thank you for your reply. The template I'm using already has "OpenApiVersion: 3.0.2" set.