Documentation ¶
Overview ¶
Package ec2metadata provides the client for making API calls to the EC2 Instance Metadata service.
This package's client can be disabled completely by setting the environment variable "AWS_EC2_METADATA_DISABLED=true". This environment variable set to true instructs the SDK to disable the EC2 Metadata client. The client cannot be used while the environemnt variable is set to true, (case insensitive).
Index ¶
- Constants
- type Client
- func (c *Client) Available(ctx context.Context) bool
- func (c *Client) GetDynamicData(ctx context.Context, p string) (string, error)
- func (c *Client) GetInstanceIdentityDocument(ctx context.Context) (EC2InstanceIdentityDocument, error)
- func (c *Client) GetMetadata(ctx context.Context, p string) (string, error)
- func (c *Client) GetUserData(ctx context.Context) (string, error)
- func (c *Client) IAMInfo(ctx context.Context) (EC2IAMInfo, error)
- func (c *Client) Region(ctx context.Context) (string, error)
- type EC2IAMInfo
- type EC2InstanceIdentityDocument
Constants ¶
const (
// ServiceName is the name of the service.
ServiceName = "ec2metadata"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.23.2
A Client is an EC2 Instance Metadata service Client.
func New ¶
New creates a new instance of the Client client with a Config. This client is safe to use across multiple goroutines.
Example:
// Create a Client client from just a config. svc := ec2metadata.New(cfg)
func (*Client) Available ¶ added in v0.23.2
Available returns if the application has access to the EC2 Instance Metadata service. Can be used to determine if application is running within an EC2 Instance and the metadata service is available.
func (*Client) GetDynamicData ¶ added in v0.23.2
GetDynamicData uses the path provided to request information from the EC2 instance metadata service for dynamic data. The content will be returned as a string, or error if the request failed.
func (*Client) GetInstanceIdentityDocument ¶ added in v0.23.2
func (c *Client) GetInstanceIdentityDocument(ctx context.Context) (EC2InstanceIdentityDocument, error)
GetInstanceIdentityDocument retrieves an identity document describing an instance. Error is returned if the request fails or is unable to parse the response.
func (*Client) GetMetadata ¶ added in v0.23.2
GetMetadata uses the path provided to request information from the EC2 instance metadata service. The content will be returned as a string, or error if the request failed.
func (*Client) GetUserData ¶ added in v0.23.2
GetUserData returns the userdata that was configured for the service. If there is no user-data setup for the EC2 instance a "NotFoundError" error code will be returned.
type EC2IAMInfo ¶
type EC2IAMInfo struct { Code string LastUpdated time.Time InstanceProfileArn string InstanceProfileID string }
An EC2IAMInfo provides the shape for unmarshaling an IAM info from the metadata API
type EC2InstanceIdentityDocument ¶
type EC2InstanceIdentityDocument struct { DevpayProductCodes []string `json:"devpayProductCodes"` MarketplaceProductCodes []string `json:"marketplaceProductCodes"` AvailabilityZone string `json:"availabilityZone"` PrivateIP string `json:"privateIp"` Version string `json:"version"` Region string `json:"region"` InstanceID string `json:"instanceId"` BillingProducts []string `json:"billingProducts"` InstanceType string `json:"instanceType"` AccountID string `json:"accountId"` PendingTime time.Time `json:"pendingTime"` ImageID string `json:"imageId"` KernelID string `json:"kernelId"` RamdiskID string `json:"ramdiskId"` Architecture string `json:"architecture"` }
An EC2InstanceIdentityDocument provides the shape for unmarshaling an instance identity document