Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-s3-deployment): (Errors on resource deletion when retainOnDelete is set to false) #27651

Closed
massi-ang opened this issue Oct 23, 2023 · 3 comments
Labels
@aws-cdk/aws-s3-deployment bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@massi-ang
Copy link

massi-ang commented Oct 23, 2023

Describe the bug

I deployed a stack using BucketDeployment construct with reatinOnDelete=false
I then changed the construct name in the stack and redeployed.
The stack would correctly try to remove the old files, but an error is thrown:

3:21:06 PM | DELETE_FAILED        | AWS::CloudFormation::CustomResource             | ...omResourceE9F2C2EB
Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'rm', 's3://bucket-xyz-zf6fdg25ehh1/build-script', '--recursive']' returned non-zero exit status 1. (RequestId: e52c1279-8e5f-466a-9b49-f01d1098e6e5)

Expected Behavior

Files are correctly removed if present

Current Behavior

An error is thrown (see above)

Reproduction Steps

Deploy something first using:

 new s3deploy.BucketDeployment(this, "Script", {
      sources: [s3deploy.Source.asset(path.join(__dirname, "./build-script"))],
      retainOnDelete: false,
      destinationBucket: buildBucket,
      destinationKeyPrefix: "build-script",
    });

then change the construct resource name and redeploy

 new s3deploy.BucketDeployment(this, "Script-new", {
      sources: [s3deploy.Source.asset(path.join(__dirname, "./build-script"))],
      retainOnDelete: false,
      destinationBucket: buildBucket,
      destinationKeyPrefix: "build-script",
    });

Possible Solution

Automatically add the necessary permission to the custom resource Lambda function

Additional Information/Context

No response

CDK CLI Version

2.99.1 (build b2a895e)

Framework Version

2.99.1

Node.js Version

v20.2.0

OS

MacOS

Language

TypeScript

Language Version

5.1.3

Other information

No response

@massi-ang massi-ang added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2023
@khushail
Copy link
Contributor

Hi @massi-ang , thanks for reaching out.

As stated here for the retainOnDelete flag, I tried to repro the issue with the code provided, but it succeeded as stated. cdk diff produces this result -
Screenshot 2023-10-23 at 4 40 53 PM

could you please share the result of cdk diff which might help in understanding the issue on your side.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 23, 2023
@massi-ang
Copy link
Author

massi-ang commented Oct 24, 2023

Hi Shailja

thank for the prompt answer. I confirm that the BucketDeployment works as expected and the issue is with the Bucket resource.
See #27660

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3-deployment bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants