Skip to content

Instantly share code, notes, and snippets.

@toricls
Created December 14, 2017 04:37
Show Gist options
  • Save toricls/aa6866a0b2e59fd819cb69efd80bd2f2 to your computer and use it in GitHub Desktop.
Save toricls/aa6866a0b2e59fd819cb69efd80bd2f2 to your computer and use it in GitHub Desktop.
A transformed version of 'Hello World' AWS SAM template (see original version here: https://gist.github.com/toricls/7d078e6d25515f26b73bfa3a6f4f0ec5)
AWSTemplateFormatVersion: '2010-09-09'
Description: A hello world application.
Resources:
HelloWorldFunctionRole:
Type: 'AWS::IAM::Role'
Properties:
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 'sts:AssumeRole'
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
HelloWorldFunction:
Type: 'AWS::Lambda::Function'
Properties:
Code:
S3Bucket: xxxxxxxxxxxxxxxxxx
S3Key: 2a32fe99ed081c4bc95433eeabc76bce
Handler: index.handler
Role: !GetAtt
- HelloWorldFunctionRole
- Arn
Runtime: nodejs6.10
Tags:
- Value: SAM
Key: 'lambda:createdBy'
ServerlessRestApiProdStage:
Type: 'AWS::ApiGateway::Stage'
Properties:
DeploymentId: !Ref ServerlessRestApiDeployment47fc2d5f9d
RestApiId: !Ref ServerlessRestApi
StageName: Prod
ServerlessRestApiDeployment47fc2d5f9d:
Type: 'AWS::ApiGateway::Deployment'
Properties:
RestApiId: !Ref ServerlessRestApi
Description: 'RestApi deployment id: 47fc2d5f9d21ad56f83937abe2779d0e26d7095e'
StageName: Stage
ServerlessRestApi:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Body:
info:
version: '1.0'
title: !Ref 'AWS::StackName'
paths:
/hello:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub >-
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloWorldFunction.Arn}/invocations
responses: {}
swagger: '2.0'
HelloWorldFunctionGetResourcePermissionTest:
Type: 'AWS::Lambda::Permission'
Properties:
Action: 'lambda:invokeFunction'
Principal: apigateway.amazonaws.com
FunctionName: !Ref HelloWorldFunction
SourceArn: !Sub
- >-
arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/hello
- __Stage__: '*'
__ApiId__: !Ref ServerlessRestApi
HelloWorldFunctionGetResourcePermissionProd:
Type: 'AWS::Lambda::Permission'
Properties:
Action: 'lambda:invokeFunction'
Principal: apigateway.amazonaws.com
FunctionName: !Ref HelloWorldFunction
SourceArn: !Sub
- >-
arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/hello
- __Stage__: Prod
__ApiId__: !Ref ServerlessRestApi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment