awsutils

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 38 Imported by: 34

Documentation

Overview

Package awsutils is a utility package for calling EC2 or IMDS

Index

Constants

View Source
const (

	// UnknownInstanceType indicates that the instance type is not yet supported
	UnknownInstanceType = "vpc ip resource(eni ip limit): unknown instance type"
)

Variables

View Source
var (

	// ErrENINotFound is an error when ENI is not found.
	ErrENINotFound = errors.New("ENI is not found")
	// ErrAllSecondaryIPsNotFound is returned when not all secondary IPs on an ENI have been assigned
	ErrAllSecondaryIPsNotFound = errors.New("All secondary IPs not found")
	// ErrNoSecondaryIPsFound is returned when not all secondary IPs on an ENI have been assigned
	ErrNoSecondaryIPsFound = errors.New("No secondary IPs have been assigned to this ENI")
	// ErrNoNetworkInterfaces occurs when DescribeNetworkInterfaces(eniID) returns no network interfaces
	ErrNoNetworkInterfaces = errors.New("No network interfaces found for ENI")
	// ErrUnableToDetachENI is returned when the ENI cannot be detached from the instance
	ErrUnableToDetachENI = errors.New("unable to detach ENI from EC2 instance, giving up")
	// ErrENIAttachmentIdNotFound is returned when the ENI attachment ID is not found
	ErrENIAttachmentIdNotFound = errors.New("ENI attachment ID not found")
)

Functions

func IsNotFound added in v1.8.0

func IsNotFound(err error) bool

IsNotFound returns true if the error was caused by an AWS API 404 response. We implement a Custom IMDS Error, so need to use APIError instead of HTTP Response Error

func ValidSubnetTagsMatchingClusterName added in v1.22.0

func ValidSubnetTagsMatchingClusterName(subnet ec2types.Subnet) bool

ValidSubnetForCluster checks if a subnet is valid for use by this cluster For secondary subnets, they must either have no cluster tags or have a matching cluster tag

Types

type APIs

type APIs interface {
	// AllocENI creates an ENI and attaches it to the instance
	AllocENI(ctx context.Context, sg []*string, eniCfgSubnet string, numIPs int, networkCard int) (eni string, err error)

	// FreeENI detaches ENI interface and deletes it
	FreeENI(ctx context.Context, eniName string) error

	// TagENI Tags ENI with current tags to contain expected tags.
	TagENI(ctx context.Context, eniID string, currentTags map[string]string) error

	// GetAttachedENIs retrieves eni information from instance metadata service
	GetAttachedENIs() (eniList []ENIMetadata, err error)

	// GetIPv4sFromEC2 returns the IPv4 addresses for a given ENI
	GetIPv4sFromEC2(ctx context.Context, eniID string) (addrList []ec2types.NetworkInterfacePrivateIpAddress, err error)

	// GetIPv4PrefixesFromEC2 returns the IPv4 prefixes for a given ENI
	GetIPv4PrefixesFromEC2(ctx context.Context, eniID string) (addrList []ec2types.Ipv4PrefixSpecification, err error)

	// GetIPv6PrefixesFromEC2 returns the IPv6 prefixes for a given ENI
	GetIPv6PrefixesFromEC2(ctx context.Context, eniID string) (addrList []ec2types.Ipv6PrefixSpecification, err error)

	// DescribeAllENIs calls EC2 and returns a fully populated DescribeAllENIsResult struct and an error
	DescribeAllENIs(ctx context.Context) (DescribeAllENIsResult, error)

	// AllocIPAddress allocates an IP address for an ENI
	AllocIPAddress(ctx context.Context, eniID string) error

	// AllocIPAddresses allocates numIPs IP addresses on a ENI
	AllocIPAddresses(ctx context.Context, eniID string, numIPs int) (*ec2.AssignPrivateIpAddressesOutput, error)

	// DeallocIPAddresses deallocates the list of IP addresses from a ENI
	DeallocIPAddresses(ctx context.Context, eniID string, ips []string) error

	// DeallocPrefixAddresses deallocates the list of IP addresses from a ENI
	DeallocPrefixAddresses(ctx context.Context, eniID string, ips []string) error

	// AllocIPv6Prefixes allocates IPv6 prefixes to the ENI passed in
	AllocIPv6Prefixes(ctx context.Context, eniID string) ([]*string, error)

	// GetVPCIPv4CIDRs returns VPC's IPv4 CIDRs from instance metadata
	GetVPCIPv4CIDRs() ([]string, error)

	// GetLocalIPv4 returns the primary IPv4 address on the primary ENI interface
	GetLocalIPv4() net.IP

	// GetLocalIPv6 returns the primary IPv6 address on the primary ENI interface
	GetLocalIPv6() net.IP

	// GetVPCIPv6CIDRs returns VPC's IPv6 CIDRs from instance metadata
	GetVPCIPv6CIDRs() ([]string, error)

	// GetPrimaryENI returns the primary ENI
	GetPrimaryENI() string

	// GetENIIPv4Limit return IP address limit per ENI based on EC2 instance type
	GetENIIPv4Limit() int

	// GetENILimit returns the number of ENIs that can be attached to an instance
	GetENILimit() int

	// GetNetworkCards returns the network cards the instance has
	GetNetworkCards() []vpc.NetworkCard

	// GetPrimaryENImac returns the mac address of the primary ENI
	GetPrimaryENImac() string

	// SetUnmanagedENIs sets the list of unmanaged ENI IDs
	SetUnmanagedENIs(eniIDs []string)

	// SetUnmanagedNetworkCards sets the list of unmanaged Network Cards
	SetUnmanagedNetworkCards(skipNetworkCards []bool)

	// Set EFAOnlyENIs
	SetEFAOnlyENIs(efaOnlyENIByNetworkCard []string)

	// IsUnmanagedENI checks if an ENI is unmanaged
	IsUnmanagedENI(eniID string) bool

	// IsUnmanagedNIC checks if an Network Card is unmanaged
	IsUnmanagedNIC(networkCard int) bool

	// IsEfaOnlyENI checks if an ENI is efa-only
	IsEfaOnlyENI(networkCard int, eni string) bool

	// WaitForENIAndIPsAttached waits until the ENI has been attached and the secondary IPs have been added
	WaitForENIAndIPsAttached(eni string, wantedSecondaryIPs int) (ENIMetadata, error)

	// IsPrimaryENI
	IsPrimaryENI(eniID string) bool

	// RefreshSGIDs
	RefreshSGIDs(ctx context.Context, mac string, ds *datastore.DataStoreAccess) error

	// RefreshCustomSGIDs discovers and refreshes security groups tagged with kubernetes.io/role/cni=1
	RefreshCustomSGIDs(ctx context.Context, dsAccess *datastore.DataStoreAccess) error

	// GetInstanceHypervisorFamily returns the hypervisor family for the instance
	GetInstanceHypervisorFamily() string

	// GetInstanceType returns the EC2 instance type
	GetInstanceType() string

	// Update cached prefix delegation flag
	InitCachedPrefixDelegation(bool)

	// GetInstanceID returns the instance ID
	GetInstanceID() string

	// FetchInstanceTypeLimits Verify if the InstanceNetworkingLimits has the ENI limits else make EC2 call to fill cache.
	FetchInstanceTypeLimits(ctx context.Context) error

	IsPrefixDelegationSupported() bool

	IsTrunkingCompatible() bool

	// GetENISubnetID gets the subnet ID for an ENI from AWS
	GetENISubnetID(ctx context.Context, eniID string) (string, error)

	// GetVpcSubnets returns all subnets in the VPC
	GetVpcSubnets(ctx context.Context) ([]ec2types.Subnet, error)

	// IsSubnetExcluded returns if a subnet is excluded for pod IPs based on its tags
	IsSubnetExcluded(ctx context.Context, subnetID string) (bool, error)
}

APIs defines interfaces calls for adding/getting/deleting ENIs/secondary IPs. The APIs are not thread-safe.

type CustomRequestFailure added in v1.19.4

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

Custom error type

func (*CustomRequestFailure) Error added in v1.19.4

func (e *CustomRequestFailure) Error() string

func (*CustomRequestFailure) ErrorCode added in v1.19.4

func (e *CustomRequestFailure) ErrorCode() string

func (*CustomRequestFailure) ErrorFault added in v1.19.4

func (e *CustomRequestFailure) ErrorFault() smithy.ErrorFault

func (*CustomRequestFailure) ErrorMessage added in v1.19.4

func (e *CustomRequestFailure) ErrorMessage() string

func (*CustomRequestFailure) HTTPStatusCode added in v1.19.4

func (e *CustomRequestFailure) HTTPStatusCode() int

func (*CustomRequestFailure) RequestID added in v1.19.4

func (e *CustomRequestFailure) RequestID() string

type DescribeAllENIsResult added in v1.7.6

type DescribeAllENIsResult struct {
	ENIMetadata             []ENIMetadata
	TagMap                  map[string]TagMap
	TrunkENI                string
	EFAENIs                 map[string]bool
	EFAOnlyENIByNetworkCard []string
	ENIsByNetworkCard       [][]string
}

DescribeAllENIsResult contains the fully

type EC2InstanceMetadataCache

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

EC2InstanceMetadataCache caches instance metadata

func New

func New(ctx context.Context, useSubnetDiscovery, useCustomNetworking, disableLeakedENICleanup, v4Enabled, v6Enabled bool) (*EC2InstanceMetadataCache, error)

New creates an EC2InstanceMetadataCache

func (*EC2InstanceMetadataCache) AllocENI

func (cache *EC2InstanceMetadataCache) AllocENI(ctx context.Context, sg []*string, eniCfgSubnet string, numIPs int, networkCard int) (string, error)

AllocENI creates an ENI and attaches it to the instance returns: newly created ENI ID

func (*EC2InstanceMetadataCache) AllocIPAddress

func (cache *EC2InstanceMetadataCache) AllocIPAddress(ctx context.Context, eniID string) error

AllocIPAddress allocates an IP address for an ENI

func (*EC2InstanceMetadataCache) AllocIPAddresses added in v1.1.0

func (cache *EC2InstanceMetadataCache) AllocIPAddresses(ctx context.Context, eniID string, numIPs int) (*ec2.AssignPrivateIpAddressesOutput, error)

AllocIPAddresses allocates numIPs of IP address on an ENI

func (*EC2InstanceMetadataCache) AllocIPv6Prefixes added in v1.10.0

func (cache *EC2InstanceMetadataCache) AllocIPv6Prefixes(ctx context.Context, eniID string) ([]*string, error)

func (*EC2InstanceMetadataCache) DeallocIPAddresses added in v1.5.0

func (cache *EC2InstanceMetadataCache) DeallocIPAddresses(ctx context.Context, eniID string, ips []string) error

DeallocIPAddresses frees IP address on an ENI

func (*EC2InstanceMetadataCache) DeallocPrefixAddresses added in v1.9.0

func (cache *EC2InstanceMetadataCache) DeallocPrefixAddresses(ctx context.Context, eniID string, prefixes []string) error

DeallocPrefixAddresses frees Prefixes on an ENI (supports both IPv4 and IPv6)

func (*EC2InstanceMetadataCache) DescribeAllENIs added in v1.6.1

func (cache *EC2InstanceMetadataCache) DescribeAllENIs(ctx context.Context) (DescribeAllENIsResult, error)

DescribeAllENIs calls EC2 to refresh the ENIMetadata and tags for all attached ENIs

func (*EC2InstanceMetadataCache) FetchInstanceTypeLimits added in v1.9.1

