EBSボリューム、スナップショットコマンド検証

■EBSボリューム
特定タグのEBSボリュームのID取得
aws ec2 describe-volumes –filters “Name=tag:キー,Values=バリュー” –query “Volumes[].VolumeId” –output text

EBSボリューム一覧からボリュームIDの取得
aws ec2 describe-volumes –query Volumes[].VolumeId –output text

EBSボリューム一覧から最新のボリュームIDと作成時刻の取得
aws ec2 describe-volumes –query “Volumes | sort_by(@, &CreateTime)[-1].[VolumeId,CreateTime]” –output text

特定IDのスナップショットからEBSボリューム作成
aws ec2 create-volume –snapshot-id snap-0cab1688164271c8d –availability-zone ap-northeast-1a

特定IDのスナップショットからEBSボリューム作成
aws ec2 create-volume –snapshot-id snap-0cab1688164271c8d –availability-zone ap-northeast-1a –query “VolumeId”

特定IDのEBSボリュームを削除
aws ec2 delete-volume –volume-id vol-xxxxxxxxxxxxxxxxx

特定タグのEBSボリュームを1ずつ削除
aws ec2 describe-volumes –filters “Name=tag:キー,Values=バリュー” –query “Volumes[].VolumeId” –output text | xargs -n1 aws ec2 delete-volume –volume-id

■スナップショット
特定タグのスナップショットのID取得
aws ec2 describe-snapshots –filters “Name=tag:キー,Values=バリュー” –query “Snapshots[].SnapshotId” –output text

自己所有のスナップ一覧からボリュームIDの取得
aws ec2 describe-snapshots –owner-ids self –query Snapshots[].SnapshotId –output text

自己所有のスナップショット一覧から最新のIDと作成時刻の取得
aws ec2 describe-snapshots –owner-ids self –query “Snapshots | sort_by(@, &StartTime)[-1].[SnapshotId,StartTime]” –output text

特定IDのEBSボリュームのスナップショット作成
aws ec2 create-snapshot –volume-id vol-022b93ea07ded2f70

特定IDのEBSボリュームのスナップショット作成し、作成するスナップショットIDの出力
aws ec2 create-snapshot –volume-id vol-022b93ea07ded2f70 –query “SnapshotId”

特定IDのスナップショットを削除
aws ec2 delete-snapshot –snapshot-id snap-xxxxxxxxxxxxxxxxx

特定タグのスナップショットを1ずつ削除
aws ec2 describe-snapshots –owner-ids self –filters “Name=tag:キー,Values=バリュー” –query “Snapshots[].SnapshotId” –output text | xargs -n1 aws ec2 delete-snapshot –snapshot-id

コメント

タイトルとURLをコピーしました