Amazon EC2 AMI 取消注册保护
您可以在 AMI 上开启取消注册保护,以防止意外或恶意删除。开启取消注册保护后,任何用户都无法取消注册该 AMI,无论其 IAM 权限如何。如果要取消注册该 AMI,则必须首先关闭其上的取消注册保护。
在 AMI 上开启取消注册保护时,您可以选择包含 24 小时的冷却时间。此冷却时间是取消注册保护在您关闭后仍然有效的时间。在此冷却时间内,该 AMI 无法取消注册。冷却时间结束后,可以取消注册该 AMI。
所有现有和新的 AMI 都会默认关闭取消注册保护。
开启取消注册保护
使用以下过程开启取消注册保护。
- Console
-
- AWS CLI
-
开启注销保护
使用 enable-image-deregistration-protection 命令。要启用可选的冷却时间,请添加 --with-cooldown
选项。
aws ec2 enable-image-deregistration-protection \
--image-id ami-0abcdef1234567890
\
--with-cooldown
- PowerShell
-
开启注销保护
使用 Enable-EC2ImageDeregistrationProtection cmdlet。要启用可选的冷却时间,请将 -WithCooldown
参数设置为 true
。
Enable-EC2ImageDeregistrationProtection `
-ImageId ami-0abcdef1234567890
`
-WithCooldown $true
关闭取消注册保护
使用以下过程关闭取消注册保护。
如果您在为 AMI 开启取消注册保护时选择了包含 24 小时冷却时间的选项,则在您关闭取消注册保护后,您将无法立即取消注册 AMI。此冷却时间为 24 小时,是取消注册保护在您关闭后仍然有效的时间。在此冷却时间内,该 AMI 无法取消注册。冷却时间结束后,可以取消注册该 AMI。
- Console
-
- AWS CLI
-
关闭注销保护
使用 disable-image-deregistration-protection 命令。
aws ec2 disable-image-deregistration-protection --image-id ami-0abcdef1234567890
- PowerShell
-
关闭注销保护
使用 Disable-EC2ImageDeregistrationProtection cmdlet。
Disable-EC2ImageDeregistrationProtection -ImageId ami-0abcdef1234567890