Skip to content

Instantly share code, notes, and snippets.

@ronyis
Last active June 1, 2018 11:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyis/ac51d6485156b2391771b00e31a886b9 to your computer and use it in GitHub Desktop.
Save ronyis/ac51d6485156b2391771b00e31a886b9 to your computer and use it in GitHub Desktop.
Example of a Serverless system with Step Functions invoked by SNS
service: state-machine-invoking-example
provider:
name: aws
region: eu-west-1
runtime: python3.6
# Specific Role for the Lambda and machine is better
iamRoleStatements:
- Effect: "Allow"
Action:
- "states:StartExecution"
Resource:
- "*"
functions:
first_step:
handler: simple_lambda.run
second_step:
handler: another_lambda.run
timeout: 5
machine_invoker:
handler: state_machine_invoker.run
events:
- sns: 'arn:aws:sns:eu-west-1:xxxxxxxx:sns_name'
custom:
env-resources:
- MyStateMachine
stepFunctions:
stateMachines:
exampleMachine:
name: myStateMachine
definition:
StartAt: firstStep
States:
firstStep:
Type: Task
Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-first_step
TimeoutSeconds: 6
Next: secondStep
secondStep:
Type: Task
Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-second_step
TimeoutSeconds: 5
End: true
plugins:
- serverless-step-functions
- serverless-pseudo-parameters
- serverless-resources-env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment