Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubnetFullErrMsgStr = "There aren't sufficient free Ipv4 addresses or prefixes"

	// InsufficientPrefixesInSubnetStr AWS error code for insufficient /28 prefixes in a subnet, possibly due to
	// fragmentation
	InsufficientPrefixesInSubnetStr = "InsufficientCidrBlocks"

	// InvalidParameterValueStr sort of catch-all error code from AWS to indicate request params are invalid. Often,
	// requires looking at the error message to get the actual reason. See SubnetFullErrMsgStr for example.
	InvalidParameterValueStr = "InvalidParameterValue"

	// OperationNotPermittedStr indicates the request returned too many results without sufficient filtering or pagination
	OperationNotPermittedStr = "OperationNotPermitted"

	AssignPrivateIpAddresses        = "AssignPrivateIpAddresses"
	AssignIPv6Addresses             = "AssignIPv6Addresses"
	AssociateAddress                = "AssociateAddress"
	AttachNetworkInterface          = "AttachNetworkInterface"
	CreateNetworkInterface          = "CreateNetworkInterface"
	DeleteNetworkInterface          = "DeleteNetworkInterface"
	DescribeAddresses               = "DescribeAddresses"
	DescribeInstances               = "DescribeInstances"
	DescribeInstanceTypes           = "DescribeInstanceTypes"
	DescribeNetworkInterfaces       = "DescribeNetworkInterfaces"
	DescribeSecurityGroups          = "DescribeSecurityGroups"
	DescribeSubnets                 = "DescribeSubnets"
	DescribeVpcs                    = "DescribeVpcs"
	DescribeRouteTables             = "DescribeRouteTables"
	ModifyNetworkInterface          = "ModifyNetworkInterface"
	ModifyNetworkInterfaceAttribute = "ModifyNetworkInterfaceAttribute"
	UnassignPrivateIpAddresses      = "UnassignPrivateIpAddresses"
)

Variables

This section is empty.

Functions

func DetectEKSClusterName

func DetectEKSClusterName(ctx context.Context, cfg aws.Config) (string, error)

func MergeTags

func MergeTags(tagMaps ...map[string]string) map[string]string

MergeTags merges all tags into a newly created map. Duplicate tags are overwritten by rightmost argument.

func NewConfig

func NewConfig(ctx context.Context) (aws.Config, error)

NewConfig returns a new aws.Config configured with the correct region

func NewSubnetsFilters

func NewSubnetsFilters(tags map[string]string, ids []string) []ec2_types.Filter

NewSubnetsFilters transforms a map of tags and values and a slice of subnets into a slice of ec2.Filter adequate to filter AWS subnets.

func NewTagsFilter

func NewTagsFilter(tags map[string]string) []ec2_types.Filter

NewTagsFilter transforms a map of tags and values into a slice of ec2.Filter adequate to filter resources based on tags.

Types

type Client

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

Client represents an EC2 API client

func NewClient

func NewClient(logger *slog.Logger, ec2Client *ec2.Client, metrics MetricsAPI, rateLimit float64, burst int, subnetsFilters, instancesFilters []ec2_types.Filter, eniTags map[string]string, usePrimary bool, maxResultsPerCall int32) *Client

NewClient returns a new EC2 client

func (*Client) AssignENIIPv6Prefix

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

AssignENIIPv6Prefix assigns one IPv6 prefix to the ENI. One AWS IPv6 Prefix has 2^48 addresses which is enormous.

func (*Client) AssignENIPrefixes

func (c *Client) AssignENIPrefixes(ctx context.Context, eniID string, prefixes int32) error

func (*Client) AssignPrivateIpAddresses

func (c *Client) AssignPrivateIpAddresses(ctx context.Context, eniID string, addresses int32) ([]string, error)

AssignPrivateIpAddresses assigns the specified number of secondary IP addresses

func (*Client) AssociateEIP

func (c *Client) AssociateEIP(ctx context.Context, eniID string, eipTags ipamTypes.Tags) (string, error)

AssociateEIP tries to find an Elastic IP Address with the given tags and associates it with the given instance

func (*Client) AttachNetworkInterface

func (c *Client) AttachNetworkInterface(ctx context.Context, index int32, instanceID, eniID string) (string, error)

AttachNetworkInterface attaches a previously created ENI to an instance

func (*Client) CreateNetworkInterface

func (c *Client) CreateNetworkInterface(ctx context.Context, toAllocate int32, subnetID, desc string, groups []string, allocatePrefixes, allocateIPv6 bool) (string, *types.ENI, error)

CreateNetworkInterface creates an ENI with the given parameters

func (*Client) DeleteNetworkInterface

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

DeleteNetworkInterface deletes an ENI with the specified ID

func (*Client) GetDetachedNetworkInterfaces

func (c *Client) GetDetachedNetworkInterfaces(ctx context.Context, tags ipamTypes.Tags, maxResults int32) ([]string, error)

func (*Client) GetInstance

func (c *Client) GetInstance(ctx context.Context, vpcs ipamTypes.VirtualNetworkMap, subnets ipamTypes.SubnetMap, instanceID string) (*ipamTypes.Instance, error)

GetInstance returns the instance including its ENIs by the given instanceID

func (*Client) GetInstanceTypes

func (c *Client) GetInstanceTypes(ctx context.Context) ([]ec2_types.InstanceTypeInfo, error)

GetInstanceTypes returns all the known EC2 instance types in the configured region

func (*Client) GetInstances

GetInstances returns the list of all instances including their ENIs as instanceMap

func (*Client) GetRouteTables

func (c *Client) GetRouteTables(ctx context.Context, vpcID string) (ipamTypes.RouteTableMap, error)

GetRouteTables returns the route tables in the vpcID, or all route tables if the vpcID is empty.

func (*Client) GetSecurityGroups

func (c *Client) GetSecurityGroups(ctx context.Context, vpcID string) (types.SecurityGroupMap, error)

GetSecurityGroups returns the security groups in the vpcID, or all security groups if the vpcID is empty.

func (*Client) GetSubnets

func (c *Client) GetSubnets(ctx context.Context, vpcID string) (ipamTypes.SubnetMap, error)

GetSubnets returns the subnets in the vpcID, or all subnets if the vpcID is empty.

func (*Client) GetVpcs

func (c *Client) GetVpcs(ctx context.Context, vpcID string) (ipamTypes.VirtualNetworkMap, error)

GetVpcs retrieves and returns the VPC based on vpcID, or all VPCs if the vpcID is empty.

func (*Client) ModifyNetworkInterface

func (c *Client) ModifyNetworkInterface(ctx context.Context, eniID, attachmentID string, deleteOnTermination bool) error

ModifyNetworkInterface modifies the attributes of an ENI

func (*Client) UnassignENIPrefixes

func (c *Client) UnassignENIPrefixes(ctx context.Context, eniID string, prefixes []string) error

func (*Client) UnassignPrivateIpAddresses

func (c *Client) UnassignPrivateIpAddresses(ctx context.Context, eniID string, addresses []string) error

UnassignPrivateIpAddresses unassigns specified IP addresses from ENI

type MetricsAPI

type MetricsAPI interface {
	helpers.MetricsAPI
	ObserveAPICall(call, status string, duration float64)
}

MetricsAPI represents the metrics maintained by the AWS API client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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