awsinstancetag

package module
v0.0.0-...-3bdb644 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package awsinstancetag helps retrieving data from AWS instance metadata.

This is oriented toward software configuration (not infrastructure checking or monitoring). Secrets must NOT be stored in metadata (not safe). Some methods require tags to be explicitly allowed in the instance options.

See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html and https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html

This is opinionated for a specific use:

It returns a custom error for common catch errors (Like "not on AWS" or "instance metadata not configured")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

Load gets instances metadata.

First, it gets the InstanceIdentityDocument for the InstanceID + region. Then it creates a new session with the region and finally it calls DescribeInstances.

It uses CreateEC2sDefault() if ec2s is null.

Types

type AWSEC2Service

type AWSEC2Service interface {
	DescribeInstances(input *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error)
}

func CreateEC2sDefault

func CreateEC2sDefault(region string) (AWSEC2Service, error)

type AWSInstanceMetadataService

type AWSInstanceMetadataService interface {
	GetInstanceIdentityDocument(ctx context.Context, params *imds.GetInstanceIdentityDocumentInput, optFns ...func(*imds.Options)) (*imds.GetInstanceIdentityDocumentOutput, error)
}

type ForbiddenInstanceTagReadingError

type ForbiddenInstanceTagReadingError struct {
	Err error
}

see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-options.html

func (ForbiddenInstanceTagReadingError) Error

func (ForbiddenInstanceTagReadingError) Unwrap

type UnreachableInstanceIdentityDocumentError

type UnreachableInstanceIdentityDocumentError struct {
	Err error
}

func (UnreachableInstanceIdentityDocumentError) Error

func (UnreachableInstanceIdentityDocumentError) Unwrap

Jump to

Keyboard shortcuts

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