Skip to content

Instantly share code, notes, and snippets.

@asishrs
Created February 1, 2020 06:15
Show Gist options
  • Save asishrs/d1d98251fe1db10f2ca9de3fd77ecb85 to your computer and use it in GitHub Desktop.
Save asishrs/d1d98251fe1db10f2ca9de3fd77ecb85 to your computer and use it in GitHub Desktop.
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
ApiKeySourceType: HEADER
Description: An API Gateway for Lambda APIs
EndpointConfiguration:
Types:
- REGIONAL
Name: !Join ["", [{"Ref": "AWS::StackName"}, "-api"]]
ProxyResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
RestApiId: !Ref ApiGatewayRestApi
ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
PathPart: !Ref "apiResourcePath"
ProxyResourceANY:
Type: 'AWS::ApiGateway::Method'
Properties:
RestApiId: !Ref ApiGatewayRestApi
ResourceId: !Ref ProxyResource
HttpMethod: GET
ApiKeyRequired: true
AuthorizationType: NONE
OperationName: !Ref "apiResourcePath"
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction.Arn}/invocations'
ApiGatewayModel:
Type: AWS::ApiGateway::Model
Properties:
ContentType: 'application/json'
RestApiId: !Ref ApiGatewayRestApi
Schema: {}
ApiGatewayStage:
Type: AWS::ApiGateway::Stage
Properties:
DeploymentId: !Ref ApiGatewayDeployment
Description: Lambda API Stage v1
RestApiId: !Ref ApiGatewayRestApi
StageName: !Ref "apiStageName"
ApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn: ProxyResourceANY
Properties:
Description: Lambda API Deployment
RestApiId: !Ref ApiGatewayRestApi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment