metadata

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error was caused by an AWS API 404 response.

Types

type CachedIMDS

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

CachedIMDS is a wrapper around EC2MetadataIface that adds a naive cache. There is no cache expiry, so don't use this for dynamic information.

func NewCachedIMDS

func NewCachedIMDS(imds EC2MetadataIface) CachedIMDS

NewCachedIMDS creates a new CachedIMDS.

func (CachedIMDS) GetMetadataWithContext

func (c CachedIMDS) GetMetadataWithContext(ctx context.Context, p string) (string, error)

GetMetadataWithContext implements the EC2MetadataIface interface.

type EC2MetadataIface

type EC2MetadataIface interface {
	GetMetadataWithContext(ctx context.Context, p string) (string, error)
}

EC2MetadataIface is a subset of the EC2Metadata API.

type FakeIMDS

type FakeIMDS map[string]interface{}

FakeIMDS is a trivial implementation of EC2MetadataIface using an in-memory map - for testing.

func (FakeIMDS) GetMetadataWithContext

func (f FakeIMDS) GetMetadataWithContext(ctx context.Context, p string) (string, error)

GetMetadataWithContext implements the EC2MetadataIface interface.

type TypedIMDS

type TypedIMDS struct {
	EC2MetadataIface
}

TypedIMDS is a typed wrapper around raw untyped IMDS SDK API.

func NewTypedIMDS

func NewTypedIMDS(inner EC2MetadataIface) TypedIMDS

NewTypedIMDS returns a typed wrapper around raw untyped IMDS SDK API.

func (TypedIMDS) GetAZ

func (imds TypedIMDS) GetAZ(ctx context.Context) (string, error)

GetAZ returns the Availability Zone in which the instance launched.

func (TypedIMDS) GetDeviceNumber

func (imds TypedIMDS) GetDeviceNumber(ctx context.Context, mac string) (int, error)

GetDeviceNumber returns the unique device number associated with an interface. The primary interface is 0.

func (TypedIMDS) GetIPv6s

func (imds TypedIMDS) GetIPv6s(ctx context.Context, mac string) ([]net.IP, error)

GetIPv6s returns the IPv6 addresses associated with the interface.

func (TypedIMDS) GetInstanceID

func (imds TypedIMDS) GetInstanceID(ctx context.Context) (string, error)

GetInstanceID returns the ID of this instance.

func (TypedIMDS) GetInstanceType

func (imds TypedIMDS) GetInstanceType(ctx context.Context) (string, error)

GetInstanceType returns the type of this instance.

func (TypedIMDS) GetInterfaceID

func (imds TypedIMDS) GetInterfaceID(ctx context.Context, mac string) (string, error)

GetInterfaceID returns the ID of the network interface.

func (TypedIMDS) GetLocalIPv4

func (imds TypedIMDS) GetLocalIPv4(ctx context.Context) (net.IP, error)

GetLocalIPv4 returns the private (primary) IPv4 address of the instance.

func (TypedIMDS) GetLocalIPv4s

func (imds TypedIMDS) GetLocalIPv4s(ctx context.Context, mac string) ([]net.IP, error)

GetLocalIPv4s returns the private IPv4 addresses associated with the interface. First returned address is the primary address.

func (TypedIMDS) GetMAC

func (imds TypedIMDS) GetMAC(ctx context.Context) (string, error)

GetMAC returns the first/primary network interface mac address.

func (TypedIMDS) GetMACs

func (imds TypedIMDS) GetMACs(ctx context.Context) ([]string, error)

GetMACs returns the interface addresses attached to the instance.

func (TypedIMDS) GetSecurityGroupIDs

func (imds TypedIMDS) GetSecurityGroupIDs(ctx context.Context, mac string) ([]string, error)

GetSecurityGroupIDs returns the IDs of the security groups to which the network interface belongs.

func (TypedIMDS) GetSubnetID

func (imds TypedIMDS) GetSubnetID(ctx context.Context, mac string) (string, error)

GetSubnetID returns the ID of the subnet in which the interface resides.

func (TypedIMDS) GetSubnetIPv4CIDRBlock

func (imds TypedIMDS) GetSubnetIPv4CIDRBlock(ctx context.Context, mac string) (net.IPNet, error)

GetSubnetIPv4CIDRBlock returns the IPv4 CIDR block for the subnet in which the interface resides.

func (TypedIMDS) GetSubnetIPv6CIDRBlocks

func (imds TypedIMDS) GetSubnetIPv6CIDRBlocks(ctx context.Context, mac string) (net.IPNet, error)

GetSubnetIPv6CIDRBlocks returns the IPv6 CIDR block for the subnet in which the interface resides. Note, despite plural name, this only returns a single CIDR block.

func (TypedIMDS) GetVPCIPv4CIDRBlocks

func (imds TypedIMDS) GetVPCIPv4CIDRBlocks(ctx context.Context, mac string) ([]net.IPNet, error)

GetVPCIPv4CIDRBlocks returns the IPv4 CIDR blocks for the VPC.

func (TypedIMDS) GetVPCIPv6CIDRBlocks

func (imds TypedIMDS) GetVPCIPv6CIDRBlocks(ctx context.Context, mac string) ([]net.IPNet, error)

GetVPCIPv6CIDRBlocks returns the IPv6 CIDR blocks for the VPC.

Jump to

Keyboard shortcuts

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