func (cache *EC2InstanceMetadataCache) FetchInstanceTypeLimits(ctx context.Context) error

func (*EC2InstanceMetadataCache) FreeENI

func (cache *EC2InstanceMetadataCache) FreeENI(ctx context.Context, eniName string) error

FreeENI detaches and deletes the ENI interface

func (*EC2InstanceMetadataCache) GetAttachedENIs

func (cache *EC2InstanceMetadataCache) GetAttachedENIs() (eniList []ENIMetadata, err error)

GetAttachedENIs retrieves ENI information from meta data service

func (*EC2InstanceMetadataCache) GetENIIPv4Limit added in v1.6.4

func (cache *EC2InstanceMetadataCache) GetENIIPv4Limit() int

GetENIIPv4Limit return IP address limit per ENI based on EC2 instance type

func (*EC2InstanceMetadataCache) GetENILimit

func (cache *EC2InstanceMetadataCache) GetENILimit() int

GetENILimit returns the number of ENIs can be attached to an instance

func (*EC2InstanceMetadataCache) GetENISubnetID added in v1.22.0

func (cache *EC2InstanceMetadataCache) GetENISubnetID(ctx context.Context, eniID string) (string, error)

GetENISubnetID gets the subnet ID for an ENI from AWS

func (*EC2InstanceMetadataCache) GetIPv4PrefixesFromEC2 added in v1.9.0

func (cache *EC2InstanceMetadataCache) GetIPv4PrefixesFromEC2(ctx context.Context, eniID string) (addrList []ec2types.Ipv4PrefixSpecification, err error)

GetIPv4PrefixesFromEC2 calls EC2 and returns a list of all addresses on the ENI

func (*EC2InstanceMetadataCache) GetIPv4sFromEC2 added in v1.6.1

func (cache *EC2InstanceMetadataCache) GetIPv4sFromEC2(ctx context.Context, eniID string) (addrList []ec2types.NetworkInterfacePrivateIpAddress, err error)

GetIPv4sFromEC2 calls EC2 and returns a list of all addresses on the ENI

func (*EC2InstanceMetadataCache) GetIPv6PrefixesFromEC2 added in v1.10.0

func (cache *EC2InstanceMetadataCache) GetIPv6PrefixesFromEC2(ctx context.Context, eniID string) (addrList []ec2types.Ipv6PrefixSpecification, err error)

GetIPv6PrefixesFromEC2 calls EC2 and returns a list of all addresses on the ENI

func (*EC2InstanceMetadataCache) GetInstanceHypervisorFamily added in v1.9.0

func (cache *EC2InstanceMetadataCache) GetInstanceHypervisorFamily() string

GetInstanceHypervisorFamily returns hypervisor of EC2 instance type

func (*EC2InstanceMetadataCache) GetInstanceID added in v1.9.1

func (cache *EC2InstanceMetadataCache) GetInstanceID() string

GetInstanceID returns the instance ID

func (*EC2InstanceMetadataCache) GetInstanceType added in v1.9.0

func (cache *EC2InstanceMetadataCache) GetInstanceType() string

GetInstanceType return EC2 instance type

func (*EC2InstanceMetadataCache) GetLocalIPv4

func (cache *EC2InstanceMetadataCache) GetLocalIPv4() net.IP

GetLocalIPv4 returns the primary IP address on the primary interface

func (*EC2InstanceMetadataCache) GetLocalIPv6 added in v1.20.0

func (cache *EC2InstanceMetadataCache) GetLocalIPv6() net.IP

GetLocalIPv4 returns the primary IP address on the primary interface

func (*EC2InstanceMetadataCache) GetNetworkCards added in v1.16.4

func (cache *EC2InstanceMetadataCache) GetNetworkCards() []vpc.NetworkCard

GetNetworkCards returns the network cards the instance has

func (*EC2InstanceMetadataCache) GetPrimaryENI

func (cache *EC2InstanceMetadataCache) GetPrimaryENI() string

GetPrimaryENI returns the primary ENI

