Skip to content

Commit

Permalink
fix(stepfunctions-tasks): SNS FIFO tasks does not support messageGrou…
Browse files Browse the repository at this point in the history
…pId and messageDeduplicationId (#27369)

`SnsPublish` is failing the execution with FIFO topics due to some missing parameters.

This fixes the problem by adding:
* [`messageGroupId`](https://docs.aws.amazon.com/sns/latest/api/API_Publish.html#:~:text=Required%3A%20No-,MessageGroupId,-This%20parameter%20applies) - Required for FIFO topics
* [`messageDeduplicationId`](https://docs.aws.amazon.com/sns/latest/api/API_Publish.html#:~:text=Required%3A%20No-,MessageDeduplicationId,-This%20parameter%20applies) - Required for FIFO topics with [`contentBasedDeduplication`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-topic.html#cfn-sns-topic-contentbaseddeduplication) disabled

Closes #27341.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
lpizzinidev committed Oct 11, 2023
1 parent b1ce47b commit 9cb9fb8
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 59 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,87 @@
"showmethemessagesawsstepfunctionstaskssnspublishintegcooltopic8388C976F1D63091": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": {
"Fn::GetAtt": [
"showmethemessages8D16BBDB",
"Arn"
]
},
"Protocol": "sqs",
"TopicArn": {
"Ref": "cooltopic4736778A"
}
},
"DependsOn": [
"showmethemessagesPolicyB08B04B0"
]
},
"fifotopicA6114788": {
"Type": "AWS::SNS::Topic",
"Properties": {
"FifoTopic": true,
"TopicName": "awsstepfunctionstaskssnspublishinteg-fifotopic-6FE667F7.fifo"
}
},
"fifoqueue3F2573B3": {
"Type": "AWS::SQS::Queue",
"Properties": {
"FifoQueue": true
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"fifoqueuePolicyCA528C39": {
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "sqs:SendMessage",
"Condition": {
"ArnEquals": {
"aws:SourceArn": {
"Ref": "fifotopicA6114788"
}
}
},
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Resource": {
"Fn::GetAtt": [
"fifoqueue3F2573B3",
"Arn"
]
}
}
],
"Version": "2012-10-17"
},
"Queues": [
{
"Ref": "fifoqueue3F2573B3"
}
]
}
},
"fifoqueueawsstepfunctionstaskssnspublishintegfifotopic6FE667F78F3219A7": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": {
"Fn::GetAtt": [
"showmethemessages8D16BBDB",
"fifoqueue3F2573B3",
"Arn"
]
},
"Protocol": "sqs",
"TopicArn": {
"Ref": "fifotopicA6114788"
}
},
"DependsOn": [
"showmethemessagesPolicyB08B04B0"
"fifoqueuePolicyCA528C39"
]
},
"StateMachineRoleB840431D": {
Expand Down Expand Up @@ -86,9 +154,14 @@
{
"Action": "sns:Publish",
"Effect": "Allow",
"Resource": {
"Ref": "cooltopic4736778A"
}
"Resource": [
{
"Ref": "cooltopic4736778A"
},
{
"Ref": "fifotopicA6114788"
}
]
}
],
"Version": "2012-10-17"
Expand All @@ -104,27 +177,35 @@
"StateMachine2E01A3A5": {
"Type": "AWS::StepFunctions::StateMachine",
"Properties": {
"RoleArn": {
"Fn::GetAtt": [
"StateMachineRoleB840431D",
"Arn"
]
},
"DefinitionString": {
"Fn::Join": [
"",
[
"{\"StartAt\":\"publish to SNS\",\"States\":{\"publish to SNS\":{\"Next\":\"Final step\",\"Type\":\"Task\",\"Resource\":\"arn:",
"{\"StartAt\":\"publish to SNS\",\"States\":{\"publish to SNS\":{\"Next\":\"publish to FIFO SNS\",\"Type\":\"Task\",\"Resource\":\"arn:",
{
"Ref": "AWS::Partition"
},
":states:::sns:publish\",\"Parameters\":{\"TopicArn\":\"",
{
"Ref": "cooltopic4736778A"
},
"\",\"Message\":\"sending message over\"}},\"Final step\":{\"Type\":\"Pass\",\"End\":true}},\"TimeoutSeconds\":30}"
"\",\"Message\":\"sending message over\"}},\"publish to FIFO SNS\":{\"Next\":\"Final step\",\"Type\":\"Task\",\"Resource\":\"arn:",
{
"Ref": "AWS::Partition"
},
":states:::sns:publish\",\"Parameters\":{\"TopicArn\":\"",
{
"Ref": "fifotopicA6114788"
},
"\",\"Message\":\"sending message over\",\"MessageDeduplicationId\":\"message-deduplication-id\",\"MessageGroupId\":\"message-group-id\"}},\"Final step\":{\"Type\":\"Pass\",\"End\":true}},\"TimeoutSeconds\":30}"
]
]
},
"RoleArn": {
"Fn::GetAtt": [
"StateMachineRoleB840431D",
"Arn"
]
}
},
"DependsOn": [
Expand All @@ -145,6 +226,11 @@
"Value": {
"Ref": "showmethemessages8D16BBDB"
}
},
"fifoQueueUrl": {
"Value": {
"Ref": "fifoqueue3F2573B3"
}
}
},
"Parameters": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9cb9fb8

Please sign in to comment.