ec2metadata

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// SpotInstanceActionPath is the context path to spot/instance-action within IMDS
	SpotInstanceActionPath = "/latest/meta-data/spot/instance-action"
	// ScheduledEventPath is the context path to events/maintenance/scheduled within IMDS
	ScheduledEventPath = "/latest/meta-data/events/maintenance/scheduled"
	// RebalanceRecommendationPath is the context path to events/recommendations/rebalance within IMDS
	RebalanceRecommendationPath = "/latest/meta-data/events/recommendations/rebalance"
	// InstanceIDPath path to instance id
	InstanceIDPath = "/latest/meta-data/instance-id"
	// InstanceLifeCycle path to instance life cycle
	InstanceLifeCycle = "/latest/meta-data/instance-life-cycle"
	// InstanceTypePath path to instance type
	InstanceTypePath = "/latest/meta-data/instance-type"
	// PublicHostnamePath path to public hostname
	PublicHostnamePath = "/latest/meta-data/public-hostname"
	// PublicIPPath path to public ip
	PublicIPPath = "/latest/meta-data/public-ipv4"
	// LocalHostnamePath path to local hostname
	LocalHostnamePath = "/latest/meta-data/local-hostname"
	// LocalIPPath path to local ip
	LocalIPPath = "/latest/meta-data/local-ipv4"
	// AZPlacementPath path to availability zone placement
	AZPlacementPath = "/latest/meta-data/placement/availability-zone"
	// IdentityDocPath is the path to the instance identity document
	IdentityDocPath = "/latest/dynamic/instance-identity/document"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceAction

type InstanceAction struct {
	Action string `json:"action"`
	Time   string `json:"time"`
}

InstanceAction metadata structure for json parsing

type NodeMetadata added in v1.3.0

type NodeMetadata struct {
	AccountId         string `json:"accountId"`
	InstanceID        string `json:"instanceId"`
	InstanceLifeCycle string `json:"instanceLifeCycle"`
	InstanceType      string `json:"instanceType"`
	PublicHostname    string `json:"publicHostname"`
	PublicIP          string `json:"publicIp"`
	LocalHostname     string `json:"localHostname"`
	LocalIP           string `json:"privateIp"`
	AvailabilityZone  string `json:"availabilityZone"`
	Region            string `json:"region"`
}

NodeMetadata contains information that applies to every drain event

type RebalanceRecommendation added in v1.10.0

type RebalanceRecommendation struct {
	NoticeTime string `json:"noticeTime"`
}

RebalanceRecommendation metadata structure for json parsing

type ScheduledEventDetail added in v1.2.0

type ScheduledEventDetail struct {
	NotBefore   string `json:"NotBefore"`
	Code        string `json:"Code"`
	Description string `json:"Description"`
	EventID     string `json:"EventId"`
	NotAfter    string `json:"NotAfter"`
	State       string `json:"State"`
}

ScheduledEventDetail metadata structure for json parsing

type Service added in v1.3.0

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

Service is used to query the EC2 instance metadata service v1 and v2

func New added in v1.3.0

func New(metadataURL string, tries int) *Service

New constructs an instance of the Service client

func (*Service) GetMetadataInfo added in v1.3.0

func (e *Service) GetMetadataInfo(path string) (info string, err error)

GetMetadataInfo generic function for retrieving ec2 metadata

func (*Service) GetNodeMetadata added in v1.3.0

func (e *Service) GetNodeMetadata() NodeMetadata

GetNodeMetadata attempts to gather additional ec2 instance information from the metadata service

func (*Service) GetRebalanceRecommendationEvent added in v1.10.0

func (e *Service) GetRebalanceRecommendationEvent() (rebalanceRec *RebalanceRecommendation, err error)

GetRebalanceRecommendationEvent retrieves rebalance recommendation events from imds

func (*Service) GetScheduledMaintenanceEvents added in v1.3.0

func (e *Service) GetScheduledMaintenanceEvents() ([]ScheduledEventDetail, error)

GetScheduledMaintenanceEvents retrieves EC2 scheduled maintenance events from imds

func (*Service) GetSpotITNEvent added in v1.3.0

func (e *Service) GetSpotITNEvent() (instanceAction *InstanceAction, err error)

GetSpotITNEvent retrieves EC2 spot interruption events from imds

func (*Service) Request added in v1.3.0

func (e *Service) Request(contextPath string) (*http.Response, error)

Request sends an http request to IMDSv1 or v2 at the specified path It is up to the caller to handle http status codes on the response An error will only be returned if the request is unable to be made

Jump to

Keyboard shortcuts

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