AWS::SQS::Queue - template fail to update queue RedriveAllowPolicy

0

I'm using a YAML template of CloudFormation, to create two queues, one of them is a DLQ. In the DLQ queue I'm attempting to add RedriveAllowPolicy with either of the below json lines, however it fails with the message mentioned below the json examples. Embedding here also the full template (YAML) for reproduce purposes.

FYI, we're using region us-west-2 (Oregon)

RedriveAllowPolicy JSON examples:

RedriveAllowPolicy: !Sub '{"redrivePermission":"byQueue","sourceQueueArns":"arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:${EnvironmentType}-${MlResultsQueueName}"}'

or

RedriveAllowPolicy: !Join ['',['{"redrivePermission":"byQueue","sourceQueueArns":"', !GetAtt NevaDscvrMlResultsQueue.Arn, '"}']]

CloudFormation stack failure message on queue update

Resource handler returned message: "Invalid value for the parameter RedriveAllowPolicy. Reason: Amazon SQS can't create the redrive allow policy, as it?s in an unsupported format. (Service: Sqs, Status Code: 400, Request ID: edb2977c-9656-5c9b-a7bf-cdde4dd26492, Extended Request ID: null)" (RequestToken: 76823ad0-286b-ff35-ba3e-de300bac4c88, HandlerErrorCode: GeneralServiceException)

Full template:

AWSTemplateFormatVersion: '2010-09-09'

Parameters:

EnvironmentType:

Type: String

Default: dev

Description: 'The name of the release environment.'

MlResultsQueueName:

Description: MlResultsQueue name

Type: String

Default: 'nevadscvr-ml-results'

MlResultsQueueDLQName:

Description: MlResultsQueueDLQ name

Type: String

Default: 'nevadscvr-ml-results-DLQ'

Resources:

NevaDscvrMlResultsQueue:

Type: AWS::SQS::Queue

Properties:

  QueueName: !Sub '${EnvironmentType}-${MlResultsQueueName}'

  VisibilityTimeout: 60

  MessageRetentionPeriod: 345600

  DelaySeconds: 0

  MaximumMessageSize: 262144
  
  ReceiveMessageWaitTimeSeconds: 20

  RedrivePolicy:

    deadLetterTargetArn: !Sub 'arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:${EnvironmentType}-${MlResultsQueueDLQName}'

    maxReceiveCount: 3

NevaDscvrMlResultsQueueDLQ:

Type: AWS::SQS::Queue

Properties:

  QueueName: !Sub '${EnvironmentType}-${MlResultsQueueDLQName}'

  VisibilityTimeout: 30
  
  MessageRetentionPeriod: 345600
  
  DelaySeconds: 0

  MaximumMessageSize: 262144
  
  ReceiveMessageWaitTimeSeconds: 0

  RedriveAllowPolicy: !Sub '{"redrivePermission":"byQueue","sourceQueueArns":"arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:${EnvironmentType}-${MlResultsQueueName}"}'
1 回答
0
已接受的回答

Hello,

I was able to reproduce this issue by using the provided template. To fix this issue, I passed the RedriveAllowPolicy as below which worked;

      RedriveAllowPolicy: !Sub >-
         {"redrivePermission":"byQueue","sourceQueueArns":["arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:${EnvironmentType}-${MlResultsQueueName}"]}

Passing the sourceQueueArns as a list fixed the issue.

AWS
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则