-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for scenarios where DefinitionString or other parameter that need…
… to stay as json but the paramter has intrinsic functions like Fn::GetAtt or Fn::Sub
- Loading branch information
Showing
5 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"Resources": { | ||
"FeedbackRequestStateMachine": { | ||
"Properties": { | ||
"DefinitionString": { | ||
"Fn::Sub": [ | ||
"\n {\n \"Comment\": \"State machine which awaits until defined date to submit a feedback request\",\n \"StartAt\": \"WaitForDueDate\",\n \"States\": {\n \"WaitForDueDate\": {\n \"Type\": \"Wait\",\n \"TimestampPath\": \"$.plannedAt\",\n \"Next\": \"SubmitFeedbackRequestToSQS\"\n },\n \"SubmitFeedbackRequestToSQS\": {\n \"Type\": \"Task\",\n \"Resource\": \"arn:aws:states:::sqs:sendMessage\",\n \"Parameters\": {\n \"MessageBody.$\": \"$\",\n \"QueueUrl\": \"${feedbackQueueUrl}\"\n },\n \"End\": true\n }\n }\n }\n ", | ||
{ | ||
"feedbackQueueUrl": { | ||
"Ref": "FeedbackRequestsQueue" | ||
} | ||
} | ||
] | ||
}, | ||
"RoleArn": { | ||
"Fn::Join": [ | ||
"/", | ||
[ | ||
{ | ||
"Fn::Sub": "arn:aws:iam::${AWS::AccountId}:role" | ||
}, | ||
{ | ||
"Ref": "FeedbackRequestStateMachineRole" | ||
} | ||
] | ||
] | ||
}, | ||
"StateMachineName": { | ||
"Fn::Sub": "${AWS::StackName}-FeedbackRequestStateMachine" | ||
} | ||
}, | ||
"Type": "AWS::StepFunctions::StateMachine" | ||
}, | ||
"FeedbackRequestStateMachineRole": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
{ | ||
"Fn::Sub": "states.${AWS::Region}.amazonaws.com" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"Policies": [ | ||
{ | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sqs:SendMessage" | ||
], | ||
"Effect": "Allow", | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"FeedbackRequestsQueue", | ||
"Arn" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"PolicyName": "submit_request_to_sqs" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::IAM::Role" | ||
}, | ||
"FeedbackRequestsQueue": { | ||
"Properties": { | ||
"MessageRetentionPeriod": 172800, | ||
"VisibilityTimeout": 600 | ||
}, | ||
"Type": "AWS::SQS::Queue" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Resources: | ||
FeedbackRequestStateMachine: | ||
Properties: | ||
DefinitionString: !Sub | ||
- "\n {\n \"Comment\": \"State machine which awaits until\ | ||
\ defined date to submit a feedback request\",\n \"StartAt\"\ | ||
: \"WaitForDueDate\",\n \"States\": {\n \"WaitForDueDate\"\ | ||
: {\n \"Type\": \"Wait\",\n \"TimestampPath\"\ | ||
: \"$.plannedAt\",\n \"Next\": \"SubmitFeedbackRequestToSQS\"\ | ||
\n },\n \"SubmitFeedbackRequestToSQS\": {\n\ | ||
\ \"Type\": \"Task\",\n \"Resource\"\ | ||
: \"arn:aws:states:::sqs:sendMessage\",\n \"Parameters\"\ | ||
: {\n \"MessageBody.$\": \"$\",\n \ | ||
\ \"QueueUrl\": \"${feedbackQueueUrl}\"\n },\n\ | ||
\ \"End\": true\n }\n }\n \ | ||
\ }\n " | ||
- feedbackQueueUrl: !Ref 'FeedbackRequestsQueue' | ||
RoleArn: !Join | ||
- / | ||
- - !Sub 'arn:aws:iam::${AWS::AccountId}:role' | ||
- !Ref 'FeedbackRequestStateMachineRole' | ||
StateMachineName: !Sub '${AWS::StackName}-FeedbackRequestStateMachine' | ||
Type: AWS::StepFunctions::StateMachine | ||
FeedbackRequestStateMachineRole: | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Statement: | ||
- Action: | ||
- sts:AssumeRole | ||
Effect: Allow | ||
Principal: | ||
Service: | ||
- !Sub 'states.${AWS::Region}.amazonaws.com' | ||
Policies: | ||
- PolicyDocument: | ||
Statement: | ||
- Action: | ||
- sqs:SendMessage | ||
Effect: Allow | ||
Resource: !GetAtt 'FeedbackRequestsQueue.Arn' | ||
PolicyName: submit_request_to_sqs | ||
Type: AWS::IAM::Role | ||
FeedbackRequestsQueue: | ||
Properties: | ||
MessageRetentionPeriod: 172800 | ||
VisibilityTimeout: 600 | ||
Type: AWS::SQS::Queue |
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