修改实例大小而不是创建新卷 (Cloudformation)
Modify Instance size instead of creating new volume (Cloudformation)
我正在尝试为我的实例提供更多磁盘 space,因为默认情况下它使用 8GB。我需要大约 20GB。我使用以下内容:
但我收到此错误 - unixDevice 的值“/dev/sda1”无效。连接点 /dev/sda1 已在使用中
有没有一种方法可以在不创建新卷的情况下修改磁盘 space 还是我做错了什么?
"WebServerInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"Volumes" : [
{ "VolumeId" : { "Ref" : "MyVolume1" },
"Device" : "/dev/sda1"
}
],
}
}
"MyVolume1": {
"Type": "AWS::EC2::Volume",
"Properties": {
"Size": "50",
"AvailabilityZone" : "eu-west-1a"
},}
2020 年 11 月更新
根据 AWS::EC2::Volume
documentation for the Size
property:
Update requires: No interruption
因此,您可以修改模板,然后执行更新。
我对 John Rotenstein 的回答有一些疑问。公平地说,AWS 正在迅速发展,他的建议当时可能 correct/appropriate。
- 实际上可以通过 CloudFormation 增加 EBS 卷的大小。但是,您无法通过 CloudFormation 或任何其他方式减小 EBS 卷的大小。如果增加卷大小,则需要扩展 OS 中的卷,以便它看到额外的 space。
- 如果您通过 CloudFormation 管理您的 AWS 资源,则在管理控制台中修改这些资源会导致配置漂移,这在最好的情况下是不整洁的,在最坏的情况下是危险的。如果您采用基础架构即代码方法,则应始终在代码中修改您的资源。
我正在尝试为我的实例提供更多磁盘 space,因为默认情况下它使用 8GB。我需要大约 20GB。我使用以下内容:
但我收到此错误 - unixDevice 的值“/dev/sda1”无效。连接点 /dev/sda1 已在使用中
有没有一种方法可以在不创建新卷的情况下修改磁盘 space 还是我做错了什么?
"WebServerInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"Volumes" : [
{ "VolumeId" : { "Ref" : "MyVolume1" },
"Device" : "/dev/sda1"
}
],
}
}
"MyVolume1": {
"Type": "AWS::EC2::Volume",
"Properties": {
"Size": "50",
"AvailabilityZone" : "eu-west-1a"
},}
2020 年 11 月更新
根据 AWS::EC2::Volume
documentation for the Size
property:
Update requires: No interruption
因此,您可以修改模板,然后执行更新。
我对 John Rotenstein 的回答有一些疑问。公平地说,AWS 正在迅速发展,他的建议当时可能 correct/appropriate。
- 实际上可以通过 CloudFormation 增加 EBS 卷的大小。但是,您无法通过 CloudFormation 或任何其他方式减小 EBS 卷的大小。如果增加卷大小,则需要扩展 OS 中的卷,以便它看到额外的 space。
- 如果您通过 CloudFormation 管理您的 AWS 资源,则在管理控制台中修改这些资源会导致配置漂移,这在最好的情况下是不整洁的,在最坏的情况下是危险的。如果您采用基础架构即代码方法,则应始终在代码中修改您的资源。