JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.795

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.util

Class EC2MetadataUtils

    • Field Detail

      • SECURITY_CREDENTIALS_RESOURCE

        public static final String SECURITY_CREDENTIALS_RESOURCE
        Default resource path for credentials in the Amazon EC2 Instance Metadata Service.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EC2MetadataUtils

        public EC2MetadataUtils()
    • Method Detail

      • getAmiId

        public static String getAmiId()
        Get the AMI ID used to launch the instance.
      • getAmiLaunchIndex

        public static String getAmiLaunchIndex()
        Get the index of this instance in the reservation.
      • getAmiManifestPath

        public static String getAmiManifestPath()
        Get the manifest path of the AMI with which the instance was launched.
      • getAncestorAmiIds

        public static List<String> 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

        public static String getInstanceAction()
        Notifies the instance that it should reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending.
      • getInstanceId

        public static String getInstanceId()
        Get the ID of this instance.
      • getInstanceType

        public static String getInstanceType()
        Get the type of the instance.
      • getLocalHostName

        public static String 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

        public static String 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

        public static String 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

        public static String getAvailabilityZone()
        Get the Availability Zone in which the instance launched.
      • getProductCodes

        public static List<String> getProductCodes()
        Get the list of product codes associated with the instance, if any.
      • getPublicKey

        public static String getPublicKey()
        Get the public key. Only available if supplied at instance launch time.
      • getRamdiskId

        public static String getRamdiskId()
        Get the ID of the RAM disk specified at launch time, if applicable.
      • getReservationId

        public static String getReservationId()
        Get the ID of the reservation.
      • getSecurityGroups

        public static List<String> getSecurityGroups()
        Get the list of names of the security groups applied to the instance.
      • getIAMInstanceProfileInfo

        public static EC2MetadataUtils.IAMInfo getIAMInstanceProfileInfo()
        Get information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.
      • getInstanceInfo

        public 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

        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.

      • getInstanceSignature

        public static String getInstanceSignature()
        Get the signature of the instance.
      • getEC2InstanceRegion

        public static String 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

        public static Map<String,EC2MetadataUtils.IAMSecurityCredential> getIAMSecurityCredentials()
        Returns the temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM roles on the instance.
      • getBlockDeviceMapping

        public static Map<String,String> getBlockDeviceMapping()
        Get the virtual devices associated with the ami, root, ebs, and swap.
      • getUserData

        public static String getUserData()
        Get the metadata sent to the instance
      • getData

        public static String getData(String path,
         int tries)
      • getItems

        public static List<String> getItems(String path)
        Parameters:
        path - Path to query.
        Returns:
        List of items for given path or null if path does not exist.
      • getItems

        public static List<String> getItems(String path,
         int tries)
        Parameters:
        path - Path to query.
        tries - Number of attempts to query EC2 metadata service for items.
        Returns:
        List of items for given path or null if path does not exist.
      • getHostAddressForEC2MetadataService

        public static String getHostAddressForEC2MetadataService()
        Returns the host address of the Amazon EC2 Instance Metadata Service.
Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /