/** * Get the type of the instance. */ public static String getInstanceType() { return fetchData(EC2_METADATA_ROOT + "/instance-type"); }
/** * Get the public key. Only available if supplied at instance launch time. */ public static String getPublicKey() { return fetchData(EC2_METADATA_ROOT + "/public-keys/0/openssh-key"); }
/** * Get the index of this instance in the reservation. */ public static String getAmiLaunchIndex() { return fetchData(EC2_METADATA_ROOT + "/ami-launch-index"); }
/** * Get the ID of this instance. */ public static String getInstanceId() { return fetchData(EC2_METADATA_ROOT + "/instance-id"); }
/** * 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). */ public static String getLocalHostName() { return fetchData(EC2_METADATA_ROOT + "/local-hostname"); }
/** * Get the Availability Zone in which the instance launched. */ public static String getAvailabilityZone() { return fetchData(EC2_METADATA_ROOT + "/placement/availability-zone"); }
/** * Get the ID of the RAM disk specified at launch time, if applicable. */ public static String getRamdiskId() { return fetchData(EC2_METADATA_ROOT + "/ramdisk-id"); }
/** * Get the signature of the instance. */ public static String getInstanceSignature() { return fetchData(EC2_DYNAMICDATA_ROOT + INSTANCE_IDENTITY_SIGNATURE); }
/** * Get the manifest path of the AMI with which the instance was launched. */ public static String getAmiManifestPath() { return fetchData(EC2_METADATA_ROOT + "/ami-manifest-path"); }
/** * 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). */ public static String getPrivateIpAddress() { return fetchData(EC2_METADATA_ROOT + "/local-ipv4"); }
/** * Get the ID of the reservation. */ public static String getReservationId() { return fetchData(EC2_METADATA_ROOT + "/reservation-id"); }
/** * Get the AMI ID used to launch the instance. */ public static String getAmiId() { return fetchData(EC2_METADATA_ROOT + "/ami-id"); }
/** * Notifies the instance that it should reboot in preparation for bundling. * Valid values: none | shutdown | bundle-pending. */ public static String getInstanceAction() { return fetchData(EC2_METADATA_ROOT + "/instance-action"); }
/** * 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). */ public static String getMacAddress() { return fetchData(EC2_METADATA_ROOT + "/mac"); }
private static String fetchData(String path) { return fetchData(path, false); }
/** * Get the AMI ID used to launch the instance. */ public static String getAmiId() { return fetchData(EC2_METADATA_ROOT + "/ami-id"); }
/** * 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). */ public static String getMacAddress() { return fetchData(EC2_METADATA_ROOT + "/mac"); }
/** * 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). */ public static String getPrivateIpAddress() { return fetchData(EC2_METADATA_ROOT + "/local-ipv4"); }
/** * Get the public key. Only available if supplied at instance launch time. */ public static String getPublicKey() { return fetchData(EC2_METADATA_ROOT + "/public-keys/0/openssh-key"); }
/** * Notifies the instance that it should reboot in preparation for bundling. * Valid values: none | shutdown | bundle-pending. */ public static String getInstanceAction() { return fetchData(EC2_METADATA_ROOT + "/instance-action"); }