Skip to content

Commit

Permalink
Added a callout for Removal Policy (#8055)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Oct 28, 2024
1 parent 63616a6 commit 549b12d
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Create an OpenSearch instance with encryption.
```ts title="amplify/backend.ts"
// highlight-start
import * as opensearch from 'aws-cdk-lib/aws-opensearchservice';
import { RemovalPolicy } from "aws-cdk-lib";
// highlight-end
import { defineBackend } from '@aws-amplify/backend';
import { auth } from './auth/resource';
Expand Down Expand Up @@ -148,13 +149,23 @@ const openSearchDomain = new opensearch.Domain(
{
version: opensearch.EngineVersion.OPENSEARCH_2_11,
nodeToNodeEncryption: true,
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
removalPolicy: RemovalPolicy.DESTROY,
encryptionAtRest: {
enabled: true
}
}
);
// highlight-end
```
<Callout warning>

**Important considerations:**

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.

</Callout>


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

Expand All @@ -181,6 +192,7 @@ Get the `s3BucketArn` and `s3BucketName` values from storage resource as shown b
```ts title="amplify/backend.ts"
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { RemovalPolicy } from "aws-cdk-lib";
// highlight-next-line
import * as iam from "aws-cdk-lib/aws-iam";
import { defineBackend } from "@aws-amplify/backend";
Expand Down Expand Up @@ -220,6 +232,8 @@ const openSearchDomain = new opensearch.Domain(
{
version: opensearch.EngineVersion.OPENSEARCH_2_11,
nodeToNodeEncryption: true,
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
removalPolicy: RemovalPolicy.DESTROY,
encryptionAtRest: {
enabled: true,
},
Expand Down Expand Up @@ -307,6 +321,7 @@ Customize the `template_content` JSON-representation to define the data structur
```ts title="amplify/backend.ts"
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { RemovalPolicy } from "aws-cdk-lib";
import * as iam from "aws-cdk-lib/aws-iam";
import { defineBackend } from "@aws-amplify/backend";
import { auth } from "./auth/resource";
Expand Down Expand Up @@ -342,6 +357,8 @@ const openSearchDomain = new opensearch.Domain(
{
version: opensearch.EngineVersion.OPENSEARCH_2_11,
nodeToNodeEncryption: true,
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
removalPolicy: RemovalPolicy.DESTROY,
encryptionAtRest: {
enabled: true,
},
Expand Down Expand Up @@ -444,6 +461,7 @@ The configuration is a data-prepper feature of OpenSearch. For specific document
```ts title="amplify/backend.ts"
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { RemovalPolicy } from "aws-cdk-lib";
import * as iam from "aws-cdk-lib/aws-iam";
import { defineBackend } from "@aws-amplify/backend";
import { auth } from "./auth/resource";
Expand Down Expand Up @@ -479,6 +497,8 @@ const openSearchDomain = new opensearch.Domain(
{
version: opensearch.EngineVersion.OPENSEARCH_2_11,
nodeToNodeEncryption: true,
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
removalPolicy: RemovalPolicy.DESTROY,
encryptionAtRest: {
enabled: true,
},
Expand Down Expand Up @@ -636,6 +656,7 @@ Now, create the OSIS pipeline resource:
```ts title="amplify/backend.ts"
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
import { RemovalPolicy } from "aws-cdk-lib";
import * as iam from "aws-cdk-lib/aws-iam";
// highlight-start
import * as osis from "aws-cdk-lib/aws-osis";
Expand Down Expand Up @@ -676,6 +697,8 @@ const openSearchDomain = new opensearch.Domain(
{
version: opensearch.EngineVersion.OPENSEARCH_2_11,
nodeToNodeEncryption: true,
// set removalPolicy to DESTROY to make sure the open search domain is deleted on stack deletion.
removalPolicy: RemovalPolicy.DESTROY,
encryptionAtRest: {
enabled: true,
},
Expand Down

0 comments on commit 549b12d

Please sign in to comment.