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

aws-cdk-lib/aws-events: Support for Cross Account SNS/SQS/Lambda Targets #33328

Open
2 tasks
scabraha opened this issue Feb 6, 2025 · 2 comments
Open
2 tasks
Labels
@aws-cdk/aws-events-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@scabraha
Copy link

scabraha commented Feb 6, 2025

Describe the feature

EventBridge recently released cross account targets which allows customers to send events to SQS queues, SNS topics, Lambda functions, Kinesis Streams, and API Gateway endpoints in another account provided the target account has granted permissions via resource policies. Before this release, SQS/SNS/Lambda required customers to NOT provide a role and the current implementation of CDK supports that constraint. With this release, customers are required to provide a role from the rule's account for cross account resource access.

We're requesting updates to the CDK libraries to allow for roles to be provided for the following constructs:

Use Case

Customers would like to be able to setup Cross Account targets for SNS/SQS/Lambda targets via our L2 constructs.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.178.0

Environment details (OS name and version, etc.)

Mac OSX 15.3

@scabraha scabraha added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 6, 2025
@pahud pahud self-assigned this Feb 7, 2025
@pahud
Copy link
Contributor

pahud commented Feb 7, 2025

Yes it seems we could send the custom role to https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-rolearn ? Making this a p2 FR and we welcome community PRs.

@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Feb 7, 2025
@pahud pahud removed their assignment Feb 7, 2025
@pahud pahud removed the needs-triage This issue or PR still needs to be triaged. label Feb 7, 2025
@rrhodes
Copy link
Contributor

rrhodes commented Feb 9, 2025

Hey, I started looking into this proposed change but I've discovered the following limitation which I think warrants further conversation:

Cannot create a cross-account or cross-region rule for an imported resource (create a stack with the right environment for the imported resource)

If we were to support roles for the target L2 constructs, how do we foresee users managing cross-account resources in CDK? I was expecting to follow a pattern like below:

const fn = lambda.Function.fromFunctionArn(
  this,
  'Function',
  'arn:aws:lambda:us-east-1:123456789012:function:MyFn',
);

const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.ServicePrincipal('events.amazonaws.com'),
});

const rule = new events.Rule(this, 'rule', {
  eventPattern: {
    source: ["aws.ec2"],
  },
});

rule.addTarget(new targets.LambdaFunction(fn, {
  role,
}));

But that's currently not possible under the aforementioned restriction, unless I misunderstand the reported error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants