Minimal AWS Step Functions example
ADD
aws-ts-stepfunctions/.gitignore
+/bin/
+/node_modules/
+/.pulumi/

ADD
aws-ts-stepfunctions/Pulumi.yaml
+name: stepfunctions
+description: Basic example of AWS Step Functions.
+runtime: nodejs

ADD
aws-ts-stepfunctions/README.md
+# AWS Step Functions
+
+A basic example that demonstrates using AWS Step Functions with a Lambda function.
+
+```
+# Create and configure a new stack
+$ pulumi stack init stepfunctions-dev
+$ pulumi config set aws:region us-east-2
+
+# Install dependencies
+$ npm install
+
+# Compile the TypeScript program
+$ npm run build
+
+# 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 stateMachineArn)
+
+# Remove the app
+$ pulumi destroy
+```
\ No newline at end of file

ADD
aws-ts-stepfunctions/index.ts
+import * as aws from "@pulumi/aws";
+
+const region = aws.config.requireRegion();
+
+const lambdaRole = new aws.iam.Role("lambdaRole", {
+ assumeRolePolicy: JSON.stringify({
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Action": "sts:AssumeRole",
+ "Principal": {
+ "Service": "lambda.amazonaws.com",
+ },
+ "Effect": "Allow",
+ "Sid": "",
+ },
+ ],
+ })
+});
+
+const lambdaRolePolicy = new aws.iam.RolePolicy("lambdaRolePolicy", {
+ role: lambdaRole.id,
+ policy: JSON.stringify({
+ "Version": "2012-10-17",
+ "Statement": [{
+ "Effect": "Allow",
+ "Action": [
+ "logs:CreateLogGroup",
+ "logs:CreateLogStream",
+ "logs:PutLogEvents"
+ ],
+ "Resource": "arn:aws:logs:*:*:*"
+ }]
+ })
+});
+
+const sfnRole = new aws.iam.Role("sfnRole", {
+ assumeRolePolicy: JSON.stringify({
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Principal": {
+ "Service": `states.${region}.amazonaws.com`
+ },
+ "Action": "sts:AssumeRole"
+ }
+ ]
+ })
+});
+
+const sfnRolePolicy = new aws.iam.RolePolicy("sfnRolePolicy", {
+ role: sfnRole.id,
+ policy: JSON.stringify({
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Effect": "Allow",
+ "Action": [
+ "lambda:InvokeFunction"
+ ],
+ "Resource": "*"
+ }
+ ]
+ })
+});
+
+const helloWorldFunction = new aws.serverless.Function(
+ "helloWorldFunction",
+ { role: lambdaRole },
+ (event, context, callback) => {
+ callback(null, "Hello world!");
+ }
+);
+
+const stateMachine = new aws.sfn.StateMachine("stateMachine", {
+ roleArn: sfnRole.arn,
+ definition: helloWorldFunction.lambda.arn.apply(lambdaArn => {
+ return JSON.stringify({
+ "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
+ "StartAt": "HelloWorld",
+ "States": {
+ "HelloWorld": {
+ "Type": "Task",
+ "Resource": lambdaArn,
+ "End": true
+ }
+ }
+ });
+ }),
+});
+
+exports.stateMachineArn = stateMachine.id;

ADD
aws-ts-stepfunctions/package.json
+{
+ "name": "stepfunctions",
+ "main": "bin/index.js",
+ "typings": "bin/index.d.ts",
+ "scripts": {
+ "build": "tsc"
+ },
+ "devDependencies": {
+ "typescript": "^2.7.2",
+ "@types/node": "latest"
+ },
+ "dependencies": {
+ "@pulumi/aws": "^0.14.0",
+ "@pulumi/pulumi": "^0.14.0"
+ }
+}

ADD
aws-ts-stepfunctions/tsconfig.json
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es6",
+ "lib": [
+ "es6"
+ ],
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictNullChecks": true
+ },
+ "files": [
+ "index.ts"
+ ]
+}

Minimal AWS Step Functions example (#92)