Skip to content

Commit 549b12d

Browse files
AnilMaktalasunderscjosefaidt
authored
Added a callout for Removal Policy (#8055)
* Added a callout for Removal Policy * Update src/pages/[platform]/build-a-backend/data/custom-business-logic/search-and-aggregate-queries/index.mdx Co-authored-by: Christopher Sundersingh <[email protected]> * updated removal policy * Update src/pages/[platform]/build-a-backend/data/custom-business-logic/search-and-aggregate-queries/index.mdx Co-authored-by: josef <[email protected]> * added Removal enum import --------- Co-authored-by: Christopher Sundersingh <[email protected]> Co-authored-by: josef <[email protected]>
1 parent 63616a6 commit 549b12d

File tree

1 file changed

+23
-0
lines changed
  • src/pages/[platform]/build-a-backend/data/custom-business-logic/search-and-aggregate-queries

1 file changed

+23
-0
lines changed

src/pages/[platform]/build-a-backend/data/custom-business-logic/search-and-aggregate-queries/index.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Create an OpenSearch instance with encryption.
116116
```ts title="amplify/backend.ts"
117117
// highlight-start
118118
import * as opensearch from 'aws-cdk-lib/aws-opensearchservice';
119+
import { RemovalPolicy } from "aws-cdk-lib";
119120
// highlight-end
120121
import { defineBackend } from '@aws-amplify/backend';
121122
import { auth } from './auth/resource';
@@ -148,13 +149,23 @@ const openSearchDomain = new opensearch.Domain(
148149
{
149150
version: opensearch.EngineVersion.OPENSEARCH_2_11,
150151
nodeToNodeEncryption: true,
152+
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
153+
removalPolicy: RemovalPolicy.DESTROY,
151154
encryptionAtRest: {
152155
enabled: true
153156
}
154157
}
155158
);
156159
// highlight-end
157160
```
161+
<Callout warning>
162+
163+
**Important considerations:**
164+
165+
We recommend configuring the `removalPolicy` to destroy resources for sandbox environments. By default, OpenSearch instances are not deleted when you run `npx ampx sandbox delete`, as the default removal policy for stateful resources is set to retain the resource.
166+
167+
</Callout>
168+
158169

159170
## Step 3: Setting Up Zero ETL from DynamoDB to OpenSearch
160171

@@ -181,6 +192,7 @@ Get the `s3BucketArn` and `s3BucketName` values from storage resource as shown b
181192
```ts title="amplify/backend.ts"
182193
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
183194
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
195+
import { RemovalPolicy } from "aws-cdk-lib";
184196
// highlight-next-line
185197
import * as iam from "aws-cdk-lib/aws-iam";
186198
import { defineBackend } from "@aws-amplify/backend";
@@ -220,6 +232,8 @@ const openSearchDomain = new opensearch.Domain(
220232
{
221233
version: opensearch.EngineVersion.OPENSEARCH_2_11,
222234
nodeToNodeEncryption: true,
235+
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
236+
removalPolicy: RemovalPolicy.DESTROY,
223237
encryptionAtRest: {
224238
enabled: true,
225239
},
@@ -307,6 +321,7 @@ Customize the `template_content` JSON-representation to define the data structur
307321
```ts title="amplify/backend.ts"
308322
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
309323
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
324+
import { RemovalPolicy } from "aws-cdk-lib";
310325
import * as iam from "aws-cdk-lib/aws-iam";
311326
import { defineBackend } from "@aws-amplify/backend";
312327
import { auth } from "./auth/resource";
@@ -342,6 +357,8 @@ const openSearchDomain = new opensearch.Domain(
342357
{
343358
version: opensearch.EngineVersion.OPENSEARCH_2_11,
344359
nodeToNodeEncryption: true,
360+
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
361+
removalPolicy: RemovalPolicy.DESTROY,
345362
encryptionAtRest: {
346363
enabled: true,
347364
},
@@ -444,6 +461,7 @@ The configuration is a data-prepper feature of OpenSearch. For specific document
444461
```ts title="amplify/backend.ts"
445462
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
446463
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
464+
import { RemovalPolicy } from "aws-cdk-lib";
447465
import * as iam from "aws-cdk-lib/aws-iam";
448466
import { defineBackend } from "@aws-amplify/backend";
449467
import { auth } from "./auth/resource";
@@ -479,6 +497,8 @@ const openSearchDomain = new opensearch.Domain(
479497
{
480498
version: opensearch.EngineVersion.OPENSEARCH_2_11,
481499
nodeToNodeEncryption: true,
500+
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
501+
removalPolicy: RemovalPolicy.DESTROY,
482502
encryptionAtRest: {
483503
enabled: true,
484504
},
@@ -636,6 +656,7 @@ Now, create the OSIS pipeline resource:
636656
```ts title="amplify/backend.ts"
637657
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
638658
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
659+
import { RemovalPolicy } from "aws-cdk-lib";
639660
import * as iam from "aws-cdk-lib/aws-iam";
640661
// highlight-start
641662
import * as osis from "aws-cdk-lib/aws-osis";
@@ -676,6 +697,8 @@ const openSearchDomain = new opensearch.Domain(
676697
{
677698
version: opensearch.EngineVersion.OPENSEARCH_2_11,
678699
nodeToNodeEncryption: true,
700+
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
701+
removalPolicy: RemovalPolicy.DESTROY,
679702
encryptionAtRest: {
680703
enabled: true,
681704
},

0 commit comments

Comments
 (0)