Closed nam-truong-le closed 2 weeks ago
Hey @nam-truong-le, to confirm is this a Amplify Gen 1 or Gen 2 app? if this is a Amplify Gen 1 application this behavior is currently being tracked on https://github.com/aws-amplify/amplify-cli/issues/11173
This is a Gen 2 app.
Hey @nam-truong-le, on a quick reproduction i was unable to reproduce this behavior in Ampify Gen 2 but did notice the storage resource name had a format as follows for a PR preview branch. Which suggests the buckets shows in the screenshot provided are from Amplify Gen 1 storage.
nope, I create this resource in backend.ts
like this:
/*========== RESOURCES TO PROCESS RESULT FILES ==========*/
const resultFilesStack = backend.createStack("result-files-stack");
const resultFilesBucket = new Bucket(resultFilesStack, "ResultFilesBucket", {
bucketName: `shop-app-result-files-${process.env.AWS_BRANCH}`,
});
It's not my main storage created by defineStorage
.
@nam-truong-le thank you for the clarification. It appears this is a custom S3 bucket. From the CDK documentation for S3 construct it appears the removalPolicy on the bucket is set to orphaned by default. you will need to adjust the policy to destroy on stack deletion.
Adding removalPolicy helps. Thank you!
Closing the issue, do open a new issue if you require additional assistance.
Environment information
Describe the bug
S3 bucket is removed after PR is merged.
Reproduction steps