Transit gateway attachment tagging

675 Views Asked by At

There are two accounts. One is for transit gateway and another is for vpc. There is a transit gateway in account A, and in account B there is a vpc and transit gateway attachment that is associated to the transit gateway in account A through Resource Access Manager. Even if the transit gateway attachment in account B has a tag, the transit gateway attachment that is shown in account A doesn't have a tag. How can I apply a tag to the transit gateway attachment in account A by CDK in Typescript? In account A, only id of the transit gateway attachment is known thus the following occurs an error.

cdk.Tags.of(attachment_id).add('Name', 'tgw-test');
-> TypeError: Cannot read property 'Symbol(cdk-aspects)' of undefined
1

There are 1 best solutions below

0
On

I know nothing about typescript, but using the AWS console it is possible to manually add tags to the Transit Gateway Attachment in Account A.

The way I usually do this is to note the TGWA id in Account B, then switch roles to Account A and apply the tag to the matching TGWA id.

Looking at this answer it appears typescript allows one to assume other cross-account roles from within the script.

You could follow the same pattern as the manual workaround, i.e. obtain the TGWA id in account B, assume a role in account A, then apply the tag to the TGWA resource in Account A that matches the stored id from Account B.