Skip to content

Instantly share code, notes, and snippets.

@derekalia
Created June 11, 2020 00:42
Show Gist options
  • Save derekalia/e09430eb551bf38e85fd7e53c35a6aa3 to your computer and use it in GitHub Desktop.
Save derekalia/e09430eb551bf38e85fd7e53c35a6aa3 to your computer and use it in GitHub Desktop.
# AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
app-hello
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: functions/hello-world/
Handler: app.lambdaHandler
Runtime: nodejs12.x
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
CiaoFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/ciao/
Handler: app.lambdaHandler
Runtime: nodejs12.x
Proxy:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/proxy/
Handler: app.lambdaHandler
Runtime: nodejs12.x
Environment:
Variables:
statemachine_arn: !Ref Hellostepfunc1
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow" # step function permissions open for now
Action:
- states: "*"
Resource: "*"
Hellostepfunc1:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionUri: statemachines/statemachine.json
DefinitionSubstitutions:
HelloWorldFunction: !GetAtt HelloWorldFunction.Arn
CiaoFunction: !GetAtt CiaoFunction.Arn
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref CiaoFunction
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
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
CiaoFunction:
Value: !GetAtt CiaoFunction.Arn
CiaoFunctionIamRole:
Value: !GetAtt CiaoFunctionRole.Arn
Proxy:
Value: !Ref Hellostepfunc1
# ProxyIamRole:
# Value: !GetAtt Hellostepfunc1.Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment