ec2

package
v0.0.0-...-46749fd Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 17 Imported by: 7

Documentation

Overview

Package ec2 provides information when running in ec2

Index

Constants

This section is empty.

Variables

View Source
var (

	// CloudProviderName contains the inventory name of for EC2
	CloudProviderName = "AWS"
	// DMIBoardVendor contains the DMI board vendor for EC2
	DMIBoardVendor = "Amazon EC2"
)

declare these as vars not const to ease testing

Functions

func GetAccountID

func GetAccountID(_ context.Context) (string, error)

GetAccountID returns the account ID of the current AWS instance

func GetClusterName

func GetClusterName(ctx context.Context) (string, error)

GetClusterName returns the name of the cluster containing the current EC2 instance

func GetHostAliases

func GetHostAliases(ctx context.Context) ([]string, error)

GetHostAliases returns the host aliases from the EC2 metadata API.

func GetHostID

func GetHostID(ctx context.Context) string

GetHostID returns the instanceID for the current EC2 host using IMDSv2 only.

func GetHostname

func GetHostname(ctx context.Context) (string, error)

GetHostname fetches the hostname for current host from the EC2 metadata API

func GetIDMSv2InstanceID

func GetIDMSv2InstanceID(ctx context.Context) (string, error)

GetIDMSv2InstanceID fetches the instance id for current host from the IMDSv2 EC2 metadata API

func GetInstanceID

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

GetInstanceID fetches the instance id for current host from the EC2 metadata API

func GetLegacyResolutionInstanceID

func GetLegacyResolutionInstanceID(ctx context.Context) (string, error)

GetLegacyResolutionInstanceID fetches the instance id for current host from the EC2 metadata API without using IMDSv2 or DMI (ie: only IMDSv1)

func GetNTPHosts added in v0.9.0

func GetNTPHosts(ctx context.Context) []string

GetNTPHosts returns the NTP hosts for EC2 if it is detected as the cloud provider, otherwise an empty array. Docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html#configure_ntp

func GetNetworkID

func GetNetworkID(ctx context.Context) (string, error)

GetNetworkID retrieves the network ID using the EC2 metadata endpoint. For EC2 instances, the the network ID is the VPC ID, if the instance is found to be a part of exactly one VPC.

func GetPublicIPv4 added in v0.9.0

func GetPublicIPv4(ctx context.Context) (string, error)

GetPublicIPv4 gets the public IPv4 for the currently running host using the EC2 metadata API.

func GetSourceName

func GetSourceName() string

GetSourceName returns the source used to pull information for EC2 (UUID, DMI, IMDSv1 or IMDSv2)

func GetTags

func GetTags(_ context.Context) ([]string, error)

GetTags grabs the host tags from the EC2 api

func IsDefaultHostname

func IsDefaultHostname(hostname string) bool

IsDefaultHostname returns whether the given hostname is a default one for EC2

func IsDefaultHostnameForIntake

func IsDefaultHostnameForIntake(hostname string) bool

IsDefaultHostnameForIntake returns whether the given hostname is a default one for EC2 for the intake

func IsRunningOn

func IsRunningOn(ctx context.Context) bool

IsRunningOn returns true if the agent is running on AWS

func IsWindowsDefaultHostname

func IsWindowsDefaultHostname(hostname string) bool

IsWindowsDefaultHostname returns whether the given hostname is a Windows default one for EC2 (starts with 'ec2amaz-')

Types

type Subnet added in v0.9.0

type Subnet struct {
	ID   string
	Cidr string
}

Subnet stores information about an AWS subnet

func GetSubnetForHardwareAddr added in v0.9.0

func GetSubnetForHardwareAddr(ctx context.Context, hwAddr net.HardwareAddr) (subnet Subnet, err error)

GetSubnetForHardwareAddr returns info about the subnet associated with a hardware address (mac address) on the current host

Jump to

Keyboard shortcuts

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