Using AWS cli create-image with tags

0

Hi, I am creating a script in windows to create images of an EC2 Windows instance using Create-image option. aws ec2 create-image --instance-id i-123456789 --name "My server" --no-reboot'

I want to add the same two tags, to the AMI and to the snapshots. In the console there is an option called "Tag image and snapshots together" Is there a way to do it in a command line?

Itamar
質問済み 5ヶ月前320ビュー
1回答
0
承認された回答

Hi,

As described on the AWS-Cli documentation, you can use the --tag-specifications parameter to tag the AMI, the snapshots, or both on creation.

  • To tag the AMI, the value for ResourceType must be image .
  • To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the instance, the value for ResourceType must be snapshot . The same tag is applied to all of the snapshots that are created.

Example:

aws ec2 create-image \
    --instance-id i-1234567890abcdef0 \
    --name "My server" \
    --no-reboot
    --tag-specifications "ResourceType=image,Tags=[{Key=cost-center,Value=cc123}]" "ResourceType=snapshot,Tags=[{Key=cost-center,Value=cc123}]"
profile picture
エキスパート
回答済み 5ヶ月前
profile picture
エキスパート
レビュー済み 5ヶ月前
profile picture
エキスパート
レビュー済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