Skip to content

Commit

Permalink
feat: Remove LogGroups and export table on stack deletion (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-watanabe-snkeos authored Jul 3, 2024
1 parent 7d54a65 commit b3d824d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
5 changes: 3 additions & 2 deletions solutions/deployment/lib/bulkExportStateMachine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Duration } from 'aws-cdk-lib';
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
import { Key } from 'aws-cdk-lib/aws-kms';
import { Function } from 'aws-cdk-lib/aws-lambda';
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
Expand Down Expand Up @@ -109,7 +109,8 @@ export default class BulkExportStateMachine {
destination: new LogGroup(scope, 'bulkExportStateMachineLogs', {
logGroupName: `BulkExportSM-Logs-${stage}`,
encryptionKey: logKMSKey,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
}),
},
});
Expand Down
3 changes: 2 additions & 1 deletion solutions/deployment/lib/cdk-infra-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ export default class FhirWorksStack extends Stack {
const apiGatewayLogGroup = new LogGroup(this, 'apiGatewayLogGroup', {
encryptionKey: kmsResources.logKMSKey,
logGroupName: `/aws/api-gateway/fhir-service-${props!.stage}`,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
});

const apiGatewayRestApi = new RestApi(this, 'apiGatewayRestApi', {
Expand Down
3 changes: 2 additions & 1 deletion solutions/deployment/lib/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export default class ElasticSearchResources {
this.searchLogs = new LogGroup(scope, 'searchLogs', {
logGroupName: `${stackName}-search-logs`,
encryptionKey: elasticSearchKMSKey,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
});

this.searchLogsResourcePolicy = new ResourcePolicy(scope, 'searchLogsResourcePolicy', {
Expand Down
5 changes: 3 additions & 2 deletions solutions/smart-deployment/src/lib/bulkExportStateMachine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Duration } from 'aws-cdk-lib';
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
import { Key } from 'aws-cdk-lib/aws-kms';
import { Function } from 'aws-cdk-lib/aws-lambda';
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
Expand Down Expand Up @@ -110,7 +110,8 @@ export default class BulkExportStateMachine {
destination: new LogGroup(scope, 'bulkExportStateMachineLogs', {
logGroupName: `BulkExportSM-Logs-${stage}`,
encryptionKey: logKMSKey,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
}),
},
});
Expand Down
8 changes: 5 additions & 3 deletions solutions/smart-deployment/src/lib/cdk-infra-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ export default class FhirWorksStack extends Stack {
encryption: TableEncryption.CUSTOMER_MANAGED,
encryptionKey: kmsResources.dynamoDbKMSKey,
billingMode: BillingMode.PAY_PER_REQUEST,
pointInTimeRecovery: true
pointInTimeRecovery: true,
RemovalPolicy: RemovalPolicy.DESTROY
});
exportRequestDynamoDbTable.addGlobalSecondaryIndex({
indexName: exportRequestTableJobStatusIndex,
Expand Down Expand Up @@ -261,7 +262,7 @@ export default class FhirWorksStack extends Stack {
versioned: true,
encryption: BucketEncryption.KMS,
encryptionKey: kmsResources.s3KMSKey,
removalPolicy: RemovalPolicy.RETAIN,
removalPolicy: RemovalPolicy.DESTROY,
blockPublicAccess: {
blockPublicAcls: true,
blockPublicPolicy: true,
Expand Down Expand Up @@ -298,7 +299,8 @@ export default class FhirWorksStack extends Stack {
const apiGatewayLogGroup = new LogGroup(this, 'apiGatewayLogGroup', {
encryptionKey: kmsResources.logKMSKey,
logGroupName: `/aws/api-gateway/fhir-service-${props!.stage}`,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
});

const apiGatewayRestApi = new RestApi(this, 'apiGatewayRestApi', {
Expand Down
5 changes: 3 additions & 2 deletions solutions/smart-deployment/src/lib/elasticsearch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CfnMapping } from 'aws-cdk-lib';
import { CfnMapping, RemovalPolicy } from 'aws-cdk-lib';
import { Domain, EngineVersion } from 'aws-cdk-lib/aws-opensearchservice';
import {
CfnUserPool,
Expand Down Expand Up @@ -249,7 +249,8 @@ export default class ElasticSearchResources {
this.searchLogs = new LogGroup(scope, 'searchLogs', {
logGroupName: `${stackName}-search-logs`,
encryptionKey: elasticSearchKMSKey,
retention: RetentionDays.TEN_YEARS
retention: RetentionDays.TEN_YEARS,
removalPolicy: RemovalPolicy.DESTROY
});

this.searchLogsResourcePolicy = new ResourcePolicy(scope, 'searchLogsResourcePolicy', {
Expand Down

0 comments on commit b3d824d

Please sign in to comment.