mspices
mspices

Reputation: 459

How to set image name from cli

When logged in to the AWS EC2 Management Console, the list of AMIs has, as its first column, "Name" (followed by "AMI Name", "AMI ID", etc).

For AMIs created through AWS CLI (using aws ec2 import-image), the Name field is empty. How can I set the name programmatically?

Also, is there any implication for giving it a name (e.g. does it have to be unique, and is the name used by something?) I would like to have it as a useful info, for managing my AMIs from the console.

Upvotes: 1

Views: 810

Answers (1)

jellycsc
jellycsc

Reputation: 12359

If you select the AMI row which has a value present in the Name column in the web console, then in the Tags tab you will see the customizable AMI name is actually the value corresponding to the Name key.

You can also check this via AWS CLI,

aws ec2 describe-tags --filters 'Name=resource-id,Values=<ami-id>'

To set a name for an AMI, you just need to create a tag whose key is Name and value is the name you want to set.

aws ec2 create-tags --resources <ami-id> --tags 'Key=Name,Value=<name>'

The name doesn't have to be unique across all AMIs.

Upvotes: 3

Related Questions