Skip to content

Instantly share code, notes, and snippets.

@jacepark12
Created December 9, 2019 14:19
Show Gist options
  • Select an option

  • Save jacepark12/28807d651fcdf6fb20f73bff3bed2ae6 to your computer and use it in GitHub Desktop.

Select an option

Save jacepark12/28807d651fcdf6fb20f73bff3bed2ae6 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'SAM Sample'
Globals:
Function:
Timeout: 3
Api:
Cors:
AllowMethods: "'GET,POST,OPTIONS,PUT,DELETE'"
AllowHeaders: "'content-type'"
AllowOrigin: "'*'"
AllowCredentials: "'*'"
Parameters:
Stage:
Type: String
AllowedValues:
- dev
- v1
DATABASE:
Type: String
Default: test_database
AllowedValues:
- test_database
- production_database
Resources:
Sample API:
Type: AWS::Serverless::Api
Properties:
StageName: !Ref Stage
RDSLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: RDSLayer
Description: Dependencies for sam app
ContentUri: util/
CompatibleRuntimes:
- python3.7
UsersSignup:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./users
Handler: app.signup_handler
Layers:
- !Ref RDSLayer
Runtime: python3.7
Role: arn:aws:iam::155087259035:role/LambdaRole
Events:
RequestUserSignup:
Type: Api
Properties:
RestApiId: !Ref SampleAPI
Path: /users/signup
Method: post
Environment:
Variables:
DATABASE: !Ref DATABASE
UsersLogin:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./users
Handler: app.login_handler
Layers:
- !Ref RDSLayer
Runtime: python3.7
Role: arn:aws:iam::155087259035:role/LambdaRole
Events:
RequestUsersLogin:
Type: Api
Properties:
RestApiId: !Ref SampleAPI
Path: /users/login
Method: post
Environment:
Variables:
DATABASE: !Ref DATABASE
Outputs:
SniperAPI:
Description: API Gateway endpoint URL
Value:
Fn::Sub: https://${SampleAPI}.execute-api.${AWS::Region}.amazonaws.com/${Stage}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment