[英]How to change EBS volume type on a running instance with Boto3?
使用modify_volume()
方法:
import boto3
client = boto3.client('ec2')
response = client.modify_volume(VolumeId='vol-xxxxxxxx',VolumeType='io1',Iops=100)
即使在正在運行的啟動卷上也可以正常工作。
解決這個問題的最佳選擇是:
但是缺點是您必須重新啟動VM,而無法在不重新啟動VM的情況下執行整個過程。
new_volume_id=$(aws ec2 create-volume \
--region "$region" \
--availability-zone "$zone" \
--size "$size" \
--snapshot "$snapshot_id" \
--output text \
--volume-type <value>
--query 'VolumeId')
創建新卷后,您可以附加新卷。 但在此之前,您必須停止實例:
aws ec2 attach-volume \
--region "$region" \
--instance "$instance_id" \
--device "$root_device" \
--volume-id "$new_volume_id"
在這種情況下,我不確定此答案是否對您有幫助。
希望它能在一定程度上有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.