本文介绍了cdk 销毁时未删除 CloudWatch 日志组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个 CDK 代码:
I have this CDK code:
const logGroup = new LogGroup(this, 'MyAppLogGroup', {
logGroupName: 'myapp',
retention: RetentionDays.ONE_DAY
});
当我运行 cdk deploy
时,在 CloudWatch 中创建了日志组,但是当我运行 cdk destroy
时,它没有被删除.有什么方法可以启用此功能吗?
When I run cdk deploy
, log group is created in CloudWatch, but when I run cdk destroy
, it's not deleted. Is there some way to enable this?
推荐答案
请参阅 https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html#removalpolicy.您需要将LogGroup
的removalPolicy
设置为DESTROY
,因为默认为RETAIN
See https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html#removalpolicy. You need to set the removalPolicy
of the LogGroup
to DESTROY
as the default one is RETAIN
这篇关于cdk 销毁时未删除 CloudWatch 日志组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!