imds

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client defines the client for interacting with the Amazon EC2 Instance Metadata Service (IMDS)

func NewFromAPI

func NewFromAPI(api MetadataClientAPI) *Client

NewFromAPI returns a new client from the provided IMDS API implementation

func (*Client) InstanceMetadata

func (c *Client) InstanceMetadata(ctx context.Context) (Metadata, error)

InstanceMetadata attempts to retrieve useful metadata associated with the current EC2 instance by querying IMDS

type Metadata

type Metadata struct {
	// IPv4 is the private IPv4 address of the launched instance
	IPv4 string

	// Region of where the EC2 instance was launched
	Region string

	// VPC ID of where the EC2 instance was launched
	VPC string

	// AZ is the availability zone where the instance was launched
	AZ string

	// InstanceID is the unique ID of this instance
	InstanceID string
}

Metadata contains metadata associated with an EC2 instance

type MetadataClientAPI

type MetadataClientAPI interface {
	// GetMetadata uses the path provided to request information from the Amazon
	// EC2 Instance Metadata Service
	GetMetadata(ctx context.Context, params *awsimds.GetMetadataInput, optFns ...func(*awsimds.Options)) (*awsimds.GetMetadataOutput, error)
}

MetadataClientAPI defines the API for interacting with the Amazon EC2 Instance Metadata Service (IMDS)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL