Skip to content

Instantly share code, notes, and snippets.

@AndrzejKomarnicki
Last active December 5, 2019 21:40
Show Gist options
  • Save AndrzejKomarnicki/d5b08b1815664c737c77537daa21d773 to your computer and use it in GitHub Desktop.
Save AndrzejKomarnicki/d5b08b1815664c737c77537daa21d773 to your computer and use it in GitHub Desktop.
AWS SAM template.yaml with the new API Gateway V2 HTTP API support
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-appapigw2
Sample SAM Template for sam-appapigw2
# API Gateway V2 with HTTP API
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs12.x
Events:
HelloWorld:
Type: HttpApi #changed from default Api type
Properties:
Path: /hello
Method: get
Outputs:
HelloWorldHttpApi:
Description: "This API defaults to a StageName called '$default' that cannot be configured"
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/hello" #SAM will use the $default stage from Api Gateway
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment