0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS CLIでEC2のスナップショットを作成、削除

Last updated at Posted at 2018-11-01

手順

・AWS CLI のセットアップ
・コマンド叩いて作成、削除する
・そいつをcronで動かす

AWS CLIのセットアップ

IAM ユーザのキーが必要なのでまずは
認証情報タブ --> アクセスキーの作成 --> 新規アクセスキー
csvのダウンロードをしておき
以下のコマンドでセットアップ

# aws configure
AWS Access Key ID [None]: Access key ID
AWS Secret Access Key [None]: Secret access key
Default region name [None]: ap-northeast-1
Default output format [None]: json

コマンドうにうに

スナップショットの作成

# aws ec2 create-snapshot --volume-id vol-xxxxxx --description "説明"
{
    "Description": "説明",
    "Encrypted": false,
    "VolumeId": "vol-xxxxxx",
    "State": "pending",
    "VolumeSize": 500,
    "Progress": "",
    "StartTime": "2018-11-01T02:10:40.000Z",
    "SnapshotId": "snap-000000000000",
    "OwnerId": "000000000"
}

スナップショットの削除

aws ec2 delete-snapshot --snapshot-id snap-000000000000

作成したときの SnapshotId を保存しておいて
"SnapshotId": "snap-000000000000"
cronとかで自動で回せば楽になります

※script 作成なう

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?