Search code examples
amazon-web-servicesaws-cloudformationaws-cdk

CDK DELETE_FAILED but there's nothing in the CloudFormation console


I'm really new to CDK and Cloudformation. I've been running into this issue when trying to run cdk bootstrap. So I get this error message:

 ⏳  Bootstrapping environment aws://.../us-east-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to 
customize.
CDKToolkit: creating CloudFormation changeset...
 ❌  Environment aws://.../us-east-1 failed bootstrapping: Error [ValidationError]: Stack:arn:aws:cloudformation:us-eas
t-1:...:stack/CDKToolkit/... is in DELETE_FAILED state and can not be updated.       
    at Request.extractError (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:46430)
    at Request.callListeners (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:90083)
    at Request.emit (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:89531)
    at Request.emit (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:196289)
    at Request.transition (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:189841)
    at AcceptorStateMachine.runTo (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:154713)    
    at Request.<anonymous> (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:190133)
    at Request.<anonymous> (C:\Users\user\AppData\Roaming\nvm\v20.7.0\node_modules\aws-cdk\lib\index.js:349:196364)
  code: 'ValidationError',
  time: 2023-09-23T20:21:19.925Z,
  requestId: 'a10b9870-0611-4522-b0cd-4d47e1dfa4e4',
  statusCode: 400,
  retryable: false,
  retryDelay: 194.11292931446434
}
Stack:arn:aws:cloudformation:us-east-1:...:stack/CDKToolkit/... is in DELETE_FAILED state and can not be updated.

I read on SO that I should go into CloudFormation and delete the stack in question, but when I open it, I see nothing:

enter image description here

But when I type cdk list into my terminal, I see my AppStack (name of my stack)

I run cdk destroy AppStack and confirm destroying it and see

✅  AppStack: destroyed

But if I run cdk list again it shows me the same Stack.

I'll also include my code down below in case it helps people:

app.py

#!/usr/bin/env python3
import os
import aws_cdk as cdk
from appStack.app_stack import AppStack

app = cdk.App()
LyrrStack(app, "AppStack",
    env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')),
)

app.synth()

app_stack.py

from aws_cdk import (
    Stack,
    aws_lambda as _lambda,
    aws_apigateway as _api
)
from constructs import Construct

class AppStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        
        # define the lambda functions
        docker_folder = "../appStack/src"
        file_name = "lambda"            
        # lambda Function from docker image
        lambda_ = _lambda.DockerImageFunction(
            self, file_name,
            code=_lambda.DockerImageCode.from_image_asset(docker_folder, cmd=["lambda.handler"]),
        )
        
        # define the api
        api = _api.LambdaRestApi(
            scope=self,
            id="appstack-api",
            handler=lambda_,
            proxy=True
        )

        // omitted add method codes
        

I also have given my iam profile administrator access, if that makes a difference.

I've also given it all the access it needs (including s3 access which I didn't use (?))

If there's anything missing that you guys would like to see, please let me know.


Solution

  • You show CDK Bootstrapping failed in region us-east-1 so you need to go to cloudformation of that region and fix the stack of bootstrap there.