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

feat(scheduler-targets): SqsSendMessage Target #27774

Merged
merged 24 commits into from
Nov 21, 2023

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Oct 31, 2023

This PR adds SqsSendMessage Target for EventBridge Scheduler.

Closes #27458.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team October 31, 2023 12:42
@github-actions github-actions bot added star-contributor [Pilot] contributed between 25-49 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Oct 31, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 31, 2023 15:33

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Comment on lines 31 to 33
if (props.messageGroupId.length < 1 || props.messageGroupId.length > 128 ) {
throw new Error(`messageGroupId length must be between 1 and 128, got ${props.messageGroupId.length}`);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +40 to +42
} else if (queue.fifo) {
throw new Error('messageGroupId must be specified if the target is a FIFO queue');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +37 to +39
if (!(queue.node.defaultChild as sqs.CfnQueue).contentBasedDeduplication) {
throw new Error('contentBasedDeduplication must be true if the target is a FIFO queue');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you specify an Amazon SQS FIFO queue as a target, the queue must have content-based deduplication enabled.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-sqsparameters

Comment on lines +34 to +36
if (!queue.fifo) {
throw new Error('target must be a FIFO queue if messageGroupId is specified');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CFn occurs a following error when the queue is not FIFO queue if messageGroupId is specified. So added this validation.

ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: Parameters MessageGroupId not valid for the target.

@go-to-k go-to-k marked this pull request as ready for review November 1, 2023 04:31
@kaizencc kaizencc changed the title feat(scheduler-targets): Add SqsSendMessage Target feat(scheduler-targets): SqsSendMessage Target Nov 1, 2023
@go-to-k
Copy link
Contributor Author

go-to-k commented Nov 2, 2023

@kaizencc

For some reason this PR doesn't seem to have a pr/needs-community-review label. How can I label it? Did this happen because I already commented on it?

Copy link
Contributor

@laurelmay laurelmay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links to documentation are super helpful! Thanks! The tests also seem to cover the cases well.

I do have two small thoughts I wanted to ask about though.

throw new Error(`Cannot grant permission to execution role in account ${this.props.role.env.account} to invoke target ${Names.nodeUniqueId(this.queue.node)} in account ${this.queue.env.account}. Both the target and the execution role must be in the same account.`);
}

this.queue.grant(role, 'sqs:SendMessage');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.queue.grant(role, 'sqs:SendMessage');
this.queue.grantSendMessages(role);

Would this be better? It handles the case where the queue uses KMS encryption and grants a few other permissions. But I'm not sure that's necessary for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly, I'll leave it at that.

Comment on lines 38 to 40
if (props.messageGroupId.length < 1 || props.messageGroupId.length > 128 ) {
throw new Error(`messageGroupId length must be between 1 and 128, got ${props.messageGroupId.length}`);
}
Copy link
Contributor

@laurelmay laurelmay Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think tokens ever get this long but maybe:

Suggested change
if (props.messageGroupId.length < 1 || props.messageGroupId.length > 128 ) {
throw new Error(`messageGroupId length must be between 1 and 128, got ${props.messageGroupId.length}`);
}
if (!Token.isUnresolved(props.messageGroupId) && (props.messageGroupId.length < 1 || props.messageGroupId.length > 128)) {
throw new Error(`messageGroupId length must be between 1 and 128, got ${props.messageGroupId.length}`);
}

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Token.html#static-iswbrunresolvedobj

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll do that just in case.

@go-to-k
Copy link
Contributor Author

go-to-k commented Nov 4, 2023

@kylelaker

Thanks for your review!

I changed, so please review again.

Copy link
Contributor

@laurelmay laurelmay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 4, 2023
sumupitchayan
sumupitchayan previously approved these changes Nov 20, 2023
Copy link
Contributor

@sumupitchayan sumupitchayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing!

Copy link
Contributor

mergify bot commented Nov 20, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 20, 2023
Copy link
Contributor

mergify bot commented Nov 20, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed sumupitchayan’s stale review November 20, 2023 22:00

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 20, 2023
sumupitchayan
sumupitchayan previously approved these changes Nov 20, 2023
@mergify mergify bot dismissed sumupitchayan’s stale review November 20, 2023 22:32

Pull request has been modified.

Copy link
Contributor

mergify bot commented Nov 21, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 84951af
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 80c1d26 into aws:main Nov 21, 2023
9 checks passed
Copy link
Contributor

mergify bot commented Nov 21, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@go-to-k go-to-k deleted the feat/scheduler-targets-sqs branch November 21, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-scheduler-targets-alpha): Add SqsSendMessage Target
5 participants