public class EC2MetadataUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
EC2MetadataUtils.IAMInfo
Information about the last time the instance profile was updated,
including the instance's LastUpdated date, InstanceProfileArn, and
InstanceProfileId.
|
static class |
EC2MetadataUtils.IAMSecurityCredential
The temporary security credentials (AccessKeyId, SecretAccessKey,
SessionToken, and Expiration) associated with the IAM role.
|
static class |
EC2MetadataUtils.InstanceInfo
This POJO is a best attempt to capture the instance info which is only
guaranteed to be a JSON document per
http://docs.aws.amazon.com/AWSEC2/latest
/UserGuide/ec2-instance-metadata.html
Instance info includes dynamic information about the current instance
such as region, instanceId, private IP address, etc.
|
static class |
EC2MetadataUtils.NetworkInterface
All of the metada associated with a network interface on the instance.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.lang.String> |
cache |
private static int |
DEFAULT_QUERY_RETRIES |
private static java.lang.String |
EC2_DYNAMICDATA_ROOT |
private static java.lang.String |
EC2_METADATA_ROOT |
private static java.lang.String |
EC2_USERDATA_ROOT |
private static EC2MetadataClient |
ec2MetadataClient |
private static java.lang.String |
INSTANCE_IDENTITY_DOCUMENT |
private static org.apache.commons.logging.Log |
log |
private static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
private static int |
MINIMUM_RETRY_WAIT_TIME_MILLISECONDS |
private static java.lang.String |
REGION |
Constructor and Description |
---|
EC2MetadataUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static java.lang.String |
doGetEC2InstanceRegion(java.lang.String json) |
(package private) static EC2MetadataUtils.InstanceInfo |
doGetInstanceInfo(java.lang.String json) |
private static java.lang.String |
fetchData(java.lang.String path) |
private static java.lang.String |
fetchData(java.lang.String path,
boolean force) |
static java.lang.String |
getAmiId()
Get the AMI ID used to launch the instance.
|
static java.lang.String |
getAmiLaunchIndex()
Get the index of this instance in the reservation.
|
static java.lang.String |
getAmiManifestPath()
Get the manifest path of the AMI with which the instance was launched.
|
static java.util.List<java.lang.String> |
getAncestorAmiIds()
Get the list of AMI IDs of any instances that were rebundled to created
this AMI.
|
static java.lang.String |
getAvailabilityZone()
Get the Availability Zone in which the instance launched.
|
static java.util.Map<java.lang.String,java.lang.String> |
getBlockDeviceMapping()
Get the virtual devices associated with the ami, root, ebs, and swap.
|
static java.lang.String |
getData(java.lang.String path) |
static java.lang.String |
getData(java.lang.String path,
int tries) |
static java.lang.String |
getEC2InstanceRegion()
Returns the current region of this running EC2 instance; or null if
it is unable to do so.
|
static EC2MetadataUtils.IAMInfo |
getIAMInstanceProfileInfo()
Get information about the last time the instance profile was updated,
including the instance's LastUpdated date, InstanceProfileArn, and
InstanceProfileId.
|
static java.util.Map<java.lang.String,EC2MetadataUtils.IAMSecurityCredential> |
getIAMSecurityCredentials()
Returns the temporary security credentials (AccessKeyId, SecretAccessKey,
SessionToken, and Expiration) associated with the IAM roles on the
instance.
|
static java.lang.String |
getInstanceAction()
Notifies the instance that it should reboot in preparation for bundling.
|
static java.lang.String |
getInstanceId()
Get the ID of this instance.
|
static EC2MetadataUtils.InstanceInfo |
getInstanceInfo()
The instance info is only guaranteed to be a JSON document per
http://docs
.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
|
static java.lang.String |
getInstanceType()
Get the type of the instance.
|
static java.util.List<java.lang.String> |
getItems(java.lang.String path) |
static java.util.List<java.lang.String> |
getItems(java.lang.String path,
int tries) |
private static java.util.List<java.lang.String> |
getItems(java.lang.String path,
int tries,
boolean slurp) |
static java.lang.String |
getLocalHostName()
Get the local hostname of the instance.
|
static java.lang.String |
getMacAddress()
Get the MAC address of the instance.
|
static java.util.List<EC2MetadataUtils.NetworkInterface> |
getNetworkInterfaces()
Get the list of network interfaces on the instance.
|
static java.lang.String |
getPrivateIpAddress()
Get the private IP address of the instance.
|
static java.util.List<java.lang.String> |
getProductCodes()
Get the list of product codes associated with the instance, if any.
|
static java.lang.String |
getPublicKey()
Get the public key.
|
static java.lang.String |
getRamdiskId()
Get the ID of the RAM disk specified at launch time, if applicable.
|
static java.lang.String |
getReservationId()
Get the ID of the reservation.
|
static java.util.List<java.lang.String> |
getSecurityGroups()
Get the list of names of the security groups applied to the instance.
|
static java.lang.String |
getUserData()
Get the metadata sent to the instance
|
private static final java.lang.String REGION
private static final java.lang.String INSTANCE_IDENTITY_DOCUMENT
private static final java.lang.String EC2_METADATA_ROOT
private static final java.lang.String EC2_USERDATA_ROOT
private static final java.lang.String EC2_DYNAMICDATA_ROOT
private static final int DEFAULT_QUERY_RETRIES
private static final int MINIMUM_RETRY_WAIT_TIME_MILLISECONDS
private static java.util.Map<java.lang.String,java.lang.String> cache
private static EC2MetadataClient ec2MetadataClient
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
private static final org.apache.commons.logging.Log log
public static java.lang.String getAmiId()
public static java.lang.String getAmiLaunchIndex()
public static java.lang.String getAmiManifestPath()
public static java.util.List<java.lang.String> getAncestorAmiIds()
public static java.lang.String getInstanceAction()
public static java.lang.String getInstanceId()
public static java.lang.String getInstanceType()
public static java.lang.String getLocalHostName()
public static java.lang.String getMacAddress()
public static java.lang.String getPrivateIpAddress()
public static java.lang.String getAvailabilityZone()
public static java.util.List<java.lang.String> getProductCodes()
public static java.lang.String getPublicKey()
public static java.lang.String getRamdiskId()
public static java.lang.String getReservationId()
public static java.util.List<java.lang.String> getSecurityGroups()
public static EC2MetadataUtils.IAMInfo getIAMInstanceProfileInfo()
public static EC2MetadataUtils.InstanceInfo getInstanceInfo()
This method is only a best attempt to capture the instance info as a typed object.
Get an InstanceInfo object with dynamic information about this instance.
static EC2MetadataUtils.InstanceInfo doGetInstanceInfo(java.lang.String json)
public static java.lang.String getEC2InstanceRegion()
The instance info is only guaranteed to be a JSON document per http://docs .aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
static java.lang.String doGetEC2InstanceRegion(java.lang.String json)
public static java.util.Map<java.lang.String,EC2MetadataUtils.IAMSecurityCredential> getIAMSecurityCredentials()
public static java.util.Map<java.lang.String,java.lang.String> getBlockDeviceMapping()
public static java.util.List<EC2MetadataUtils.NetworkInterface> getNetworkInterfaces()
public static java.lang.String getUserData()
public static java.lang.String getData(java.lang.String path)
public static java.lang.String getData(java.lang.String path, int tries)
public static java.util.List<java.lang.String> getItems(java.lang.String path)
public static java.util.List<java.lang.String> getItems(java.lang.String path, int tries)
private static java.util.List<java.lang.String> getItems(java.lang.String path, int tries, boolean slurp)
private static java.lang.String fetchData(java.lang.String path)
private static java.lang.String fetchData(java.lang.String path, boolean force)