Last active
May 16, 2020 11:24
-
-
Save owfm/3156f82253f5047aa253057f9caca2b2 to your computer and use it in GitHub Desktop.
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
service: step-functions | |
plugins: | |
- serverless-step-functions | |
- serverless-bundle | |
provider: | |
profile: medium | |
name: aws | |
runtime: nodejs12.x | |
region: eu-west-1 | |
environment: | |
promotionsTable: !Ref PromotionsTable | |
iamManagedPolicies: | |
- arn:aws:iam::aws:policy/AWSStepFunctionsFullAccess | |
- arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess | |
functions: | |
emailCongratulations: | |
handler: email.congratulations | |
emailCommiserations: | |
handler: email.commiserations | |
proposePromotion: | |
handler: proposePromotion.call | |
getPendingPromotions: | |
handler: getPendingPromotions.call | |
events: | |
- http: | |
method: get | |
path: promotions | |
cors: true | |
handleDecisions: | |
handler: handleDecisions.call | |
events: | |
- http: | |
method: post | |
path: decisions | |
cors: true | |
storePromotions: | |
handler: storePromotions.call | |
stepFunctions: | |
stateMachines: | |
promotionFlow: | |
name: myCompanyPromotionFlowStateMachine-${opt:stage} | |
definition: | |
Comment: "Handles the manual approval of promotions." | |
StartAt: ProposePromotion | |
States: | |
ProposePromotion: | |
Type: Task | |
Resource: !GetAtt [proposePromotion, Arn] | |
ResultPath: "$.employeeDetails" | |
Next: GetManualReview | |
GetManualReview: | |
Type: Task | |
Resource: arn:aws:states:::lambda:invoke.waitForTaskToken | |
Parameters: | |
FunctionName: ${self:service}-${opt:stage}-storePromotions | |
Payload: | |
employeeDetails.$: "$.employeeDetails" | |
taskToken.$: "$$.Task.Token" | |
ResultPath: "$.decision" | |
Next: PromotionDecision | |
PromotionDecision: | |
Type: Choice | |
Choices: | |
- Variable: "$.decision" | |
StringEquals: approved | |
Next: EmailCongratulations | |
- Variable: "$.decision" | |
StringEquals: rejected | |
Next: EmailCommiserations | |
EmailCongratulations: | |
Type: Task | |
Resource: !GetAtt [emailCongratulations, Arn] | |
End: true | |
EmailCommiserations: | |
Type: Task | |
Resource: !GetAtt [emailCommiserations, Arn] | |
End: true | |
resources: | |
Resources: | |
PromotionsTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
BillingMode: PAY_PER_REQUEST | |
AttributeDefinitions: | |
- AttributeName: taskToken | |
AttributeType: S | |
- AttributeName: decisionStatus | |
AttributeType: S | |
KeySchema: | |
- AttributeName: taskToken | |
KeyType: HASH | |
GlobalSecondaryIndexes: | |
- IndexName: decisionStatus | |
KeySchema: | |
- AttributeName: decisionStatus | |
KeyType: HASH | |
Projection: | |
ProjectionType: ALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment