简体   繁体   English

AWS CloudFormation:如果指定了 VolumeAttachment,则更新堆栈失败

[英]AWS CloudFormation: update-stack fails if VolumeAttachment specified

we're encountering a strange issue with AWS CloudFormation.我们遇到了 AWS CloudFormation 的一个奇怪问题。

We're using CloudFormation in order to automate the deployment of some our machines;我们正在使用 CloudFormation 来自动化部署我们的一些机器; our CloudFormation yml describes the deployment, which contains a persistent EBS volume which was created outside the stack, and we don't want to remove or recreate along such stack (it contains a lot of the state of our application).我们的 CloudFormation yml 描述了部署,它包含一个在堆栈外部创建的持久 EBS 卷,我们不想沿着这样的堆栈删除或重新创建(它包含我们应用程序的很多 state)。

The relevant CloudFormation yml snippet is:相关的 CloudFormation yml 片段是:

DataVolumeAttachment01: Type: AWS::EC2::VolumeAttachment Properties: Device: "/dev/xvdm" InstanceId: :Ref EC2Instance01 VolumeId: :Ref DataVolumeId EC2Instance01: Type: "AWS::EC2::Instance" Properties: ImageId: "ami-6f587e1c" KeyName: :Ref "KeyName" InstanceType: :Ref "InstanceType" BlockDeviceMappings: # Root device - DeviceName: "/dev/sda1" Ebs: VolumeType: "gp2" DeleteOnTermination: "true" VolumeSize: 20

So, the root device is "transient" (every time the stack is updated, such volume is deleted and gets reprovisioned with userdata), while /dev/xvdm should contain our persistent data;因此,根设备是“瞬态的”(每次堆栈更新时,此类卷都会被删除并重新配置用户数据),而 /dev/xvdm 应该包含我们的持久数据; such device gets mounted at the end of the userdata, and added to fstab.这样的设备被安装在用户数据的末尾,并添加到 fstab。

Following AWS own documentation , I created a script that unmounts such volume from inside the VM, and I even tried deattaching such volume from the EC2 Instance, something like:按照AWS 自己的文档,我创建了一个脚本,用于从 VM 内部卸载此类卷,我什至尝试从 EC2 实例中分离此类卷,例如:

${SSH_CMD} "cd /home/application && application stop && sudo umount /data && echo data volume unmounted" echo "detaching data volume" VOLID=$(aws ec2 describe-volumes --filters Name=tag-key,Values="Name" Name=tag-value,Values=persistent-volume --query 'Volumes[*].{ID:VolumeId}' --output text) aws ec2 detach-volume --volume-id "${VOLID}"

I have verified the umount and the detach succeed.我已经验证了 umount 和 detach 成功。

The creation of a new stack with my template and parameters succeeds.使用我的模板和参数创建新堆栈成功。

And yet, when I launch然而,当我发射

aws cloudformation update-stack --capabilities CAPABILITY_IAM --stack-name $STACK_NAME --template-body file://single_ec2_instance.yml --parameters file://$AWS_PARAMETERS_FILE

The update fails, with this error:更新失败,出现以下错误:

Update to resource type AWS::EC2::VolumeAttachment is not supported.

Even though I'm not changing anything within such resource.即使我没有更改此类资源中的任何内容。

What's up?这是怎么回事? How can I solve or work around?我该如何解决或变通?

It seems that the thing was a non-issue. 看来这不是问题。

Either CloudFormation is influenced by exhausted t2 cpu credits (which we had exhausted, we were trying to change the instance type for that exact reason in order to use m3 or m4) or we got a bad day for EC2/CloudFormation in Ireland. CloudFormation受到疲惫的t2 cpu积分的影响(我们已经穷尽了,出于确切的原因试图更改实例类型以使用m3或m4),或者在爱尔兰EC2 / CloudFormation遇到了糟糕的一天。 Today, with the same exact setup, every update succeeded. 今天,使用相同的精确设置,每个更新都成功。

I just had this problem and found the solution was to Terminate my stack which creates EC2 instances and then redploy.我刚遇到这个问题,发现解决方案是终止创建 EC2 实例然后重新部署的堆栈。

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

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