in Education by
Amazon recently added the wonderful feature of tagging EC2 instances with key-value pairs to make the management of large numbers of VMs a bit easier. Is there some way to query these tags in the same way as some of the other user-set data? For example: $ curl http://169.254.169.254/latest/meta-data/placement/availability-zone us-east-1d Is there some similar way to query the tags? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
To retrieve your instance id use a combination of AWS metadata tool and the new Tag API to retrieve the tags for the instance. After you have installed ec2-metadata and ec2-describe-tags, use this example shell command to retrieve your current instances name. In this example, “Name=demo” is the tag you have to use. Assumes EC2_PRIVATE_KEY and EC2_CERT environment variables are set. ec2-describe-tags \ --filter "resource-type=instance" \ --filter "resource-id=$(ec2-metadata -i | cut -d ' ' -f2)" \ --filter "key=Name" | cut -f5 This returns demo.

Related questions

0 votes
    I want to list the public IP addresses of my EC2 instances using Bash, separated by a delimiter (space or ... something else entirely? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    How can I find out the instance id of an ec2 instance from within the ec2 instance? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I've got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2. ... path ; ec2-describe-instances Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am trying to use aws container service as per the documentation in http://docs.aws.amazon.com/AmazonECS/latest/ ... in a console? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I want to upgrade my Amazon EC2 micro (t1.micro) instance to large. Please help. Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    How can I delete instance in Amazon EC2. I have terminated the instance but still it was showing in ... instance gets terminated Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    We have a large ec2 instance running in Asia pacific region. We want to reserve that particular instance.In aws ... out on something Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    When I reboot an EC2 instance, do I get the initial image again, or is the state of the hard disk before the ... in when I rebooted? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I need SSH access to an Amazon EC2 instance running Ubuntu. All I have is the Amazon username and password. Any ideas? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I ... user's guide. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Sometimes when trying to launch my t1.micro EC2 instance, it cannot be provisioned and Amazon recommends trying ... existing instance? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I cannot SSH into my instance - Operation timed out. What could be the reasons why, and what can I do to ... because of memory issues. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I was given AWS Console access to an account with 2 instances running that I cannot shut down (in production). ... into the instances? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Bit confused here, I have an on-demand instance but do I get charged even when I stop the instance? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Is it possible to clone an EC2 instance data and all? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
...