Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/runtime/src/add-tags-to-shared-resources-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface AddTagToResourceOutput {
resourceType: string;
targetAccountIds: string[];
tags: Tag[];
region: string;
}

type AddTagToResourceOutputs = AddTagToResourceOutput[];
Expand Down Expand Up @@ -48,7 +49,7 @@ export const handler = async (input: CreateTagsRequestInput) => {
const credentials = await sts.getCredentialsForAccountAndRole(targetAccountId, assumeRoleName);
if (ALLOWED_RESOURCE_TYPES.includes(resourceType)) {
try {
const tagResources = new TagResources(credentials);
const tagResources = new TagResources(credentials, addTagsToResources.region);
await tagResources.createTags({
Resources: [resourceId],
Tags: tags.map(t => ({ Key: t.key, Value: t.value })),
Expand Down
1 change: 1 addition & 0 deletions src/deployments/cdk/src/apps/phase-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export async function deploy({ acceleratorConfig, accountStacks, accounts, conte
resourceType: 'security-group',
targetAccountIds: [accountId],
tags: securityGroup.tags.renderTags(),
region: securityGroupStack.region,
})),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface AddTagsToResource {
resourceType: 'subnet' | 'security-group' | 'vpc' | 'tgw-attachment';
targetAccountIds: string[];
tags: Tag[];
region: string;
}

export interface AddTagsToResourcesOutputProps extends Omit<JsonOutputProps, 'value' | 'type'> {
Expand Down
2 changes: 2 additions & 0 deletions src/deployments/cdk/src/common/vpc-subnet-sharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class VpcSubnetSharing extends cdk.Construct {
sourceAccountId: o.sourceAccountId,
targetAccountIds: o.targetAccountIds,
tags: o.subnet.tags.renderTags(),
region: cdk.Aws.REGION,
})),
});

Expand All @@ -137,6 +138,7 @@ export class VpcSubnetSharing extends cdk.Construct {
sourceAccountId: o.sourceAccountId,
targetAccountIds: o.targetAccountIds,
tags: vpc.tags.renderTags(),
region: cdk.Aws.REGION,
})),
});
}
Expand Down
1 change: 1 addition & 0 deletions src/deployments/cdk/src/common/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export class Vpc extends cdk.Construct implements constructs.Vpc {
resourceType: 'tgw-attachment',
tags: tgwAttachment!.resource.tags.renderTags(),
targetAccountIds: [ownerAccountId],
region: cdk.Aws.REGION,
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async function createCustomerGateways(props: {
value: `${prefix}_att`,
},
],
region: cdk.Aws.REGION,
});

const associateConfig = attachConfig['tgw-rt-associate'] || [];
Expand Down
24 changes: 24 additions & 0 deletions src/deployments/cdk/test/apps/unsupported-changes.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Web_Central_aza_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-075ca0d93563a4d6e',
Expand All @@ -334,6 +335,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Web_Central_azb_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-0b70e3e849949cc0c',
Expand All @@ -344,6 +346,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'App_Central_aza_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-04e252c39434bbb19',
Expand All @@ -354,6 +357,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'App_Central_azb_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-00bbd856fec06c15b',
Expand All @@ -364,6 +368,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Data_Central_aza_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-0ace127f373a1b274',
Expand All @@ -374,6 +379,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Data_Central_azb_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-05eff632d6af56d17',
Expand All @@ -384,6 +390,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Mgmt_Central_aza_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-03dc090bc09c84439',
Expand All @@ -394,6 +401,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Mgmt_Central_azb_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-02809ab1988c1ec82',
Expand All @@ -404,6 +412,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'GCWide_Central_aza_net' },
],
region: 'ca-central-1',
},
{
resourceId: 'subnet-0f4514137baa07759',
Expand All @@ -414,6 +423,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'GCWide_Central_azb_net' },
],
region: 'ca-central-1',
},
],
}),
Expand All @@ -434,6 +444,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -444,6 +455,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -454,6 +466,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -464,6 +477,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -474,6 +488,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -484,6 +499,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -494,6 +510,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -504,6 +521,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -514,6 +532,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
{
resourceId: 'vpc-0d0b4cd029857165a',
Expand All @@ -524,6 +543,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Central_vpc' },
],
region: 'ca-central-1',
},
],
}),
Expand Down Expand Up @@ -851,6 +871,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Mgmt_sg' },
],
region: 'ca-central-1',
},
{
resourceId: 'sg-0c91bf1bc94e5797f',
Expand All @@ -860,6 +881,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Web_sg' },
],
region: 'ca-central-1',
},
{
resourceId: 'sg-08f5b682020bf1c61',
Expand All @@ -869,6 +891,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'App_sg' },
],
region: 'ca-central-1',
},
{
resourceId: 'sg-041abd65f62750b6e',
Expand All @@ -878,6 +901,7 @@ export function createPhaseInput(): Omit<PhaseInput, 'accountStacks'> {
{ key: 'Accelerator', value: 'PBMM' },
{ key: 'Name', value: 'Data_sg' },
],
region: 'ca-central-1',
},
],
}),
Expand Down
3 changes: 2 additions & 1 deletion src/lib/common/src/aws/resource-tagging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { throttlingBackOff } from './backoff';
export class TagResources {
private readonly client: aws.EC2;

public constructor(credentials?: aws.Credentials) {
public constructor(credentials?: aws.Credentials, region?: string) {
this.client = new aws.EC2({
credentials,
region,
});
}

Expand Down