Package com.amazonaws.util
Class EC2MetadataUtils
java.lang.Object
com.amazonaws.util.EC2MetadataUtils
Utility class for retrieving Amazon EC2 instance metadata.
You can use the data to build more generic AMIs that can be modified by configuration files supplied at launch time. For example, if you run web servers for various small businesses, they can all use the same AMI and retrieve their content from the Amazon S3 bucket you specify at launch. To add a new customer at any time, simply create a bucket for the customer, add their content, and launch your AMI.
More information about Amazon EC2 Metadata
You can use the data to build more generic AMIs that can be modified by configuration files supplied at launch time. For example, if you run web servers for various small businesses, they can all use the same AMI and retrieve their content from the Amazon S3 bucket you specify at launch. To add a new customer at any time, simply create a bucket for the customer, add their content, and launch your AMI.
More information about Amazon EC2 Metadata
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.static class
The temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM role.static class
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
All of the metada associated with a network interface on the instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getAmiId()
Get the AMI ID used to launch the instance.static String
Get the index of this instance in the reservation.static String
Get the manifest path of the AMI with which the instance was launched.Get the list of AMI IDs of any instances that were rebundled to created this AMI.static String
Get the Availability Zone in which the instance launched.Get the virtual devices associated with the ami, root, ebs, and swap.static String
static String
static String
Returns the current region of this running EC2 instance; or null if it is unable to do so.static EC2MetadataUtils.IAMInfo
Get information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.Returns the temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM roles on the instance.static String
Notifies the instance that it should reboot in preparation for bundling.static String
Get the ID of this instance.The instance info is only guaranteed to be a JSON document per http://docs .aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.htmlstatic String
Get the type of the instance.static String
Get the local hostname of the instance.static String
Get the MAC address of the instance.Get the list of network interfaces on the instance.static String
Get the private IP address of the instance.Get the list of product codes associated with the instance, if any.static String
Get the public key.static String
Get the ID of the RAM disk specified at launch time, if applicable.static String
Get the ID of the reservation.Get the list of names of the security groups applied to the instance.static String
Get the metadata sent to the instance
-
Constructor Details
-
EC2MetadataUtils
public EC2MetadataUtils()
-
-
Method Details
-
getAmiId
Get the AMI ID used to launch the instance. -
getAmiLaunchIndex
Get the index of this instance in the reservation. -
getAmiManifestPath
Get the manifest path of the AMI with which the instance was launched. -
getAncestorAmiIds
Get the list of AMI IDs of any instances that were rebundled to created this AMI. Will only exist if the AMI manifest file contained an ancestor-amis key. -
getInstanceAction
Notifies the instance that it should reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending. -
getInstanceId
Get the ID of this instance. -
getInstanceType
Get the type of the instance. -
getLocalHostName
Get the local hostname of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). -
getMacAddress
Get the MAC address of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). -
getPrivateIpAddress
Get the private IP address of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). -
getAvailabilityZone
Get the Availability Zone in which the instance launched. -
getProductCodes
Get the list of product codes associated with the instance, if any. -
getPublicKey
Get the public key. Only available if supplied at instance launch time. -
getRamdiskId
Get the ID of the RAM disk specified at launch time, if applicable. -
getReservationId
Get the ID of the reservation. -
getSecurityGroups
Get the list of names of the security groups applied to the instance. -
getIAMInstanceProfileInfo
Get information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId. -
getInstanceInfo
The instance info is only guaranteed to be a JSON document per http://docs .aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.htmlThis 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.
-
getEC2InstanceRegion
Returns the current region of this running EC2 instance; or null if it is unable to do so. The method avoids interpreting other parts of the instance info JSON document to minimize potential failure.The instance info is only guaranteed to be a JSON document per http://docs .aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
-
getIAMSecurityCredentials
Returns the temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM roles on the instance. -
getBlockDeviceMapping
Get the virtual devices associated with the ami, root, ebs, and swap. -
getNetworkInterfaces
Get the list of network interfaces on the instance. -
getUserData
Get the metadata sent to the instance -
getData
-
getData
-
getItems
-
getItems
-