Skip to content

Instantly share code, notes, and snippets.

@me2resh
Last active August 24, 2019 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save me2resh/9f2f10fb1f7e8b87e099ebb3f6ac6eb9 to your computer and use it in GitHub Desktop.
Save me2resh/9f2f10fb1f7e8b87e099ebb3f6ac6eb9 to your computer and use it in GitHub Desktop.
SAM Template for creating API Gateway with AWS_IAM authorizer
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
go-sam-bootstrap
SAM Template for creating API Gateway with AWS_IAM authorizer
##### Lambda Fuctions #####
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: AWS_IAM
InvokeRole: CALLER_CREDENTIALS
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./build/package/
Handler: hello-world
Runtime: go1.x
MemorySize: 128
Events:
GetRoot:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /
Method: get
Outputs:
ApiURL:
Description: "API URL"
Value: !Sub 'https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/'
@me2resh
Copy link
Author

me2resh commented Aug 18, 2019

To make an endpoint public and bypass the authorizer:

Properties:
          Path: /
          Method: get

          # Override at resource+method level
          Auth:
            Authorizer: 'NONE'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment