aws-events: Unable to create CfnEventBusPolicy - Invalid Relative ID
See original GitHub issueWe are trying to create EventBus and corresponding EventBusPolicy using CDK. The CfnEventBus is created successfully. But when we try to create CfnEventBusPolicy, we get below error.
The relative-id "event-bus/my-custom-eventbus" is invalid for ARN "arn:aws:events:ap-southeast-2:123456789012:event-bus/my-custom-eventbus" (Service: AWSEvents; Status Code: 400; Error Code: ValidationException; Request ID: 0aef0c95-e415-441f-82bb-f3a6fdfc343d; Proxy: null)
Environment
- CDK CLI Version: 1.100.0 (build d996c6d)
- Module Version: 1.100.0
- Node.js Version: v15.13.0
- OS: macOS & Amazon Linux
- Language (Version): Typescript 4.2.4
Other information
Stack
// Custom Event Bus
const bus = new CfnEventBus(this, 'bus', { name: 'my-custom-eventbus });
// Event Bus policy
const busPolicy = new CfnEventBusPolicy(this, 'busPolicy', {
statementId: 'crossAccountAccess',
statement: {
Effect: 'Allow',
Principal: { AWS:["arn:aws:iam::123456789012:root", "arn:aws:iam::123456789013:root"] },
Action: ['events:PutEvents'],
Resource: bus.attrArn,
},
});
busPolicy.node.addDependency(bus);
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Cloudwatch eventbus policy failed to create stack #1785
Have tried to create a eventbuspolicy through the cdk module but the stack is failed with the "Internal Failure" message while creating ......
Read more >class CfnEventBusPolicy (construct) · AWS CDK
To create more secure rules, make sure that the event pattern for each rule contains an account field with a specific account ID...
Read more >The relative-id "event-bus/bus_name" is invalid for ARN ...
The doc is wrong. Correct version: ebMailPolicy: Type: AWS::Events::EventBusPolicy Properties: EventBusName: !
Read more >Find Answers to AWS Questions about Amazon EventBridge
Browse through Amazon EventBridge questions or showcase your expertise by answering unanswered questions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @kheriox-technologies I actually found the issue here.
Cloudformation requires that the
EventBusName
property onCfnEventBusPolicy
be defined when using theStatement
property, as the default value for this isdefault
.Here’s my stack which successfully deploys:
@peterwoodworth Thank you! This solution also is required for CloudFormation, in case anyone is wondering.
In short, if you’re using
Statement
you also need to specifyEventBusName
which is NOT documented by AWS. Here’s an example of a valid CloudFormation implementation: