-
Notifications
You must be signed in to change notification settings - Fork 4k
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-events): Imported Event Bus is not account aware. #13469
Closed
thantos opened this issue
Mar 8, 2021
· 2 comments
· Fixed by #13481, linz/geostore#393, sullis/aws-cdk-java-example#66, thoughtworks/tramchester#254 or linz/elasticsearch-shipper#240
Closed
(aws-events): Imported Event Bus is not account aware. #13469
thantos opened this issue
Mar 8, 2021
· 2 comments
· Fixed by #13481, linz/geostore#393, sullis/aws-cdk-java-example#66, thoughtworks/tramchester#254 or linz/elasticsearch-shipper#240
Labels
@aws-cdk/aws-events
Related to CloudWatch Events
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
Comments
thantos
added
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
labels
Mar 8, 2021
My work around (it doesn't expose the archive method in the base bus object). /**
* An Imported event bus that is aware of the account it is imported from.
*/
export class AccountAwareImportedEventBus extends Resource implements IEventBus {
constructor(scope: Construct, id: string, eventBusArn: string) {
const parsedArn = Arn.parse(eventBusArn);
super(scope, id, {
account: parsedArn.account,
region: parsedArn.region
});
this.eventBusArn = eventBusArn;
this.eventBusName = parsedArn.resourceName || '';
this.eventBusPolicy = '';
}
eventBusName: string;
eventBusArn: string;
eventBusPolicy: string;
eventSourceName?: string | undefined;
} Use const compareAccount = Token.compareStrings(Stack.of(this).account, eventBus.env.account); // eventBus could be an imported or same account bus.
const sameAccount = compareAccount === TokenComparison.SAME || compareAccount === TokenComparison.BOTH_UNRESOLVED;
// For cross account, we write from the target account bus to a bus provided by this account.
if (!sameAccount) {
if (!props.eventBus) {
throw new Error('For a cross account listener, an event bus must be provided.');
}
// Create rule policy to write across account
const coreRule = new Rule().target(/*...cross account bus...*/) // a rule which forwards events from cross account to current account's props.eventbus
} |
thantos
added a commit
to thantos/aws-cdk
that referenced
this issue
Mar 9, 2021
Parses the event bus arn to give the account and region to the underlying Resource. fixes aws#13469
thantos
added a commit
to thantos/aws-cdk
that referenced
this issue
Mar 9, 2021
Parses the event bus arn to give the account and region to the underlying Resource. fixes aws#13469
|
This was referenced Mar 12, 2021
Merged
Merged
Closed
This was referenced Mar 14, 2021
Merged
Merged
Merged
Closed
Closed
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
@aws-cdk/aws-events
Related to CloudWatch Events
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
When importing an event bus via the
fromEventBusArn
method, theresource.env
is the importing stack's account and not the account of the ARN being imported.This is important because the integration pattern for a construct consuming a bus could be different for a same account vs cross account bus.
For example, a same account bus cannot be the target of another rule, but a cross account bus MUST be the target of a rule before consuming events in the other account.
Reproduction Steps
What did you expect to happen?
What actually happened?
Environment
Other
I suspect that event bus should take the account and region from the arn.
aws-cdk/packages/@aws-cdk/aws-events/lib/event-bus.ts
Lines 285 to 291 in 465cd9c
Or it should accept account and region like s3 does.
aws-cdk/packages/@aws-cdk/aws-s3/lib/bucket.ts
Lines 345 to 357 in a67d85f
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: