File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/pages/[platform]/build-a-backend/add-aws-services/deletion-backup-resources Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 22/// <reference types="next/image-types/global" />
33
44// NOTE: This file should not be edited
5- // see https://nextjs.org/docs/basic-features /typescript for more information.
5+ // see https://nextjs.org/docs/pages/building-your-application/configuring /typescript for more information.
Original file line number Diff line number Diff line change @@ -159,3 +159,32 @@ plan.addSelection("BackupPlanSelection", {
159159});
160160// highlight-end
161161```
162+
163+ ## Retaining resources on stack deletion
164+
165+ For example, if you would like to retain a resource on stack deletion, you can use the ` applyRemovalPolicy ` property on the resource to add a retention policy.
166+
167+ ``` ts title="amplify/backend.ts"
168+ import { defineBackend } from " @aws-amplify/backend" ;
169+ import { auth } from " ./auth/resource" ;
170+ import { data } from " ./data/resource" ;
171+ import { RemovalPolicy } from " aws-cdk-lib" ;
172+ import { storage } from " ./storage/resource" ;
173+
174+ const backend = defineBackend ({
175+ auth ,
176+ data ,
177+ storage ,
178+ });
179+
180+ // highlight-start
181+ // Retain the S3 bucket on stack deletion
182+ backend .storage .resources .bucket .applyRemovalPolicy (RemovalPolicy .RETAIN );
183+
184+ // Retain the Cognito user pool on stack deletion
185+ backend .auth .resources .userPool .applyRemovalPolicy (RemovalPolicy .RETAIN );
186+
187+ // Retain the DynamoDB table on stack deletion
188+ backend .data .resources .cfnResources .amplifyDynamoDbTables [" Todo" ].applyRemovalPolicy (RemovalPolicy .RETAIN );
189+ // highlight-end
190+ ```
You can’t perform that action at this time.
0 commit comments