Skip to content

Commit

Permalink
Updated stepFunction example to display pulumi.all usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirke committed Aug 1, 2018
1 parent 9d9d6a2 commit 38edb46
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions aws-ts-stepfunctions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const region = aws.config.requireRegion();

Expand Down Expand Up @@ -65,29 +66,43 @@ const sfnRolePolicy = new aws.iam.RolePolicy("sfnRolePolicy", {
})
});

const helloWorldFunction = new aws.serverless.Function(
"helloWorldFunction",
const helloFunction = new aws.serverless.Function(
"helloFunction",
{ role: lambdaRole },
(event, context, callback) => {
callback(null, "Hello world!");
callback(null, "Hello");
}
);

const worldFunction = new aws.serverless.Function(
"worldFunction",
{role: lambdaRole},
(event, context, callback) => {
callback(null, `${event} 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
}
}
});
}),
definition: pulumi.all([helloFunction.lambda.arn, worldFunction.lambda.arn])
.apply(([helloArn, worldArn]) => {
return JSON.stringify({
"Comment": "A Hello World example of the Amazon States Language using two AWS Lambda Functions",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "Task",
"Resource": helloArn,
"Next": "World"
},
"World": {
"Type": "Task",
"Resource": worldArn,
"End": true
}
}
});
})
});

exports.stateMachineArn = stateMachine.id;

0 comments on commit 38edb46

Please sign in to comment.