Carova
Serverless AWS API Gateway Create and Deploy API
Create and Deploy an AWS API Gateway API using your Serverless YAML file. Deploy your AWS API Gateway API to a specified stage on the initial deployment.
Add the following to the resources section of your Serverless YAML file:
1resources:
2 Resources:
3 CustomApiName:
4 Type: AWS::ApiGateway::RestApi
5 Properties:
6 Name: ${self:service}-${opt:stage, self:provider.stage}-custom-api
7 EndpointConfiguration:
8 Types:
9 - REGIONAL
10 Policy:
11 Version: '2012-10-17'
12 Statement:
13 - Effect: Allow
14 Principal: '*'
15 Action: execute-api:Invoke
16 Resource:
17 - { Fn::Join: ['/', ['execute-api:', '*']] }
18
19 ApiStageDeployment:
20 Type: AWS::ApiGateway::Deployment
21 Properties:
22 RestApiId: { Ref: CustomApiName }
23 Description: ${opt:stage, self:provider.stage} Deployment
24 StageName: ${opt:stage, self:provider.stage} // provided stage
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGateway.html