Skip to content

Commit 8bc0506

Browse files
authored
fix(post-migration) remove asea config aggregator (#1261)
1 parent c7470d3 commit 8bc0506

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* eslint-disable */
2+
/**
3+
* Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
6+
* with the License. A copy of the License is located at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
11+
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
12+
* and limitations under the License.
13+
*/
14+
import { ConfigServiceClient, DeleteConfigurationAggregatorCommand } from '@aws-sdk/client-config-service';
15+
import { Credentials } from '@aws-sdk/client-sts';
16+
import { throttlingBackOff } from './backoff';
17+
18+
export class ConfigService {
19+
private readonly serviceClient: ConfigServiceClient;
20+
21+
constructor(credentials?: Credentials, region?: string) {
22+
if (credentials) {
23+
this.serviceClient = new ConfigServiceClient({ credentials: {
24+
accessKeyId: credentials.AccessKeyId!,
25+
secretAccessKey: credentials.SecretAccessKey!,
26+
sessionToken: credentials.SessionToken! },
27+
region });
28+
} else {
29+
this.serviceClient = new ConfigServiceClient({});
30+
}
31+
}
32+
33+
async deleteConfigAggregator(acceleratorPrefix: string): Promise<void> {
34+
try {
35+
await throttlingBackOff(() => this.serviceClient.send(new DeleteConfigurationAggregatorCommand({ ConfigurationAggregatorName: `${acceleratorPrefix}Config-Org-Aggregator` })));
36+
} catch (error) {
37+
console.log('No Org Aggregator found');
38+
}
39+
}
40+
}

reference-artifacts/Custom-Scripts/lza-upgrade/src/post-migration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import path from 'path';
1515
import { AcceleratorConfig, ImportCertificateConfig, ImportCertificateConfigType } from './asea-config';
1616
import { loadAseaConfig } from './asea-config/load';
1717
import { DynamoDB } from './common/aws/dynamodb';
18+
import { ConfigService } from './common/aws/config-service';
1819
import { S3 } from './common/aws/s3';
1920
import { Account, getAccountId } from './common/outputs/accounts';
2021
import { StackOutput, findValuesFromOutputs, loadOutputs } from './common/outputs/load-outputs';
@@ -30,6 +31,7 @@ export class PostMigration {
3031
private readonly aseaPrefix: string;
3132
private readonly s3: S3;
3233
private readonly dynamoDb: DynamoDB;
34+
private readonly configService: ConfigService;
3335
private outputs: StackOutput[] = [];
3436
private accounts: Account[] = [];
3537
private centralBucket: string | undefined;
@@ -48,6 +50,7 @@ export class PostMigration {
4850
this.mappingRepositoryName = config.mappingRepositoryName;
4951
this.s3 = new S3(undefined, this.region);
5052
this.dynamoDb = new DynamoDB(undefined, this.region);
53+
this.configService = new ConfigService(undefined, this.region);
5154
this.args = args;
5255
this.outputsDirectory = './outputs';
5356
this.writeConfig = {
@@ -375,6 +378,7 @@ export class PostMigration {
375378
phase: '3',
376379
resourceType: 'AWS::Config::RemediationConfiguration',
377380
});
381+
await this.configService.deleteConfigAggregator(this.aseaPrefix);
378382
}
379383

380384
private async removeLogging(mappingConfig: { mappings: ASEAResourceMapping; mappingBucket: string; s3Client: S3 }) {

0 commit comments

Comments
 (0)