func (*EC2InstanceMetadataCache) GetPrimaryENImac added in v1.2.1

func (cache *EC2InstanceMetadataCache) GetPrimaryENImac() string

GetPrimaryENImac returns the mac address of primary eni

func (*EC2InstanceMetadataCache) GetVPCIPv4CIDRs added in v1.3.0

func (cache *EC2InstanceMetadataCache) GetVPCIPv4CIDRs() ([]string, error)

GetVPCIPv4CIDRs returns VPC CIDRs

func (*EC2InstanceMetadataCache) GetVPCIPv6CIDRs added in v1.10.0

func (cache *EC2InstanceMetadataCache) GetVPCIPv6CIDRs() ([]string, error)

GetVPCIPv6CIDRs returns VPC CIDRs

func (*EC2InstanceMetadataCache) GetVpcSubnets added in v1.22.0

func (cache *EC2InstanceMetadataCache) GetVpcSubnets(ctx context.Context) ([]ec2types.Subnet, error)

func (*EC2InstanceMetadataCache) InitCachedPrefixDelegation added in v1.9.0

func (cache *EC2InstanceMetadataCache) InitCachedPrefixDelegation(enablePrefixDelegation bool)

func (*EC2InstanceMetadataCache) IsEfaOnlyENI added in v1.20.0

func (cache *EC2InstanceMetadataCache) IsEfaOnlyENI(networkCardIndex int, eniID string) bool

IsEfaOnlyENI the efaOnlyENI

func (*EC2InstanceMetadataCache) IsInstanceBareMetal added in v1.10.3

func (cache *EC2InstanceMetadataCache) IsInstanceBareMetal() bool

IsInstanceBareMetal derives bare metal value of the instance

func (*EC2InstanceMetadataCache) IsPrefixDelegationSupported added in v1.10.3

func (cache *EC2InstanceMetadataCache) IsPrefixDelegationSupported() bool

IsPrefixDelegationSupported return true if the instance type supports Prefix Assignment/Delegation

func (*EC2InstanceMetadataCache) IsPrimaryENI added in v1.10.0

func (cache *EC2InstanceMetadataCache) IsPrimaryENI(eniID string) bool

IsPrimaryENI returns if the eni is unmanaged

func (*EC2InstanceMetadataCache) IsSubnetExcluded added in v1.22.0

func (cache *EC2InstanceMetadataCache) IsSubnetExcluded(ctx context.Context, subnetID string) (bool, error)

IsSubnetExcluded checks if a subnet is excluded by examining its kubernetes.io/role/cni tag

func (*EC2InstanceMetadataCache) IsTrunkingCompatible added in v1.20.4

func (cache *EC2InstanceMetadataCache) IsTrunkingCompatible() bool

IsTrunkingCompatible return true if the instance type supports ENI trunking or not exist in the list

func (*EC2InstanceMetadataCache) IsUnmanagedENI added in v1.7.2

func (cache *EC2InstanceMetadataCache) IsUnmanagedENI(eniID string) bool

IsUnmanagedENI returns if the eni is unmanaged

func (*EC2InstanceMetadataCache) IsUnmanagedNIC added in v1.20.0

func (cache *EC2InstanceMetadataCache) IsUnmanagedNIC(networkCardIndex int) bool

IsUnmanagedENI returns if the eni is unmanaged

func (*EC2InstanceMetadataCache) RefreshCustomSGIDs added in v1.22.0

func (cache *EC2InstanceMetadataCache) RefreshCustomSGIDs(ctx context.Context, dsAccess *datastore.DataStoreAccess) error

RefreshCustomSGIDs discovers and refreshes security groups tagged for use with the CNI

func (*EC2InstanceMetadataCache) RefreshSGIDs added in v1.7.10

func (cache *EC2InstanceMetadataCache) RefreshSGIDs(ctx context.Context, mac string, dsAccess *datastore.DataStoreAccess) error

RefreshSGIDs retrieves security groups

func (*EC2InstanceMetadataCache) SetEFAOnlyENIs added in v1.20.0

func (cache *EC2InstanceMetadataCache) SetEFAOnlyENIs(efaOnlyENIByNetworkCard []string)

SetEfaOnlyENIsByNetworkCards

func (*EC2InstanceMetadataCache) SetUnmanagedENIs added in v1.7.2

func (cache *EC2InstanceMetadataCache) SetUnmanagedENIs(eniIDs []string)

SetUnmanagedENIs Set unmanaged ENI set

func (*EC2InstanceMetadataCache) SetUnmanagedNetworkCards added in v1.20.0

func (cache *EC2InstanceMetadataCache) SetUnmanagedNetworkCards(skipNetworkCards []bool)

SetUnmanagedENIs Set unmanaged ENI set

func (*EC2InstanceMetadataCache) TagENI added in v1.8.0

func (cache *EC2InstanceMetadataCache) TagENI(ctx context.Context, eniID string, currentTags map[string]string) error

func (*EC2InstanceMetadataCache) WaitForENIAndIPsAttached added in v1.7.2

func (cache *EC2InstanceMetadataCache) WaitForENIAndIPsAttached(eni string, wantedCidrs int) (eniMetadata ENIMetadata, err error)

WaitForENIAndIPsAttached waits until the ENI has been attached and the secondary IPs have been added

type EC2MetadataIface added in v1.8.0

type EC2MetadataIface interface {
	GetMetadata(ctx context.Context, params *imds.GetMetadataInput, optFns ...func(*imds.Options)) (*imds.GetMetadataOutput, error)
}

EC2MetadataIface is a subset of the EC2Metadata API.

type ENIMetadata

type ENIMetadata struct {
	// ENIID is the id of network interface
	ENIID string

	// MAC is the mac address of network interface
	MAC string

	// DeviceNumber is the  device number of network interface
	DeviceNumber int // 0 means it is primary interface

	// SubnetIPv4CIDR is the IPv4 CIDR of network interface
	SubnetIPv4CIDR string

	// SubnetIPv6CIDR is the IPv6 CIDR of network interface
	SubnetIPv6CIDR string

	// The ip addresses allocated for the network interface
	IPv4Addresses []ec2types.NetworkInterfacePrivateIpAddress

	// IPv4 Prefixes allocated for the network interface
	IPv4Prefixes []ec2types.Ipv4PrefixSpecification

	// IPv6 addresses allocated for the network interface
	IPv6Addresses []ec2types.NetworkInterfaceIpv6Address

	// IPv6 Prefixes allocated for the network interface
	IPv6Prefixes []ec2types.Ipv6PrefixSpecification

	// Network card the ENI is attached on
	NetworkCard int

	// SubnetID the ENI is created from
	SubnetID string
}

ENIMetadata contains information about an ENI

func (ENIMetadata) PrimaryIPv4Address added in v1.6.1

func (eni ENIMetadata) PrimaryIPv4Address() string

PrimaryIPv4Address returns the primary IPv4 address of this node

func (ENIMetadata) PrimaryIPv6Address added in v1.16.0

func (eni ENIMetadata) PrimaryIPv6Address() string

PrimaryIPv6Address returns the primary IPv6 address of this node

type FakeIMDS added in v1.8.0

type FakeIMDS map[string]interface{}

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

func (FakeIMDS) GetMetadata added in v1.19.4

func (f FakeIMDS) GetMetadata(ctx context.Context, params *imds.GetMetadataInput, optFns ...func(*imds.Options)) (*imds.GetMetadataOutput, error)

func (FakeIMDS) GetMetadataWithContext added in v1.8.0

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

GetMetadataWithContext implements the EC2MetadataIface interface.

type StringSet added in v1.6.4

type StringSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

StringSet is a set of strings

func (*StringSet) Difference added in v1.6.4

func (ss *StringSet) Difference(other *StringSet) *StringSet

Difference compares this StringSet with another

func (*StringSet) Has added in v1.7.2

func (ss *StringSet) Has(item string) bool

Has returns true if the StringSet contains the string

func (*StringSet) Set added in v1.6.4

func (ss *StringSet) Set(items []string)

Set sets the string set

func (*StringSet) SortedList added in v1.6.4

func (ss *StringSet) SortedList() []string

SortedList returns a sorted string slice from this set

type TagMap added in v1.6.1

type TagMap map[string]string

TagMap keeps track of the EC2 tags on each ENI

type TypedIMDS added in v1.8.0

type TypedIMDS struct {
	EC2MetadataIface
}

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

func (TypedIMDS) GetAZ added in v1.8.0

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

GetAZ returns the Availability Zone in which the instance launched.

func (TypedIMDS) GetDeviceNumber added in v1.8.0

func (typedimds 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) GetIPv4Prefixes added in v1.10.0

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

GetIPv4Prefixes returns the IPv4 prefixes delegated to this interface

func (TypedIMDS) GetIPv6Prefixes added in v1.10.0

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

GetIPv6Prefixes returns the IPv6 prefixes delegated to this interface

func (TypedIMDS) GetIPv6s added in v1.8.0

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

GetIPv6s returns the IPv6 addresses associated with the interface.

func (TypedIMDS) GetInstanceID added in v1.8.0

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

GetInstanceID returns the ID of this instance.

func (TypedIMDS) GetInstanceType added in v1.8.0

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

GetInstanceType returns the type of this instance.

func (TypedIMDS) GetInterfaceID added in v1.8.0

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

GetInterfaceID returns the ID of the network interface.

func (TypedIMDS) GetLocalIPv4 added in v1.8.0

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

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

func (TypedIMDS) GetLocalIPv4s added in v1.8.0

func (typedimds 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) GetLocalIPv6 added in v1.20.0

func (typedimds TypedIMDS) GetLocalIPv6(ctx context.Context) (net.IP, error)

GetLocalIPv6 returns the IPv6 addresses associated with the primary interface.

func (TypedIMDS) GetLocalIPv6s added in v1.20.0

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

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

func (TypedIMDS) GetMAC added in v1.8.0

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

GetMAC returns the first/primary network interface mac address.

func (TypedIMDS) GetMACImdsFields added in v1.18.5

func (typedimds TypedIMDS) GetMACImdsFields(ctx context.Context, mac string) ([]string, error)

GetMACImdsFields returns the imds fields present for a MAC

func (TypedIMDS) GetMACs added in v1.8.0

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

GetMACs returns the interface addresses attached to the instance.

func (TypedIMDS) GetNetworkCard added in v1.19.6

func (typedimds TypedIMDS) GetNetworkCard(ctx context.Context, mac string) (int, error)

GetNetworkCard returns the Network card the interface is attached on

func (TypedIMDS) GetSecurityGroupIDs added in v1.8.0

func (typedimds 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 added in v1.8.0

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

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

func (TypedIMDS) GetSubnetIPv4CIDRBlock added in v1.8.0

func (typedimds 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 added in v1.10.0

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

GetSubnetIPv6CIDRBlocks returns the IPv6 CIDR block for the subnet in which the interface resides.

func (TypedIMDS) GetVPCIPv4CIDRBlocks added in v1.8.0

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

GetVPCIPv4CIDRBlocks returns the IPv4 CIDR blocks for the VPC.

func (TypedIMDS) GetVPCIPv6CIDRBlocks added in v1.8.0

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

GetVPCIPv6CIDRBlocks returns the IPv6 CIDR blocks for the VPC.

func (TypedIMDS) GetVpcID added in v1.18.0

func (typedimds TypedIMDS) GetVpcID(ctx context.Context, mac string) (string, error)

Directories

Path Synopsis
Package mock_awsutils is a generated GoMock package.
Package mock_awsutils is a generated GoMock package.

Jump to

Keyboard shortcuts

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