Last active
November 25, 2019 12:47
-
-
Save lukemerrett/fe776ffd8d2d07a22d6a37c8ddee4820 to your computer and use it in GitHub Desktop.
AWS Step Functions Workshop - Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = (event, context, callback) => { | |
var result = { | |
UserName: event.UserName, | |
Role: event.Role, | |
Message: "User " + event.UserName + ": created..." | |
}; | |
callback(null, result); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = (event, context, callback) => { | |
var result = { | |
UserName: event.UserName, | |
Role: event.Role, | |
Message: "User " + event.UserName + ": given role " + event.Role + "..." | |
}; | |
callback(null, result); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"UserName": "Tom Waits", | |
"Role": "Admin" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment