Skip to content

Commit

Permalink
chore(events): add sqsparameters for event targets (#3735) (#3736)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
pratyush05 authored and mergify[bot] committed Aug 23, 2019
1 parent 0a2ed3d commit d950d8e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-events/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export class Rule extends Resource implements IRule {
ecsParameters: targetProps.ecsParameters,
kinesisParameters: targetProps.kinesisParameters,
runCommandParameters: targetProps.runCommandParameters,
sqsParameters: targetProps.sqsParameters,
input: inputProps && inputProps.input,
inputPath: inputProps && inputProps.inputPath,
inputTransformer: inputProps && inputProps.inputTemplate !== undefined ? {
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-events/lib/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export interface RuleTargetConfig {
*/
readonly runCommandParameters?: CfnRule.RunCommandParametersProperty;

/**
* Parameters used when the FIFO sqs queue is used an event target by the
* rule.
*/
readonly sqsParameters?: CfnRule.SqsParametersProperty;

/**
* What input to send to the event target
*
Expand Down
29 changes: 29 additions & 0 deletions packages/@aws-cdk/aws-events/test/test.rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,35 @@ export = {
test.done();
},

'sqsParameters are generated when they are specified in target props'(test: Test) {
const stack = new cdk.Stack();
const t1: IRuleTarget = {
bind: () => ({
id: '',
arn: 'ARN1',
sqsParameters: { messageGroupId: 'messageGroupId' }
})
};

new Rule(stack, 'EventRule', {
schedule: Schedule.rate(cdk.Duration.minutes(5)),
targets: [ t1 ],
});

expect(stack).to(haveResource('AWS::Events::Rule', {
Targets: [
{
"Arn": "ARN1",
"Id": "Target0",
"SqsParameters": {
"MessageGroupId": "messageGroupId"
}
}
]
}));
test.done();
},

'for cross-account targets': {
'requires that the source stack specify a concrete account'(test: Test) {
const app = new cdk.App();
Expand Down

0 comments on commit d950d8e

Please sign in to comment.