Add an example of AWS StepFunctions in Python
ADD
aws-py-stepfunctions/Pulumi.yaml
+name: stepfunctions-py
+description: Basic example of AWS Step Functions in Python.
+runtime: python

ADD
aws-py-stepfunctions/README.md
+# AWS Step Functions (Python)
+
+A basic example that demonstrates using AWS Step Functions with a Lambda function, written in Python.
+
+```
+# Install dependencies
+$ pip install -r ./requirements.txt
+
+# Create and configure a new stack
+$ pulumi stack init stepfunctions-dev
+$ pulumi config set aws:region us-east-2
+
+# Preview and run the deployment
+$ pulumi update
+
+# Start execution using the AWS CLI (or from the console at https://console.aws.amazon.com/states)
+$ aws stepfunctions start-execution --state-machine-arn $(pulumi stack output state_machine_arn)
+
+# Remove the app and its stack
+$ pulumi destroy && pulumi stack rm -y
+```

ADD
aws-py-stepfunctions/__main__.py
+# Copyright 2016-2018, Pulumi Corporation. All rights reserved.
+
+import iam
+import pulumi
+from pulumi_aws import lambda_, sfn
+
+hello_world_fn = lambda_.Function('helloWorldFunction',
+ role=iam.lambda_role.arn,
+ runtime="python2.7",
+ handler="hello_step.hello",
+ code=pulumi.AssetArchive({
+ '.': pulumi.FileArchive('./step_hello')
+ })
+)
+
+state_defn = state_machine = sfn.StateMachine('stateMachine',
+ role_arn=iam.sfn_role.arn,
+ definition="""{
+ "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
+ "StartAt": "HelloWorld",
+ "States": {
+ "HelloWorld": {
+ "Type": "Task",
+ "Resource": "%s",
+ "End": true
+ }
+ }
+ }""" % hello_world_fn.arn
+)
+
+pulumi.output('state_machine_arn', state_machine.id)

ADD
aws-py-stepfunctions/iam.py
+# Copyright 2016-2018, Pulumi Corporation. All rights reserved.
+
+from pulumi_aws import config, iam
+
+lambda_role = iam.Role('lambdaRole',
+ assume_role_policy="""{
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Action": "sts:AssumeRole",
+ "Principal": {
+ "Service": "lambda.amazonaws.com"
+ },
+ "Effect": "Allow",
+ "Sid": ""
+ }
+ ]
+ }"""
+)
+
+lambda_role_policy = iam.RolePolicy('lambdaRolePolicy',
+ role=lambda_role.id,
+ policy="""{
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Effect": "Allow",
+ "Action": [
+ "logs:CreateLogGroup",
+ "logs:CreateLogStream",
+ "logs:PutLogEvents"
+ ],
+ "Resource": "arn:aws:logs:*:*:*"
+ }]
+ }"""
+)
+
+sfn_role = iam.Role('sfnRole',
+ assume_role_policy="""{
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "states.%s.amazonaws.com"
+ },
+ "Action": "sts:AssumeRole"
+ }
+ ]
+ }""" % config.region
+)
+
+sfn_role_policy = iam.RolePolicy('sfnRolePolicy',
+ role=sfn_role.id,
+ policy="""{
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Action": [
+ "lambda:InvokeFunction"
+ ],
+ "Resource": "*"
+ }
+ ]
+ }"""
+)

ADD
aws-py-stepfunctions/requirements.txt
+pulumi>=0.14.0
+pulumi-aws>=0.14.3

ADD
aws-py-stepfunctions/step_hello/hello.py
+def handler(event, context):
+ return "Hello world!"

Add an example of AWS StepFunctions in Python (#97)