Skip to content

Instantly share code, notes, and snippets.

@lukemerrett
Last active November 25, 2019 12:47
Show Gist options
  • Save lukemerrett/fe776ffd8d2d07a22d6a37c8ddee4820 to your computer and use it in GitHub Desktop.
Save lukemerrett/fe776ffd8d2d07a22d6a37c8ddee4820 to your computer and use it in GitHub Desktop.
AWS Step Functions Workshop - Code Snippets
{
"StartAt": "Create User",
"States": {
"Create User": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "Assign Roles"
},
"Assign Roles": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "Set Permissions"
},
"Set Permissions": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Role",
"StringEquals": "Admin",
"Next": "Grant Admin Permissions"
},
{
"Variable": "$.Role",
"StringEquals": "User",
"Next": "Grant User Permissions"
}
]
},
"Grant Admin Permissions": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "Grant User Permissions"
},
"Grant User Permissions": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}
exports.handler = (event, context, callback) => {
var result = {
UserName: event.UserName,
Role: event.Role,
Message: "User " + event.UserName + ": created..."
};
callback(null, result);
};
exports.handler = (event, context, callback) => {
var result = {
UserName: event.UserName,
Role: event.Role,
Message: "User " + event.UserName + ": given role " + event.Role + "..."
};
callback(null, result);
};
exports.handler = (event, context, callback) => {
var permissions = event.Permissions || [];
permissions.push("Manage Users");
var result = {
UserName: event.UserName,
Role: event.Role,
Permissions: permissions
};
callback(null, result);
};
exports.handler = (event, context, callback) => {
var permissions = event.Permissions || [];
permissions.push("View Users");
var result = {
UserName: event.UserName,
Role: event.Role,
Permissions: permissions
};
callback(null, result);
};
{
"UserName": "Tom Waits",
"Role": "Admin"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment