You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS CLI删除服务托管型StackSet实例报错的解决咨询

解决服务托管型StackSet实例删除的CLI问题

针对服务托管型(SERVICE_MANAGED)权限模型的CloudFormation StackSet,删除实例时必须遵循核心规则:仅允许以组织单元(OU)作为目标,不能直接指定账号ID,且不能同时使用--accounts和--organizational-unit-id参数。你之前的命令同时包含了这两个参数,这是触发错误的直接原因。

正确的删除命令

移除--accounts参数,仅保留--organizational-unit-id指定目标OU,示例命令如下:

$opsResponse = aws cloudformation --region $region.RegionName delete-stack-instances `
    --call-as DELEGATED_ADMIN `
    --stack-set-name $stackDetails.StackSetName `
    --organizational-unit-id $ouId `
    --regions $multiDeleteRegions `
    --no-retain-stacks `
    --operation-preferences MaxConcurrentCount=1 | ConvertFrom-Json

特定账号实例的删除方式

如果仅需要清理个别账号的StackSet实例,无需调用delete-stack-instances命令:
将目标账号从StackSet关联的OU中移出即可——服务托管型StackSet的实例生命周期与OU成员身份绑定,账号移出后会自动完成实例清理。

内容的提问来源于stack exchange,提问作者Jay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 17:51:19