libZSamazonkaZSamazonka
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.EC2.Metadata

Description

This module contains functions for retrieving various EC2 metadata from an instance's local metadata endpoint.

It is intended to be used when you need to make metadata calls prior to initialisation of the Env.

Synopsis

EC2 Instance Check

isEC2 :: MonadIO m => Manager -> m Bool Source #

Test whether the underlying host is running on EC2 by making an HTTP request to http://instance-data/latest.

Retrieving Instance Data

dynamic :: MonadIO m => Manager -> Dynamic -> m ByteString Source #

Retrieve the specified Dynamic data.

Throws HttpException if HTTP communication fails.

metadata :: MonadIO m => Manager -> Metadata -> m ByteString Source #

Retrieve the specified Metadata.

Throws HttpException if HTTP communication fails.

userdata :: MonadIO m => Manager -> m (Maybe ByteString) Source #

Retrieve the user data. Returns Nothing if no user data is assigned to the instance.

Throws HttpException if HTTP communication fails.

identity :: MonadIO m => Manager -> m (Either String IdentityDocument) Source #

Retrieve the instance's identity document, detailing various EC2 metadata.

You can alternatively retrieve the raw unparsed identity document by using dynamic and the Document path.

See: AWS Instance Identity Documents.

Path Constructors

data Dynamic Source #

Constructors

FWS

Value showing whether the customer has enabled detailed one-minute monitoring in CloudWatch.

Valid values: enabled | disabled.

Document

JSON containing instance attributes, such as instance-id, private IP address, etc. See: identity, InstanceDocument.

PKCS7

Used to verify the document's authenticity and content against the signature.

Signature 

Instances

Instances details
Eq Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

(==) :: Dynamic -> Dynamic -> Bool #

(/=) :: Dynamic -> Dynamic -> Bool #

Ord Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Dynamic :: Type -> Type #

Methods

from :: Dynamic -> Rep Dynamic x #

to :: Rep Dynamic x -> Dynamic #

ToText Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Dynamic -> Text #

type Rep Dynamic Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Dynamic = D1 ('MetaData "Dynamic" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) ((C1 ('MetaCons "FWS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Document" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PKCS7" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Signature" 'PrefixI 'False) (U1 :: Type -> Type)))

data Metadata Source #

Constructors

AMIId

The AMI ID used to launch the instance.

AMILaunchIndex

If you started more than one instance at the same time, this value indicates the order in which the instance was launched. The value of the first instance launched is 0.

AMIManifestPath

The path to the AMI's manifest file in Amazon S3. If you used an Amazon EBS-backed AMI to launch the instance, the returned result is unknown.

AncestorAMIIds

The AMI IDs of any instances that were rebundled to create this AMI. This value will only exist if the AMI manifest file contained an ancestor-amis key.

BlockDevice !Mapping

See: Mapping

Hostname

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).

IAM !Info

See: Info

InstanceAction

Notifies the instance that it should reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending.

InstanceId

The ID of this instance.

InstanceType

The type of instance.

See: InstanceType

KernelId

The ID of the kernel launched with this instance, if applicable.

LocalHostname

The private DNS 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).

LocalIPV4

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 the device number is 0).

MAC

The instance's media access control (MAC) address. In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which the device number is 0).

Network !Text !Interface

See: Interface

AvailabilityZone

The Availability Zone in which the instance launched.

ProductCodes

Product codes associated with the instance, if any.

PublicHostname

The instance's public DNS. If the instance is in a VPC, this category is only returned if the enableDnsHostnames attribute is set to true. For more information, see Using DNS with Your VPC.

PublicIPV4

The public IP address. If an Elastic IP address is associated with the instance, the value returned is the Elastic IP address.

OpenSSHKey

Public key. Only available if supplied at instance launch time.

RAMDiskId

The ID of the RAM disk specified at launch time, if applicable.

ReservationId

ID of the reservation.

SecurityGroups

The names of the security groups applied to the instance.

Instances

Instances details
Eq Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Ord Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Metadata :: Type -> Type #

Methods

from :: Metadata -> Rep Metadata x #

to :: Rep Metadata x -> Metadata #

ToText Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Metadata -> Text #

type Rep Metadata Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Metadata = D1 ('MetaData "Metadata" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) ((((C1 ('MetaCons "AMIId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AMILaunchIndex" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "AMIManifestPath" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AncestorAMIIds" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BlockDevice" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Mapping))))) :+: ((C1 ('MetaCons "Hostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IAM" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Info)) :+: C1 ('MetaCons "InstanceAction" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "InstanceId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InstanceType" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KernelId" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "LocalHostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LocalIPV4" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MAC" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Network" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Interface)) :+: (C1 ('MetaCons "AvailabilityZone" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ProductCodes" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PublicHostname" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PublicIPV4" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OpenSSHKey" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "RAMDiskId" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ReservationId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SecurityGroups" 'PrefixI 'False) (U1 :: Type -> Type))))))

data Mapping Source #

Constructors

AMI

The virtual device that contains the root/boot file system.

EBS !Int

The virtual devices associated with Amazon EBS volumes, if present. This value is only available in metadata if it is present at launch time. The N indicates the index of the Amazon EBS volume (such as ebs1 or ebs2).

Ephemeral !Int

The virtual devices associated with ephemeral devices, if present. The N indicates the index of the ephemeral volume.

Root

The virtual devices or partitions associated with the root devices, or partitions on the virtual device, where the root (/ or C:) file system is associated with the given instance.

Swap

The virtual devices associated with swap. Not always present.

