Skip to content

feat(event-targets): add role property to sqs event target#33701

Open
atnartur wants to merge 13 commits intoaws:mainfrom
atnartur:feature/add-role-to-eventbridge-sqs-target
Open

feat(event-targets): add role property to sqs event target#33701
atnartur wants to merge 13 commits intoaws:mainfrom
atnartur:feature/add-role-to-eventbridge-sqs-target

Conversation

@atnartur
Copy link
Copy Markdown

@atnartur atnartur commented Mar 6, 2025

Reason for this change

Add role property to SQS Event Target in EventBridge

Description of changes

Add role attribute to SQS Event Target in EventBridge which is available in AWS CloudFormation template but was not available in AWS CDK.

Describe any new or updated permissions being added

No changes in permissions are made.

Description of how you validated changes

Deploy an EventBridge Rule with SQS Event Target and custom role.

Checklist


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

@github-actions github-actions bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Mar 6, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 6, 2025 16:33
Copy link
Copy Markdown
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.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review March 6, 2025 21:34

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

@atnartur atnartur marked this pull request as ready for review March 6, 2025 21:49
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.24%. Comparing base (77b6fa9) to head (06acad4).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33701   +/-   ##
=======================================
  Coverage   82.24%   82.24%           
=======================================
  Files         119      119           
  Lines        6875     6875           
  Branches     1161     1161           
=======================================
  Hits         5654     5654           
  Misses       1118     1118           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.24% <ø> (ø)
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing

To prevent automatic closure:

  • Resume work on the PR
  • OR request an exemption by adding a comment containing 'Exemption Request' with justification e.x "Exemption Request: "
  • OR request clarification by adding a comment containing 'Clarification Request' with a question e.x "Clarification Request: "

This PR will automatically close in 14 days if no action is taken.

@atnartur
Copy link
Copy Markdown
Author

atnartur commented Apr 3, 2025

Related to #33827 #33976

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing

To prevent automatic closure:

  • Resume work on the PR
  • OR request an exemption by adding a comment containing 'Exemption Request' with justification e.x "Exemption Request: "
  • OR request clarification by adding a comment containing 'Clarification Request' with a question e.x "Clarification Request: "

This PR will automatically close in 14 days if no action is taken.

@atnartur
Copy link
Copy Markdown
Author

Clarification Request: Hi! I'm receiving the message that my PR will be closed soon due to the test failure, but tests are also failing on the main branch.

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Apr 25, 2025
@shikha372 shikha372 self-assigned this May 6, 2025
*
* @default - no role defined
*/
readonly role?: iam.Role;
Copy link
Copy Markdown
Contributor

@shikha372 shikha372 May 8, 2025

Choose a reason for hiding this comment

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

question for my understanding :
why is this only in SQS queue props, since this is something that is related to EventTargets, isn't it relevant to each type of target that is supported, so should be part of TargetBaseProps.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-rolearn

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@shikha372, I moved the prop to TargetBaseProps and aligned other related interfaces. Tests ran successfully on my machine. Please take a look at this PR once again.

Copy link
Copy Markdown
Contributor

@shikha372 shikha372 May 15, 2025

Choose a reason for hiding this comment

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

Thank you @atnartur , error you're facing is due to readme related changes

[jsii-rosetta] [INFO] Adding translations to /root/.s3buildcache/rosetta-cache.tabl.json
aws-cdk-lib.aws_events_targets-README-L639.ts:23:12 - error TS2304: Cannot find name 'RuleTargetInput'.

23   message: RuleTargetInput.fromObject({
              ~~~~~~~~~~~~~~~
[jsii-rosetta] [WARN] 1 diagnostics from assemblies with 'strict' mode on (and 64 more non-strict diagnostics)

real	10m11.458s
user	127m5.050s
sys	9m1.260s

you can try updating readme with events.RuleTargetInput.fromObject

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@shikha372 Someone added the same example already in main branch, so I removed my part. I think this check should pass. Please take a look on the PR once again

@atnartur atnartur marked this pull request as draft May 14, 2025 13:44
@atnartur-emis atnartur-emis force-pushed the feature/add-role-to-eventbridge-sqs-target branch from 75d4b53 to 9dcc5f4 Compare May 14, 2025 17:55
@atnartur atnartur marked this pull request as ready for review May 14, 2025 18:02
// When scoping resource-level access for job submission, you must provide both job queue and job definition resource types.
// https://docs.aws.amazon.com/batch/latest/userguide/ExamplePolicies_BATCH.html#iam-example-restrict-job-def
const role = singletonEventRole(this.jobDefinitionScope);
const role = this.props.eventRole ?? singletonEventRole(this.jobDefinitionScope);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

currious why we need this change ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The role created here extends with an additional policy statement in the lines below, so I repeat the behaviour from bindBaseTargetConfig here to save the same process of role initiation.

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 23, 2025
@atnartur atnartur requested a review from shikha372 June 24, 2025 07:34
@atnartur
Copy link
Copy Markdown
Author

atnartur commented Jul 2, 2025

Hi @shikha372! Could you please take a look at this PR?

@pahud
Copy link
Copy Markdown
Contributor

pahud commented Nov 11, 2025

Hi,

This PR has conflicts that need to be resolved before it can be reviewed.

@atnartur
Copy link
Copy Markdown
Author

Hi @pahud,
I fixed the merge conflict. Could you please have a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants