amazon-web-services - 无法彻底删除数据堆栈中带有 AWS::EC2::VolumeAttachment 到磁盘的工作堆栈

标签 amazon-web-services amazon-ec2 aws-cloudformation amazon-ebs

我有两个堆栈:myDatamyWorker。工作人员使用数据。删除工作人员时出现错误。这些错误表明他对数据的附件仍然有效。

myData 生命周期很长,包含 myVolume,一个 AWS::EC2::Volume

myWorker 仅偶尔存在,包含 myServermyMountPoint、一个 AWS::EC2::InstanceAWS::EC2::VolumeAttachment

这行不通。 myWorker 报告上的 delete-stack:

DELETE_FAILED Volume detachment between volume-id vol-XXXX and instance-id i-YYYY at device /dev/sdX is in busy state

这似乎很合理。顺序大概是:

create myWorker
  create myServer
  create myMountPoint
... later ...
delete-stack myWorker
   delete myMountPoint
   delete myServer

在这种情况下,服务器仍在运行并且可能正在使用安装点。

但这似乎不太可能。

create myWorker
  create myServer
  create myMountPoint
  start up myServer
     mount that mount point
     start services including disk mounting
... later ...
delete-stack myWorker
   stop up myServer
     stop services & unmount disk
   delete myMountPoint
   delete myServer

那么,帮忙吗?这个序列实际记录在哪里,我该如何解决这个问题?

最佳答案

Where is this sequence actually documented [...]

AWS::EC2::VolumeAttachment您所描述的行为已在资源的 CloudFormation 文档的开头注明:

Important

Before this resource can be deleted (and therefore the volume detached), you must first unmount the volume in the instance. Failure to do so results in the volume being stuck in the busy state while it is trying to detach, which could possibly damage the file system or the data it contains.

If an Amazon EBS volume is the root device of an instance, it cannot be detached while the instance is in the "running" state. To detach the root volume, stop the instance first.


[...] and how can I fix this?

对于像您这样的典型用例,其中 EC2 实例在实例的整个生命周期中使用附加的 EBS 卷,您可以使用 Volumes 声明您的 EBS 卷附件。属性 AWS::EC2::Instance资源而不是单独的AWS::EC2::VolumeAttachment资源。 Volumes 属性可让实例在从 EC2 实例分离之前先正确关闭(卸载任何已安装的卷是关闭过程的一部分)。

关于amazon-web-services - 无法彻底删除数据堆栈中带有 AWS::EC2::VolumeAttachment 到磁盘的工作堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36248833/

相关文章:

php - IAM 角色名称在 Yii 1 中被视为类

javascript - 如何在 JavaScript 模块中使用 AWS?

node.js - 从 AWS lambda 执行 shell 命令

amazon-web-services - 将 VSTS Build 与 AWS 结合使用的最简单方法是什么?

c# - 使用 Amazon Web Services (EC2) 和 c# Windows Service/WCF 进行远程调试

ubuntu - 从运行在 EC2 (Ubuntu) 上的 Jenkins 访问 AWS CodeCommit

amazon-web-services - 云信息 : create aws security group referencing another security group

amazon-web-services - 如何通过cloudformation删除包含图像的aws ECR存储库?

amazon-web-services - 无法在 cloudformation 中创建附加有 lambda 事件的 s3 存储桶

amazon-web-services - Aws CDK 跳过 IAM 语句更改