Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to use FIFO SQS queues as target for CloudWatch events construct #3735

Closed
pratyush05 opened this issue Aug 21, 2019 · 0 comments · Fixed by #3736
Closed

Not able to use FIFO SQS queues as target for CloudWatch events construct #3735

pratyush05 opened this issue Aug 21, 2019 · 0 comments · Fixed by #3736
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@pratyush05
Copy link
Contributor

🐛 Bug Report

What is the problem?

When using FIFO SQS queues as a target in CloudWatch events, the field messageGroupId is required. Even though messageGroupId is mentioned when creating an SQS queue target, this field is not present in the generated CloudFormation template

Reproduction Steps

import cdk = require('@aws-cdk/core');
import events = require('@aws-cdk/aws-events');
import sqs = require('@aws-cdk/aws-sqs');
import targets = require('@aws-cdk/aws-events-targets');

export class SampleCloudWatchStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // The code that defines your stack goes here
    const deadQueue: sqs.DeadLetterQueue = {
      maxReceiveCount: 20,
      queue: new sqs.Queue(this, 'MyDeadQueue', {
        contentBasedDeduplication: false,
        fifo: true,
        queueName: 'MyDeadQueue.fifo'
      })
    };

    const queue: sqs.Queue = new sqs.Queue(this, 'MyQueue', {
      contentBasedDeduplication: true,
      deadLetterQueue: deadQueue,
      fifo: true,
      queueName: 'MyQueue.fifo'
    });

    const target0: targets.SqsQueue = new targets.SqsQueue(queue, {
      message: events.RuleTargetInput.fromObject({
        id: events.EventField.eventId
      }),
      messageGroupId: 'my_queue'
    });

    const rule: events.Rule = new events.Rule(this, 'MyRule', {
      description: 'This is just a sample rule',
      enabled: true,
      ruleName: 'MyRule',
      schedule: events.Schedule.expression('cron(30 9 ? * MON-FRI *)'),
      targets: [target0]
    });
  }
}

Verbose Log

SampleCloudWatchStack: deploying...
SampleCloudWatchStack: creating CloudFormation changeset...
 0/3 | 7:16:16 PM | UPDATE_IN_PROGRESS   | AWS::Events::Rule     | MyRule (MyRuleA44AB831) 
 1/3 | 7:16:46 PM | UPDATE_FAILED        | AWS::Events::Rule     | MyRule (MyRuleA44AB831)
Parameter(s) SqsParameters must be specified for target: Target0. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException)
        new Rule (/Users/gpratyush/Personal/AWS/sample-cloud-watch/node_modules/@aws-cdk/aws-events/lib/rule.ts:101:22)

Environment

  • CDK CLI Version: 1.4
  • Module Version: 1.4
  • OS: OS X
  • Language: TypeScript
@pratyush05 pratyush05 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 21, 2019
pratyush05 pushed a commit to pratyush05/aws-cdk that referenced this issue Aug 21, 2019
…oid error when using fifo sqs queue as targets (fixes aws#3735)
pratyush05 added a commit to pratyush05/aws-cdk that referenced this issue Aug 22, 2019
@mergify mergify bot closed this as completed in #3736 Aug 23, 2019
mergify bot pushed a commit that referenced this issue Aug 23, 2019
* fix(events/events-targets): add sqsparameters for event targets to avoid error when using fifo sqs queue as targets (fixes #3735)

* chore(events): add test cases #3736 (fixes #3735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant