Reputation: 2181
I am trying to have a customer name given to my API gateway created through SAM template. and also restrict creating only one stage while deploying.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Specification template describing your function.
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: Development
Cors: "'*'"
GetAllUser:
Type: AWS::Serverless::Function
Properties:
FunctionName: loadeo_get_all_user
CodeUri: code/
Handler: get_all_user.lambda_handler
Timeout: 5
Runtime: python3.8
Role: lambda_execution
MemorySize: 128
Events:
GetAllUser:
Type: Api
Properties:
Path: /get-all-user
Method: get
RestApiId:
Ref: ApiGatewayApi
All is working fine as I want, but
How I can achieve these two cases?
Upvotes: 1
Views: 1011
Reputation: 238131
To specify Name
for your ApiGatewayApi
, you have to use Name property:
A name for the API Gateway RestApi resource
Thus your ApiGatewayApi
would be:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: Development
Name: MyApiName
Cors: "'*'"
I'm not sure I understand the second issue, thus can't comment on it right now.
As explained here you can add the following to fix the Stage
issue:
Globals:
Api:
OpenApiVersion: 3.0.1
Upvotes: 2