CDK Bootstrap failed due to S3 bucket existed

Error: Lower version of bootstrap stack version

shared-custom-resources-1: deploying...

 ❌  shared-custom-resources-1 failed: Error: shared-custom-resources-1: This CDK deployment requires bootstrap stack version '6', found '4'. Please run 'cdk bootstrap'.

Source from Stackoverflow: https://stackoverflow.com/questions/62972959/aws-cdk-error-bucket-policy-already-exists-on-bucket

Due to Cloudformation doesn’t allow custom bucket handle by user.

Solution

Step 1

Create a new S3 bucket on that account and move all files from CDK Bootstrap bucket.

aws s3 mv s3://cdk-backup-toolkit s3://cdk-hnasdffds-assets-3123497-ap-northeast-1 --recursive  --profile AdminAccount

Step 2

Move all back after cdk bootstrap is done

aws s3 mv s3://cdk-hnasdffds-assets-3123497-ap-northeast-1 s3://cdk-backup-toolkit  --recursive  --profile AdminAccount

Photo by CHUTTERSNAP on Unsplash