Reputation: 306
I am trying to retrieve multiple items from the AWS EC2 link local address
It can be done using multiple calls to the link-local address:
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/instance-id
i-1234567890abcdef0
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/instance-type
p3.2xlarge
These kind of calls are throteled by AWS
Is there a way to make a single call to get both?
Upvotes: 2
Views: 209
Reputation: 2047
You can retrieve both info by making a request to the Instance identity document.
curl http://169.254.169.254/latest/dynamic/instance-identity/document
This will return a JSON that looks like this:
{
"devpayProductCodes" : null,
"marketplaceProductCodes" : [ "1abc2defghijklm3nopqrs4tu" ],
"availabilityZone" : "us-west-2b",
"privateIp" : "10.158.112.84",
"version" : "2017-09-30",
"instanceId" : "i-1234567890abcdef0",
"billingProducts" : null,
"instanceType" : "t2.micro",
"accountId" : "123456789012",
"imageId" : "ami-5fb8c835",
"pendingTime" : "2016-11-19T16:32:11Z",
"architecture" : "x86_64",
"kernelId" : null,
"ramdiskId" : null,
"region" : "us-west-2"
}
Upvotes: 3