aws-cdk: aws_appconfig_alpha: delete fail on stack destroy
Describe the bug
I’m using the new L2 constructs, sample code below.
Deploying works just fine.
However, on destroy i get the following error:
11:24:04 AM | DELETE_FAILED | AWS::AppConfig::ConfigurationProfile | rootappconfigOrder...ionProfile9C631413 Cannot delete configuration profile bvdne2p because there are still hosted configuration versions existing under it. (Service: AmazonAppConfig; Status Code: 400; Error Code: BadRequestException; Request ID: d1d449de-9138-4a5e-8461-05f925d07bae; Proxy: null)
Python code:
from pathlib import Path
import aws_cdk.aws_appconfig_alpha as appconfig
from aws_cdk import Duration
from constructs import Construct
from cdk.my_service.configuration.schema import FeatureFlagsConfiguration
DEFAULT_DEPLOYMENT_STRATEGY = 'AppConfig.AllAtOnce'
CUSTOM_ZERO_TIME_STRATEGY = 'zero'
class ConfigurationStore(Construct):
def __init__(self, scope: Construct, id_: str, environment: str, service_name: str, configuration_name: str) -> None:
"""
This construct should be deployed in a different repo and have its own pipeline so updates can be decoupled from
running the service pipeline and without redeploying the service lambdas.
Args:
scope (Construct): The scope in which to define this construct.
id_ (str): The scoped construct ID. Must be unique amongst siblings. If the ID includes a path separator (``/``), then it will be
replaced by double dash ``--``.
environment (str): environment name. Used for loading the corresponding JSON file to upload under
'configuration/json/{environment}_configuration.json'
service_name (str): application name.
configuration_name (str): configuration name
"""
super().__init__(scope, id_)
configuration_str = 'bla bla freeform conf'
self.app_name = f'{id_}{service_name}'
self.config_app = appconfig.Application(
self,
id=self.app_name,
name=self.app_name,
)
self.config_env = appconfig.Environment(
self,
id=f'{id_}env',
application=self.config_app,
name=environment,
)
# zero minutes, zero bake, 100 growth all at once
self.config_dep_strategy = appconfig.DeploymentStrategy(
self,
f'{id_}{CUSTOM_ZERO_TIME_STRATEGY}',
rollout_strategy=appconfig.RolloutStrategy.linear(
growth_factor=100,
deployment_duration=Duration.minutes(0),
final_bake_time=Duration.minutes(0),
),
)
self.config = appconfig.HostedConfiguration(
self,
f'{id_}version',
application=self.config_app,
name=configuration_name,
content=appconfig.ConfigurationContent.from_inline(configuration_str),
type=appconfig.ConfigurationType.FREEFORM,
content_type='application/json',
deployment_strategy=self.config_dep_strategy,
deploy_to=[self.config_env],
)
You can see the changes I made from the CFN variation which worked just fine here: https://github.com/ran-isenberg/aws-lambda-handler-cookbook/pull/710/files
Expected Behavior
Stack deletion success.
Current Behavior
I need to manually delete the resources via console.
root-appconfig-Orders: destroying… [1/1] 11:24:04 AM | DELETE_FAILED | AWS::AppConfig::ConfigurationProfile | rootappconfigOrder…ionProfile9C631413 Cannot delete configuration profile bvdne2p because there are still hosted configuration versions existing under it. (Service: AmazonAppConfig; Status Code: 400; Error Code: BadRequestException; Request ID: d1d449de-9138-4a5e-8461-05f925d07bae; Proxy: null) ❌ root-appconfig-Orders: destroy failed Error: The stack named root-appconfig-Orders is in a failed state.
Reproduction Steps
Use the sample code I provided to create the AppConfig resources
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.92.0 (build bf62e55)
Framework Version
No response
Node.js Version
18.17.1
OS
Mac Ventura 13.5
Language
Python
Language Version
No response
Other information
No response
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 6
- Comments: 20 (7 by maintainers)
Application, DeploymentStrategy, and Environment all have the usual
applyRemovalPolicymethod available. I would like to see this method added to the HostedConfiguration construct. We’re using an escape hatch for now. ThanksYes, we hit the same error when attempting to delete a stack using the new
aws-appconfig-alpha. I am testing out a Custom Resource tied to theApplicationthat will go through all the dependencies (including Hosted Config Versions) and delete them all when the Application is attempted to be deleted, it seems to work OK.@chenjane-dev yep, seems to be working!!!
Hi @ran-isenberg, thank you for bringing this to our attention. We are looking into it on our end.
Thanks @peterwoodworth that makes sense. I’d rather wait for the updated version. As I already have a working CFN, i dont want workarounds. I plan to write a blog post about the improved L2 version, and unless its flawless, i will not recommend it yet.
Thanks, what catches my eye is that in the L2 version, the HostedVersionConfiguration has Update and Retention policies set to Retain. This would make sense that this is what causes it given the error.
https://github.com/aws/aws-cdk/blob/eea12ea799973dff27aa4dedf03221e277ebaa0c/packages/%40aws-cdk/aws-appconfig-alpha/lib/configuration.ts#L459
You could remove this with escape hatches on the default child of the HostedConfiguration L2 construct as a workaround