Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save piyushjaware/084616b33784f6bcad329aceb6dfe7b0 to your computer and use it in GitHub Desktop.
Save piyushjaware/084616b33784f6bcad329aceb6dfe7b0 to your computer and use it in GitHub Desktop.
MyAPI:
Type: AWS::Serverless::Api
Properties:
Name: MyAPI
StageName: Default
EndpointConfiguration: REGIONAL
Auth:
ApiKeyRequired: true
DefinitionBody:
openapi: 3.0.0
x-amazon-apigateway-api-key-source : "HEADER"
paths:
/public-path:
get:
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations
/path-with-apikey-required:
get:
x-amazon-apigateway-integration:
type: aws_proxy
httpMethod: POST
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations
Function1:
Type: AWS::Serverless::Function
Properties:
FunctionName: Function1
Role: <role.arn>
Handler: <handler>
Events:
API:
Type: Api
Properties:
Path: /public-path
Method: ANY
RestApiId:
Ref: MyAPI
Auth:
ApiKeyRequired: false
Function2:
Type: AWS::Serverless::Function
Properties:
FunctionName: Function2
Role: <role.arn>
Handler: <handler>
Events:
API:
Type: Api
Properties:
Path: /path-with-apikey-required
Method: ANY
RestApiId:
Ref: MyAPI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment