imds

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 5 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 ClientAPI) *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 ClientAPI

type ClientAPI 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)
}

ClientAPI defines the API for interacting with the Amazon EC2 Instance Metadata Service (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

	// Name associated with the EC2 instance. This will be blank unless
	// tags have been enabled within IMDS for this EC2 instance
	Name string

	// Tags contains a map of all tags associated with the EC2 instance
	Tags map[string]string
}

Metadata contains metadata associated with an EC2 instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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