我正在尝试删除具有多个版本的命令行的策略,如下所示:
function iam-list-versions () {
aws iam list-policy-versions --query "Versions[].VersionId" --policy-arn $1 --output text
}
function iam-delete-policy-versions () {
iam-list-versions $1 | xargs -n 1 -I{} aws iam delete-policy-version --policy-arn $1 --version-id {}
}
function iam-delete-policy () {
iam-delete-policy-versions $1
aws iam delete-policy --policy-arn $1
}
然后运行 iam-delete-policy arn:aws:iam::123456789012:policy/...
但我不断收到错误:
An error occurred (DeleteConflict) when calling the DeletePolicyVersion operation: Cannot delete the default version of a policy.
An error occurred (DeleteConflict) when calling the DeletePolicy operation: This policy has more than one version. Before you delete a policy, you must delete the policy's versions. The default version is deleted with the policy.
看起来我的iam-delete-policy-versions
功能不起作用。希望他们能简单地添加一个--force
标志。