Instances

Instances details
Eq Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

(==) :: Mapping -> Mapping -> Bool #

(/=) :: Mapping -> Mapping -> Bool #

Ord Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Mapping :: Type -> Type #

Methods

from :: Mapping -> Rep Mapping x #

to :: Rep Mapping x -> Mapping #

ToText Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Mapping -> Text #

type Rep Mapping Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Mapping = D1 ('MetaData "Mapping" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) ((C1 ('MetaCons "AMI" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EBS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))) :+: (C1 ('MetaCons "Ephemeral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: (C1 ('MetaCons "Root" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Swap" 'PrefixI 'False) (U1 :: Type -> Type))))

data Info Source #

Constructors

Info'

Returns information about the last time the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.

SecurityCredentials (Maybe Text)

Where role-name is the name of the IAM role associated with the instance. Returns the temporary security credentials.

See: Auth for JSON deserialisation.

Instances

Instances details
Eq Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

(==) :: Info -> Info -> Bool #

(/=) :: Info -> Info -> Bool #

Ord Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

compare :: Info -> Info -> Ordering #

(<) :: Info -> Info -> Bool #

(<=) :: Info -> Info -> Bool #

(>) :: Info -> Info -> Bool #

(>=) :: Info -> Info -> Bool #

max :: Info -> Info -> Info #

min :: Info -> Info -> Info #

Show Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

showsPrec :: Int -> Info -> ShowS #

show :: Info -> String #

showList :: [Info] -> ShowS #

Generic Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Info :: Type -> Type #

Methods

from :: Info -> Rep Info x #

to :: Rep Info x -> Info #

ToText Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Info -> Text #

type Rep Info Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Info = D1 ('MetaData "Info" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) (C1 ('MetaCons "Info'" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SecurityCredentials" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))))

data Interface Source #

Constructors

IDeviceNumber

The device number associated with that interface. Each interface must have a unique device number. The device number serves as a hint to device naming in the instance; for example, device-number is 2 for the eth2 device.

IIPV4Associations !Text

The private IPv4 addresses that are associated with each public-ip address and assigned to that interface.

ILocalHostname

The interface's local hostname.

ILocalIPV4s

The private IP addresses associated with the interface.

IMAC

The instance's MAC address.

IOwnerId

The ID of the owner of the network interface. In multiple-interface environments, an interface can be attached by a third party, such as Elastic Load Balancing. Traffic on an interface is always billed to the interface owner.

IPublicHostname

The interface's public DNS. If the instance is in a VPC, this category is only returned if the enableDnsHostnames attribute is set to true. For more information, see Using DNS with Your VPC.

IPublicIPV4s

The Elastic IP addresses associated with the interface. There may be multiple IP addresses on an instance.

ISecurityGroups

Security groups to which the network interface belongs. Returned only for instances launched into a VPC.

ISecurityGroupIds

IDs of the security groups to which the network interface belongs. Returned only for instances launched into a VPC. For more information on security groups in the EC2-VPC platform, see Security Groups for Your VPC.

ISubnetId

The ID of the subnet in which the interface resides. Returned only for instances launched into a VPC.

ISubnetIPV4_CIDRBlock

The CIDR block of the subnet in which the interface resides. Returned only for instances launched into a VPC.

IVPCId

The ID of the VPC in which the interface resides. Returned only for instances launched into a VPC.

IVPCIPV4_CIDRBlock

The CIDR block of the VPC in which the interface resides. Returned only for instances launched into a VPC.

Instances

Instances details
Eq Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Ord Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep Interface :: Type -> Type #

ToText Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Methods

toText :: Interface -> Text #

type Rep Interface Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep Interface = D1 ('MetaData "Interface" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) (((C1 ('MetaCons "IDeviceNumber" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "IIPV4Associations" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "ILocalHostname" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ILocalIPV4s" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IMAC" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IOwnerId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IPublicHostname" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "IPublicIPV4s" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ISecurityGroups" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ISecurityGroupIds" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ISubnetId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ISubnetIPV4_CIDRBlock" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IVPCId" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IVPCIPV4_CIDRBlock" 'PrefixI 'False) (U1 :: Type -> Type)))))

Identity Document

data IdentityDocument Source #

Represents an instance's identity document.

Note: Fields such as $sel:_instanceType:IdentityDocument are represented as unparsed Text and will need to be manually parsed using fromText when the relevant types from a library such as Amazonka.EC2 are brought into scope.

Instances

Instances details
Eq IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Show IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Generic IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

Associated Types

type Rep IdentityDocument :: Type -> Type #

ToJSON IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

FromJSON IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep IdentityDocument Source # 
Instance details

Defined in Amazonka.EC2.Metadata

type Rep IdentityDocument = D1 ('MetaData "IdentityDocument" "Amazonka.EC2.Metadata" "libZSamazonkaZSamazonka" 'False) (C1 ('MetaCons "IdentityDocument" 'PrefixI 'True) (((S1 ('MetaSel ('Just "_devpayProductCodes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [Text])) :*: (S1 ('MetaSel ('Just "_billingProducts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Just "_version") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)))) :*: ((S1 ('MetaSel ('Just "_privateIp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "_availabilityZone") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "_region") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Region) :*: S1 ('MetaSel ('Just "_instanceId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)))) :*: ((S1 ('MetaSel ('Just "_instanceType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "_accountId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "_imageId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)))) :*: ((S1 ('MetaSel ('Just "_kernelId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "_ramdiskId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "_architecture") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "_pendingTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe ISO8601)))))))

Lenses