How can i create an AMI of the instance using the cli command ? . I ahve referred the official documentation - https://docs.aws.amazon.com/cli/latest/reference/ec2/create-image.html . I also have need to create a snapshot of the attached volume
This is the command i am trying ,
aws ec2 create-image --instance-id "instance-id" --name "my-image-nov-9"
But I need additional parameters to include the tag for the created image
Use this CLI command to create the AMI of an instance
aws ec2 create-image --instance-id instance-id --name my-image-nov-9 --no-reboot --tag-specifications "ResourceType=image,Tags=[{Key=project,Value=test-project,Key=team,Value=development}]"
--no-reboot | --reboot (boolean)
Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:
Default: false
true - The instance is not rebooted before creating the image.
--tag-specifications (list)
The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
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.