简体   繁体   English

当目标位于依赖于目标组堆栈的单独堆栈中时,如何删除 CDK 中的目标组目标

[英]How can I delete the target group targets in CDK while the targets is in a separate stack that depends on the target group stack

We have an issue remove ECS service target from target group and then remove the target group which is no longer needed via CDK, because the CDK will complain about that it is still in used by the ECS in ecs_service stack.我们有一个问题,从目标组中删除 ECS 服务目标,然后通过 CDK 删除不再需要的目标组,因为 CDK 会抱怨它仍在被 ecs_service 堆栈中的 ECS 使用。 We have our target group in one stack ecs_load_balancer and our ECS services in a different stack ecs_service .我们在一个堆栈ecs_load_balancer中有我们的目标组,在不同的堆栈ecs_service中有我们的 ECS 服务。 ecs_service stack depends on ecs_load_balancer . ecs_service栈依赖于ecs_load_balancer

When we break the dependency: props.targetGroup.addTarget(this.service);当我们打破依赖时: props.targetGroup.addTarget(this.service); in ecs_service stack.在 ecs_service 堆栈中。 CDK will try to delete the output of the target group and modify the target group resource (as I can see when I check the bb cdk diff). CDK 将尝试删除目标组的 output 并修改目标组资源(正如我在查看 bb cdk diff 时所看到的)。 While CDK deploys ecs_load_balancer stack first, CDK will think that this resource target group is still in used and throw an error when it tries to delete/modifies the target group:虽然 CDK 首先部署 ecs_load_balancer 堆栈,但 CDK 会认为此资源目标组仍在使用中,并在尝试删除/修改目标组时抛出错误:

Export Personal-Dev-us-east-1-ACSCalling-EcsLoadBalancer:ExportsOutputRefLoadBalancerListenerTargetGroupGroup27D2B0EED93AD008 cannot be deleted as it is in use by Personal-Dev-us-east-1-ACSCalling-EcsService and Personal-Dev-us-east-1-ACSCalling-OnePod-EcsService

We can delete the ECS target from the target group on the AWS console.我们可以在 AWS 控制台的目标组中删除 ECS 目标。 But not via CDK because of this cross stack reference problem.但由于这个交叉堆栈引用问题,不能通过 CDK。

I've tried to manually add back the Output that gets deleted in ecs_load_balancer.我尝试手动添加在 ecs_load_balancer 中删除的 Output。 But I still can't get rid of this change which will still cause deployment failure since the it can't be modified:但是我仍然无法摆脱这个仍然会导致部署失败的更改,因为它无法修改:

[~] AWS::ElasticLoadBalancingV2::TargetGroup LoadBalancer/Listener/TargetGroupGroup LoadBalancerListenerTargetGroupGroup27D2B0EE replace
 └─ [-] TargetType (requires replacement)
     └─ ip 

We couldn't find a way to get around this error from CDK.我们无法找到解决 CDK 错误的方法。 How can we remove this target group that we no longer need?我们怎样才能删除这个我们不再需要的目标群体?

Forcibly export the value when removing from consumer.从消费者中移除时强制导出值。 In another deployment remove the resource and its forced export from the producer.在另一个部署中,删除资源及其从生产者的强制导出。 Ref CDK docs .参考CDK 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM