Skip to content

Commit

Permalink
fix for tgw peering multiple attachments issue (#1237)
Browse files Browse the repository at this point in the history
* tgw construct id update

* add console logs

* initialize static class var

* remove debug console logs
  • Loading branch information
rjjaegeraws authored Sep 18, 2024
1 parent d961589 commit be9b11a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ export interface TransitGatewayAcceptPeeringAttachmentProps {
export class TransitGatewayAcceptPeeringAttachment extends Construct {
private readonly resource: cdk.CustomResource;
private readonly role: iam.IRole;
private static attachmentCount: number = 0;

constructor(scope: Construct, id: string, props: TransitGatewayAcceptPeeringAttachmentProps) {
super(scope, id);

this.role = iam.Role.fromRoleArn(scope, `${resourceType}Role`, props.roleArn);
const roleConstructId =
++TransitGatewayAcceptPeeringAttachment.attachmentCount > 1
? `${resourceType}Role${TransitGatewayAcceptPeeringAttachment.attachmentCount}`
: `${resourceType}Role`;

this.role = iam.Role.fromRoleArn(scope, roleConstructId, props.roleArn);

this.resource = new cdk.CustomResource(this, 'Resource', {
resourceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ export interface TransitGatewayCreatePeeringAttachmentProps {
export class TransitGatewayCreatePeeringAttachment extends Construct {
private readonly resource: cdk.CustomResource;
private readonly role: iam.IRole;
private static attachmentCount: number = 0;

constructor(scope: Construct, id: string, props: TransitGatewayCreatePeeringAttachmentProps) {
super(scope, id);

const { transitGatewayId, targetTransitGatewayId, targetAccountId, targetRegion, tagValue } = props;
this.role = iam.Role.fromRoleArn(scope, `${resourceType}Role`, props.roleArn);

const roleConstructId =
++TransitGatewayCreatePeeringAttachment.attachmentCount > 1
? `${resourceType}Role${TransitGatewayCreatePeeringAttachment.attachmentCount}`
: `${resourceType}Role`;

this.role = iam.Role.fromRoleArn(scope, roleConstructId, props.roleArn);

this.resource = new cdk.CustomResource(this, 'Resource', {
resourceType,
Expand Down

0 comments on commit be9b11a

Please sign in to comment.