Skip to content

Commit

Permalink
removed deprecated aws.serverless.lambda in favor aws.lambda.Callback…
Browse files Browse the repository at this point in the history
…Function for lambda functions
  • Loading branch information
Phillip Edwards committed Jul 13, 2021
1 parent 8fa3392 commit 764d81e
Showing 1 changed file with 60 additions and 43 deletions.
103 changes: 60 additions & 43 deletions aws-ts-stepfunctions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,80 @@ import * as pulumi from "@pulumi/pulumi";
const region = aws.config.requireRegion();

const lambdaRole = new aws.iam.Role("lambdaRole", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "lambda.amazonaws.com" }),
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "lambda.amazonaws.com" }),
});

const lambdaRolePolicy = new aws.iam.RolePolicy("lambdaRolePolicy", {
role: lambdaRole.id,
policy: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
],
Resource: "arn:aws:logs:*:*:*",
}],
},
role: lambdaRole.id,
policy: {
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: aws.iam.assumeRolePolicyForPrincipal({ Service: `states.${region}.amazonaws.com` }),
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: `states.${region}.amazonaws.com` }),
});

const sfnRolePolicy = new aws.iam.RolePolicy("sfnRolePolicy", {
role: sfnRole.id,
policy: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: [
"lambda:InvokeFunction",
],
Resource: "*",
}],
},
role: sfnRole.id,
policy: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: [
"lambda:InvokeFunction",
],
Resource: "*",
}],
},
});

const helloFunction = new aws.lambda.CallbackFunction(
"helloFunction", {
role: lambdaRole,
callback: (event, context, callback) => {
callback(null, "Hello");
}
});

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

const worldFunction = new aws.serverless.Function(
"worldFunction",
{role: lambdaRole},
(event, context, callback) => {
callback(null, `${event} World!`);
},
);
const worldFunction = new aws.lambda.CallbackFunction(
"worldFunction", {
role: lambdaRole,
callback: (event, context, callback) => {
callback(null, `${event} World!`)
}
}
)

// 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: pulumi.all([helloFunction.lambda.arn, worldFunction.lambda.arn])
.apply(([helloArn, worldArn]) => {
roleArn: sfnRole.arn,
definition: pulumi.all([helloFunction.arn, worldFunction.arn])
.apply(([helloArn, worldArn]) => {
return JSON.stringify({
"Comment": "A Hello World example of the Amazon States Language using two AWS Lambda Functions",
"StartAt": "Hello",
Expand Down

0 comments on commit 764d81e

Please sign in to comment.