aws

package
v0.20.9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EksaAwsCredentialsFileKey = "EKSA_AWS_CREDENTIALS_FILE"
	EksaAwsCABundlesFileKey   = "EKSA_AWS_CA_BUNDLES_FILE"
)

Variables

This section is empty.

Functions

func AwsCABundlesFile

func AwsCABundlesFile() (filePath string, err error)

func AwsCredentialsFile

func AwsCredentialsFile() (filePath string, err error)

func EncodeFileFromEnv

func EncodeFileFromEnv(envKey string) (string, error)

func LoadConfig

func LoadConfig(ctx context.Context, opts ...AwsConfigOpt) (aws.Config, error)

LoadConfig reads the optional aws configurations, and populates an AWS Config with the values from the configurations.

func NewEC2Client

func NewEC2Client(config aws.Config) *ec2.Client

NewEC2Client builds a new ec2 client.

func NewIMDSClient added in v0.14.2

func NewIMDSClient(config aws.Config) *imds.Client

NewIMDSClient builds a new imds client.

func NewSnowballClient added in v0.12.0

func NewSnowballClient(config aws.Config) *snowballdevice.Client

func ParseDeviceIPs

func ParseDeviceIPs(r io.Reader) ([]string, error)

func ParseDeviceIPsFromFile

func ParseDeviceIPsFromFile(filePath string) ([]string, error)

func SnowEndpointResolver

func SnowEndpointResolver(deviceIP string) aws.EndpointResolverWithOptionsFunc

Types

type AwsConfigOpt

type AwsConfigOpt = config.LoadOptionsFunc

func AwsConfigOptSet

func AwsConfigOptSet(opts ...AwsConfigOpt) AwsConfigOpt

func WithCustomCABundleFile

func WithCustomCABundleFile(certsFile string) AwsConfigOpt

WithCustomCABundleFile is a helper function to construct functional options that reads an aws certificates file and sets CustomCABundle on config's LoadOptions.

func WithSnowEndpointAccess

func WithSnowEndpointAccess(deviceIP string, certsFile, credsFile string) AwsConfigOpt

WithSnowEndpointAccess gathers all the config's LoadOptions for snow, which includes snowball ec2 endpoint, snow credentials for a specific profile, and CA bundles for accessing the https endpoint.

type Client

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

Client provides the single API client to make operations call to aws services.

func NewClient

func NewClient(opts ...ClientOpt) *Client

NewClient builds an aws Client.

func NewClientFromConfig added in v0.14.2

func NewClientFromConfig(cfg aws.Config) *Client

NewClientFromConfig builds an aws client with ec2 and snowballdevice apis from aws config.

func (*Client) BuildIMDS added in v0.14.2

func (c *Client) BuildIMDS(ctx context.Context) error

BuildIMDS builds or overrides the imds client in the Client with default aws config.

func (*Client) EC2ImageExists

func (c *Client) EC2ImageExists(ctx context.Context, imageID string) (bool, error)

EC2ImageExists calls aws sdk ec2.DescribeImages with filter imageID to fetch a specified images (AMIs, AKIs, and ARIs) available. Returns (false, nil) if the image does not exist, (true, nil) if image exists, and (false, err) if there is an non 400 status code error from ec2.DescribeImages.

func (*Client) EC2ImportKeyPair

func (c *Client) EC2ImportKeyPair(ctx context.Context, keyName string, keyMaterial []byte) error

EC2ImportKeyPair calls aws sdk ec2.ImportKeyPair to import a key pair to ec2.

func (*Client) EC2InstanceIP added in v0.14.2

func (c *Client) EC2InstanceIP(ctx context.Context) (string, error)

EC2InstanceIP calls aws sdk imds.GetMetadata with public-ipv4 path to fetch the instance ip from metadata service.

func (*Client) EC2InstanceTypes added in v0.14.2

func (c *Client) EC2InstanceTypes(ctx context.Context) ([]EC2InstanceType, error)

EC2InstanceTypes calls aws sdk ec2.DescribeInstanceTypes to get a list of supported instance type for a device.

func (*Client) EC2KeyNameExists

func (c *Client) EC2KeyNameExists(ctx context.Context, keyName string) (bool, error)

EC2KeyNameExists calls aws sdk ec2.DescribeKeyPairs with filter keyName to fetch a specified key pair available in aws. Returns (false, nil) if the key pair does not exist, (true, nil) if key pair exists, and (false, err) if there is an error from ec2.DescribeKeyPairs.

func (*Client) IsSnowballDeviceUnlocked added in v0.12.0

func (c *Client) IsSnowballDeviceUnlocked(ctx context.Context) (bool, error)

func (*Client) SnowballDeviceSoftwareVersion added in v0.12.0

func (c *Client) SnowballDeviceSoftwareVersion(ctx context.Context) (string, error)

type ClientOpt added in v0.14.2

type ClientOpt func(*Client)

ClientOpt updates an aws.Client.

func WithEC2 added in v0.14.2

func WithEC2(ec2 EC2Client) ClientOpt

WithEC2 returns a ClientOpt that sets the ec2 client.

func WithIMDS added in v0.14.2

func WithIMDS(imds IMDSClient) ClientOpt

WithIMDS returns a ClientOpt that sets the imds client.

func WithSnowballDevice added in v0.14.2

func WithSnowballDevice(snowballdevice SnowballDeviceClient) ClientOpt

WithSnowballDevice returns a ClientOpt that sets the snowballdevice client.

type Clients

type Clients map[string]*Client

Clients are a map between aws profile and its aws client.

func BuildClients added in v0.11.0

func BuildClients(ctx context.Context) (Clients, error)

type EC2Client

type EC2Client interface {
	DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
	DescribeKeyPairs(ctx context.Context, params *ec2.DescribeKeyPairsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeKeyPairsOutput, error)
	DescribeInstanceTypes(ctx context.Context, params *ec2.DescribeInstanceTypesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstanceTypesOutput, error)
	ImportKeyPair(ctx context.Context, params *ec2.ImportKeyPairInput, optFns ...func(*ec2.Options)) (*ec2.ImportKeyPairOutput, error)
}

EC2Client is an ec2 client that wraps around the aws sdk ec2 client.

type EC2InstanceType added in v0.14.2

type EC2InstanceType struct {
	Name        string
	DefaultVCPU *int32
}

EC2InstanceType has the information of an ec2 instance type.

type IMDSClient added in v0.14.2

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

IMDSClient is an imds client that wraps around the aws sdk imds client.

type ServiceEndpoint

type ServiceEndpoint struct {
	ServiceID     string
	URL           string
	SigningRegion string
}

type SnowballDeviceClient added in v0.12.0

type SnowballDeviceClient interface {
	DescribeDevice(ctx context.Context, params *snowballdevice.DescribeDeviceInput, optFns ...func(*snowballdevice.Options)) (*snowballdevice.DescribeDeviceOutput, error)
	DescribeDeviceSoftware(ctx context.Context, params *snowballdevice.DescribeDeviceSoftwareInput, optFns ...func(*snowballdevice.Options)) (*snowballdevice.DescribeDeviceSoftwareOutput, error)
}

Directories

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

Jump to

Keyboard shortcuts

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