Hi AWS, I was setting up a sample application using AWS CDK Python
. When I ran the command cdk deploy
, I got this error:
current credentials could not be used to assume 'arn:aws:iam::1111111111:role/cdk-hnb659fds-deploy-role-1111111111-us-east-1', but are for the right account. Proceeding anyway.
❌ Deployment failed: Error: AwsCdkDemoStack: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
at Deployments.validateBootstrapStackVersion (C:\Users\amang\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:430:12220)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Deployments.buildSingleAsset (C:\Users\amang\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:430:10985)
at async Object.buildAsset (C:\Users\amang\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:430:194552)
at async C:\Users\amang\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:430:178941
AwsCdkDemoStack: SSM parameter /cdk-bootstrap/hnb659fds/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
Following the warning, I ran cdk bootstrap
command and I found it created a CloudFormation Stack with AWS defined name CDKToolkit
which have these set of AWS Resources as highlighted in the screenshot I attached.
I want to know if there is a possibility that I could deploy a user-defined CloudFormation Stack resources having user-defined names and also I need to know what are the prerequisites required for the same.
So, I have deleted the CloudFormation Stack which got created when I ran the
cdk bootstrap
command but the S3 bucket deployed using the template is still present. I tried to delete that manually but the Delete Bucket option is disabled. Why's that?The CloudFormation stack CDKToolkit makes the bucket's DeletePolicy to retain, so that the bucket contents is reserved even after the stack is deleted. This is a best practices for IaC that reserve data source when the stack is deleted. In addition, the s3 bucket can be deleted when there is no object remains. Because the bucket for CDKToolkit is versioning enabled, there will be hidden versioned objects. You can empty the bucket from the S3 console and then can delete the bucket.