AWS SDK Version 2 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

.NET Framework 3.5
 
EC2 Instance Metadata.

Inheritance Hierarchy

System.Object
  Amazon.EC2.Util.EC2Metadata

Namespace: Amazon.EC2.Util
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public static class EC2Metadata : Object

The EC2Metadata type exposes the following members

Properties

NameTypeDescription
Public Property Static Property AmiId System.String The AMI ID used to launch the instance.
Public Property Static Property AmiLaunchIndex System.String The index of this instance in the reservation.
Public Property Static Property AmiManifestPath System.String The manifest path of the AMI with which the instance was launched.
Public Property Static Property AncestorAmiIds System.Collections.Generic.IEnumerable<System.String> The AMI IDs of any instances that were rebundled to create this AMI. Will only exist if the AMI manifest file contained an ancestor-amis key.
Public Property Static Property AvailabilityZone System.String The Availability Zone in which the instance launched.
Public Property Static Property BlockDeviceMapping System.Collections.Generic.IDictionary<System.String, System.String> The virtual devices associated with the ami, root, ebs, and swap.
Public Property Static Property Hostname System.String The private hostname of the instance. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).
Public Property Static Property IAMInstanceProfileInfo Amazon.EC2.Util.IAMInfo Returns information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.
Public Property Static Property IAMSecurityCredentials System.Collections.Generic.IDictionary<System.String, Amazon.EC2.Util.IAMSecurityCredential> Returns the temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM roles on the instance.
Public Property Static Property InstanceAction System.String Notifies the instance that it should reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending.
Public Property Static Property InstanceId System.String The ID of this instance.
Public Property Static Property InstanceType System.String The type of instance.
Public Property Static Property KernelId System.String The ID of the kernel launched with this instance, if applicable.
Public Property Static Property LocalHostname System.String 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 Property Static Property MacAddress System.String The instance's MAC address. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0).
Public Property Static Property NetworkInterfaces System.Collections.Generic.IEnumerable<Amazon.EC2.Util.NetworkInterface> The network interfaces on the instance.
Public Property Static Property PrivateIpAddress System.String 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 Property Static Property ProductCodes System.Collections.Generic.IEnumerable<System.String> Product codes associated with the instance, if any.
Public Property Static Property PublicKey System.String Public key. Only available if supplied at instance launch time.
Public Property Static Property RamdiskId System.String The ID of the RAM disk specified at launch time, if applicable.
Public Property Static Property ReservationId System.String ID of the reservation.
Public Property Static Property SecurityGroups System.Collections.Generic.IEnumerable<System.String> The names of the security groups applied to the instance.
Public Property Static Property UserData System.String The metadata sent to the instance.

Methods

NameDescription
Public Method Static Method GetData(string) Return the metadata at the path
Public Method Static Method GetData(string, int) Return the metadata at the path
Public Method Static Method GetItems(string) Return the list of items in the metadata at path.
Public Method Static Method GetItems(string, int) Return the list of items in the metadata at path.

Remarks

Amazon EC2 instances can access instance-specific metadata, as well as data supplied when launching the instances, using a specific URI.

You can use this 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 EC2 Metadata http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5