Skip to content

Commit dac8acc

Browse files
committed
fix: only apply tag updates to commercial tgws
TGWs in GovCloud are recreated when a tag is applied via CFN
1 parent 87d2598 commit dac8acc

File tree

1 file changed

+21
-18
lines changed
  • source/packages/@aws-accelerator/accelerator/bin

1 file changed

+21
-18
lines changed

source/packages/@aws-accelerator/accelerator/bin/app.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class AwsSolutionAspect implements cdk.IAspect {
131131
// 1. Some resources do not support tag updates
132132
// 2. Using Aspects for stacks that use the fs.writeFileSync() operation
133133
// causes the application to quit during stack synthesis
134-
function addAcceleratorTags(node: IConstruct): void {
134+
function addAcceleratorTags(node: IConstruct, partition: string): void {
135135
// Current accelerator prefix is static
136136
const acceleratorPrefix = 'AWSAccelerator';
137137

@@ -145,6 +145,9 @@ function addAcceleratorTags(node: IConstruct): void {
145145

146146
for (const resource of node.node.findAll()) {
147147
if (resource instanceof cdk.CfnResource && !excludeResourceTypes.includes(resource.cfnResourceType)) {
148+
if (resource instanceof cdk.aws_ec2.CfnTransitGateway && partition !== 'aws') {
149+
continue;
150+
}
148151
new cdk.Tag('Accel-P', acceleratorPrefix).visit(resource);
149152
new cdk.Tag('Accelerator', acceleratorPrefix).visit(resource);
150153
}
@@ -349,7 +352,7 @@ async function main() {
349352
...props,
350353
},
351354
);
352-
addAcceleratorTags(prepareStack);
355+
addAcceleratorTags(prepareStack, partition);
353356
cdk.Aspects.of(prepareStack).add(new AwsSolutionsChecks());
354357
}
355358

@@ -377,7 +380,7 @@ async function main() {
377380
...props,
378381
},
379382
);
380-
addAcceleratorTags(finalizeStack);
383+
addAcceleratorTags(finalizeStack, partition);
381384
cdk.Aspects.of(finalizeStack).add(new AwsSolutionsChecks());
382385
}
383386

@@ -405,7 +408,7 @@ async function main() {
405408
...props,
406409
},
407410
);
408-
addAcceleratorTags(accountsStack);
411+
addAcceleratorTags(accountsStack, partition);
409412
cdk.Aspects.of(accountsStack).add(new AwsSolutionsChecks());
410413
}
411414

@@ -436,7 +439,7 @@ async function main() {
436439
...props,
437440
},
438441
);
439-
addAcceleratorTags(organizationStack);
442+
addAcceleratorTags(organizationStack, partition);
440443
cdk.Aspects.of(organizationStack).add(new AwsSolutionsChecks());
441444
}
442445
}
@@ -478,7 +481,7 @@ async function main() {
478481
...props,
479482
},
480483
);
481-
addAcceleratorTags(keyStack);
484+
addAcceleratorTags(keyStack, partition);
482485
cdk.Aspects.of(keyStack).add(new AwsSolutionsChecks());
483486
}
484487

@@ -505,7 +508,7 @@ async function main() {
505508
...props,
506509
},
507510
);
508-
addAcceleratorTags(auditStack);
511+
addAcceleratorTags(auditStack, partition);
509512
cdk.Aspects.of(auditStack).add(new AwsSolutionsChecks());
510513
}
511514
}
@@ -547,7 +550,7 @@ async function main() {
547550
...props,
548551
},
549552
);
550-
addAcceleratorTags(bootstrapStack);
553+
addAcceleratorTags(bootstrapStack, partition);
551554
cdk.Aspects.of(bootstrapStack).add(new AwsSolutionsChecks());
552555
}
553556

@@ -566,7 +569,7 @@ async function main() {
566569
...props,
567570
},
568571
);
569-
addAcceleratorTags(loggingStack);
572+
addAcceleratorTags(loggingStack, partition);
570573
cdk.Aspects.of(loggingStack).add(new AwsSolutionsChecks());
571574
}
572575

@@ -585,7 +588,7 @@ async function main() {
585588
...props,
586589
},
587590
);
588-
addAcceleratorTags(securityStack);
591+
addAcceleratorTags(securityStack, partition);
589592
cdk.Aspects.of(securityStack).add(new AwsSolutionsChecks());
590593
}
591594

@@ -604,7 +607,7 @@ async function main() {
604607
...props,
605608
},
606609
);
607-
addAcceleratorTags(operationsStack);
610+
addAcceleratorTags(operationsStack, partition);
608611
cdk.Aspects.of(operationsStack).add(new AwsSolutionsChecks());
609612
}
610613

@@ -623,7 +626,7 @@ async function main() {
623626
...props,
624627
},
625628
);
626-
addAcceleratorTags(networkPrepStack);
629+
addAcceleratorTags(networkPrepStack, partition);
627630
cdk.Aspects.of(networkPrepStack).add(new AwsSolutionsChecks());
628631
}
629632

@@ -644,7 +647,7 @@ async function main() {
644647
...props,
645648
},
646649
);
647-
addAcceleratorTags(securityResourcesStack);
650+
addAcceleratorTags(securityResourcesStack, partition);
648651
cdk.Aspects.of(securityResourcesStack).add(new AwsSolutionsChecks());
649652
}
650653

@@ -742,7 +745,7 @@ async function main() {
742745
...props,
743746
},
744747
);
745-
addAcceleratorTags(vpcStack);
748+
addAcceleratorTags(vpcStack, partition);
746749
cdk.Aspects.of(vpcStack).add(new AwsSolutionsChecks());
747750

748751
const endpointsStack = new NetworkVpcEndpointsStack(
@@ -756,7 +759,7 @@ async function main() {
756759
...props,
757760
},
758761
);
759-
addAcceleratorTags(endpointsStack);
762+
addAcceleratorTags(endpointsStack, partition);
760763
endpointsStack.addDependency(vpcStack);
761764
cdk.Aspects.of(endpointsStack).add(new AwsSolutionsChecks());
762765

@@ -771,7 +774,7 @@ async function main() {
771774
...props,
772775
},
773776
);
774-
addAcceleratorTags(dnsStack);
777+
addAcceleratorTags(dnsStack, partition);
775778
dnsStack.addDependency(endpointsStack);
776779
cdk.Aspects.of(dnsStack).add(new AwsSolutionsChecks());
777780
}
@@ -793,7 +796,7 @@ async function main() {
793796
...props,
794797
},
795798
);
796-
addAcceleratorTags(networkAssociationsStack);
799+
addAcceleratorTags(networkAssociationsStack, partition);
797800
cdk.Aspects.of(networkAssociationsStack).add(new AwsSolutionsChecks());
798801

799802
const networkGwlbStack = new NetworkAssociationsGwlbStack(
@@ -807,7 +810,7 @@ async function main() {
807810
...props,
808811
},
809812
);
810-
addAcceleratorTags(networkGwlbStack);
813+
addAcceleratorTags(networkGwlbStack, partition);
811814
cdk.Aspects.of(networkGwlbStack).add(new AwsSolutionsChecks());
812815
}
813816
}

0 commit comments

Comments
 (0)