Skip to content

(aws-events-targets): Using an imported DLQ with an event rule target throws Error: Cannot assign Dead Letter Queue in region ${Token[TOKEN.35]} to the rule XYZEventRule89558AAC in region eu-west-1. Both the queue and the rule must be in the same region. #28165

@JeromeGuyon

Description

@JeromeGuyon

Please add your +1 👍 to let us know you have encountered this

Status: RESOLVED

Overview:

All users of aws-events-targets who created a Rule with the SqsQueue target and passed an imported queue to the deadLetterQueue prop would receive an error similar to:

Complete Error Message:

Error: Cannot assign Dead Letter Queue in region ${Token[TOKEN.35]} to the rule XYZEventRule89558AAC in region eu-west-1. Both the queue and the rule must be in the same region.

Workaround:

Solution:

Upgrade to 2.116.0 or higher.

Related Issues:


Original report

Describe the bug

Previously (2.95.1), I was able to associate a DLQ to a Rule.

In last version (2.111.0), it is nor more possible :

const failedEventQueue = sqs.Queue.fromQueueArn(
      this,
      "FailedEventsQueue",
      ssm.StringParameter.valueForStringParameter(
        this,
        `xyz/failed-events-queue-arn`
      )
    );
    
eventRule.addTarget(
      new targets.SqsQueue(aQueue, {
        messageGroupId: messageGroupId,
        deadLetterQueue: failedEventQueue,
        maxEventAge: cdk.Duration.seconds(60),
        retryAttempts: 0,
      })
    ); 

Generate

Error: Cannot assign Dead Letter Queue in region ${Token[TOKEN.35]} to the rule XYZEventRule89558AAC in region eu-west-1. Both the queue and the rule must be in the same region.

Expected Behavior

It should be possible to support imported SQS Queue as DLQ.

Current Behavior

Error: Cannot assign Dead Letter Queue in region ${Token[TOKEN.35]} to the rule XYZEventRule89558AAC in region eu-west-1. Both the queue and the rule must be in the same region.

Reproduction Steps

const failedEventQueue = sqs.Queue.fromQueueArn(
      this,
      "FailedEventsQueue",
      ssm.StringParameter.valueForStringParameter(
        this,
        `xyz/failed-events-queue-arn`
      )
    );
    
eventRule.addTarget(
      new targets.SqsQueue(aQueue, {
        messageGroupId: messageGroupId,
        deadLetterQueue: failedEventQueue,
        maxEventAge: cdk.Duration.seconds(60),
        retryAttempts: 0,
      })
    ); 

and in stack
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },

Possible Solution

N/A

Additional Information/Context

No response

CDK CLI Version

2.108.0

Framework Version

No response

Node.js Version

v18.13.0

OS

macos

Language

TypeScript

Language Version

TypeScript (5.2.2)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions