AWS SDK Version 3 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.

EC2 Instance Metadata. If this class is used on a non-EC2 instance, the properties in this class will return null.

Inheritance Hierarchy

System.Object
  Amazon.EC2.Util.EC2Metadata

Namespace: Amazon.EC2.Util
Assembly: AWSSDK.EC2.dll
Version: 3.x.y.z

Syntax

C#
public static class EC2Metadata

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

Note:

Asynchronous operations (methods ending with Async) in the table below are for .NET 4.5 or higher. For .NET 3.5 the SDK follows the standard naming convention of BeginMethodName and EndMethodName to indicate asynchronous operations - these method pairs are not shown in the table below.

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