@@ -116,6 +116,7 @@ Create an OpenSearch instance with encryption.
116116``` ts title="amplify/backend.ts"
117117// highlight-start
118118import * as opensearch from ' aws-cdk-lib/aws-opensearchservice' ;
119+ import { RemovalPolicy } from " aws-cdk-lib" ;
119120// highlight-end
120121import { defineBackend } from ' @aws-amplify/backend' ;
121122import { auth } from ' ./auth/resource' ;
@@ -191,6 +192,7 @@ Get the `s3BucketArn` and `s3BucketName` values from storage resource as shown b
191192``` ts title="amplify/backend.ts"
192193import * as dynamodb from " aws-cdk-lib/aws-dynamodb" ;
193194import * as opensearch from " aws-cdk-lib/aws-opensearchservice" ;
195+ import { RemovalPolicy } from " aws-cdk-lib" ;
194196// highlight-next-line
195197import * as iam from " aws-cdk-lib/aws-iam" ;
196198import { defineBackend } from " @aws-amplify/backend" ;
@@ -319,6 +321,7 @@ Customize the `template_content` JSON-representation to define the data structur
319321``` ts title="amplify/backend.ts"
320322import * as dynamodb from " aws-cdk-lib/aws-dynamodb" ;
321323import * as opensearch from " aws-cdk-lib/aws-opensearchservice" ;
324+ import { RemovalPolicy } from " aws-cdk-lib" ;
322325import * as iam from " aws-cdk-lib/aws-iam" ;
323326import { defineBackend } from " @aws-amplify/backend" ;
324327import { auth } from " ./auth/resource" ;
@@ -354,6 +357,8 @@ const openSearchDomain = new opensearch.Domain(
354357 {
355358 version: opensearch .EngineVersion .OPENSEARCH_2_11 ,
356359 nodeToNodeEncryption: true ,
360+ // set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
361+ removalPolicy: RemovalPolicy .DESTROY ,
357362 encryptionAtRest: {
358363 enabled: true ,
359364 },
@@ -456,6 +461,7 @@ The configuration is a data-prepper feature of OpenSearch. For specific document
456461``` ts title="amplify/backend.ts"
457462import * as dynamodb from " aws-cdk-lib/aws-dynamodb" ;
458463import * as opensearch from " aws-cdk-lib/aws-opensearchservice" ;
464+ import { RemovalPolicy } from " aws-cdk-lib" ;
459465import * as iam from " aws-cdk-lib/aws-iam" ;
460466import { defineBackend } from " @aws-amplify/backend" ;
461467import { auth } from " ./auth/resource" ;
@@ -491,6 +497,8 @@ const openSearchDomain = new opensearch.Domain(
491497 {
492498 version: opensearch .EngineVersion .OPENSEARCH_2_11 ,
493499 nodeToNodeEncryption: true ,
500+ // set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
501+ removalPolicy: RemovalPolicy .DESTROY ,
494502 encryptionAtRest: {
495503 enabled: true ,
496504 },
@@ -648,6 +656,7 @@ Now, create the OSIS pipeline resource:
648656``` ts title="amplify/backend.ts"
649657import * as dynamodb from " aws-cdk-lib/aws-dynamodb" ;
650658import * as opensearch from " aws-cdk-lib/aws-opensearchservice" ;
659+ import { RemovalPolicy } from " aws-cdk-lib" ;
651660import * as iam from " aws-cdk-lib/aws-iam" ;
652661// highlight-start
653662import * as osis from " aws-cdk-lib/aws-osis" ;
@@ -688,6 +697,8 @@ const openSearchDomain = new opensearch.Domain(
688697 {
689698 version: opensearch .EngineVersion .OPENSEARCH_2_11 ,
690699 nodeToNodeEncryption: true ,
700+ // set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
701+ removalPolicy: RemovalPolicy .DESTROY ,
691702 encryptionAtRest: {
692703 enabled: true ,
693704 },
0 commit comments