ec2

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMachineAMIOwnerID is a heptio/VMware owned account. Please see:
	// https://github.com/kubernetes-sigs/cluster-api-provider-aws/issues/487
	DefaultMachineAMIOwnerID = "258751437250"

	// DefaultAmiNameFormat is defined in the build/ directory of this project.
	// The pattern is:
	// 1. the string value `capa-ami-`
	// 2. the baseOS of the AMI, for example: ubuntu-18.04, centos-7, amazon-2
	// 3. the kubernetes version as defined by the packages produced by kubernetes/release with or without v as a prefix, for example: 1.13.0, 1.12.5-mybuild.1, v1.17.3
	// 4. a `-` followed by any additional characters
	DefaultAmiNameFormat = "capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*"
)

Variables

This section is empty.

Functions

func DefaultAMILookup added in v0.6.4

func DefaultAMILookup(ec2Client ec2iface.EC2API, ownerID, baseOS, kubernetesVersion, amiNameFormat string) (*ec2.Image, error)

func GenerateAmiName added in v0.6.5

func GenerateAmiName(amiNameFormat, baseOS, kubernetesVersion string) (string, error)

func GetLatestImage added in v0.6.5

func GetLatestImage(imgs []*ec2.Image) (*ec2.Image, error)

GetLatestImage assumes imgs is not empty. Responsibility of the caller to check.

Types

type AMILookup added in v0.5.4

type AMILookup struct {
	BaseOS     string
	K8sVersion string
}

AMILookup contains the parameters used to template AMI names used for lookup.

type Service

type Service struct {
	EC2Client ec2iface.EC2API

	// SSMClient is used to look up the official EKS AMI ID
	SSMClient ssmiface.SSMAPI
	// contains filtered or unexported fields
}

Service holds a collection of interfaces. The interfaces are broken down like this to group functions together. One alternative is to have a large list of functions from the ec2 client.

func NewService

func NewService(clusterScope scope.EC2Scope) *Service

NewService returns a new service given the ec2 api client.

func (*Service) CreateInstance

func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte) (*infrav1.Instance, error)

CreateInstance runs an ec2 instance.

func (*Service) CreateLaunchTemplate added in v0.6.1

func (s *Service) CreateLaunchTemplate(scope *scope.MachinePoolScope, imageID *string, userData []byte) (string, error)

CreateLaunchTemplate generates a launch template to be used with the autoscaling group

func (*Service) CreateLaunchTemplateVersion added in v0.6.1

func (s *Service) CreateLaunchTemplateVersion(scope *scope.MachinePoolScope, imageID *string, userData []byte) error

func (*Service) DeleteBastion

func (s *Service) DeleteBastion() error

DeleteBastion deletes the Bastion instance

func (*Service) DeleteLaunchTemplate added in v0.6.1

func (s *Service) DeleteLaunchTemplate(id string) error

DeleteLaunchTemplate delete a launch template

func (*Service) DetachSecurityGroupsFromNetworkInterface added in v0.4.1

func (s *Service) DetachSecurityGroupsFromNetworkInterface(groups []string, interfaceID string) error

DetachSecurityGroupsFromNetworkInterface looks up an ENI by interfaceID and detaches a list of Security Groups from that ENI.

func (*Service) DiscoverLaunchTemplateAMI added in v0.6.1

func (s *Service) DiscoverLaunchTemplateAMI(scope *scope.MachinePoolScope) (*string, error)

func (*Service) GetConsoleOutput

func (s *Service) GetConsoleOutput(instanceID string) (string, error)

GetConsoleOutput returns the latest console output of an instance

func (*Service) GetCoreNodeSecurityGroups added in v0.6.1

func (s *Service) GetCoreNodeSecurityGroups(scope *scope.MachinePoolScope) ([]string, error)

GetCoreSecurityGroups looks up the security group IDs managed by this actuator They are considered "core" to its proper functioning

func (*Service) GetCoreSecurityGroups

func (s *Service) GetCoreSecurityGroups(scope *scope.MachineScope) ([]string, error)

GetCoreSecurityGroups looks up the security group IDs managed by this actuator They are considered "core" to its proper functioning

func (*Service) GetFilteredSecurityGroupID added in v0.6.5

func (s *Service) GetFilteredSecurityGroupID(securityGroup infrav1.AWSResourceReference) (string, error)

GetFilteredSecurityGroupID get security group ID using filters

func (*Service) GetInstanceSecurityGroups

func (s *Service) GetInstanceSecurityGroups(instanceID string) (map[string][]string, error)

GetInstanceSecurityGroups returns a map from ENI id to the security groups applied to that ENI While some security group operations take place at the "instance" level, these are in fact an API convenience for manipulating the first ("primary") ENI's properties.

func (*Service) GetLaunchTemplate added in v0.6.1

func (s *Service) GetLaunchTemplate(launchTemplateName string) (*expinfrav1.AWSLaunchTemplate, string, error)

GetLaunchTemplate returns the existing LaunchTemplate or nothing if it doesn't exist. For now by name until we need the input to be something different

func (*Service) GetLaunchTemplateID added in v0.6.6

func (s *Service) GetLaunchTemplateID(launchTemplateName string) (string, error)

GetLaunchTemplateId returns the existing LaunchTemplateId or empty string if it doesn't exist.

func (*Service) GetRunningInstanceByTags

func (s *Service) GetRunningInstanceByTags(scope *scope.MachineScope) (*infrav1.Instance, error)

GetRunningInstanceByTags returns the existing instance or nothing if it doesn't exist.

func (*Service) InstanceIfExists

func (s *Service) InstanceIfExists(id *string) (*infrav1.Instance, error)

InstanceIfExists returns the existing instance or nothing if it doesn't exist.

func (*Service) LaunchTemplateNeedsUpdate added in v0.6.1

func (s *Service) LaunchTemplateNeedsUpdate(scope *scope.MachinePoolScope, incoming *expinfrav1.AWSLaunchTemplate, existing *expinfrav1.AWSLaunchTemplate) (bool, error)

LaunchTemplateNeedsUpdate checks if a new launch template version is needed.

FIXME(dlipovetsky): This check should account for changed userdata, but does not yet do so. Although userdata is stored in an EC2 Launch Template, it is not a field of AWSLaunchTemplate.

func (*Service) ReconcileBastion

func (s *Service) ReconcileBastion() error

ReconcileBastion ensures a bastion is created for the cluster

func (*Service) SDKToInstance

func (s *Service) SDKToInstance(v *ec2.Instance) (*infrav1.Instance, error)

SDKToInstance converts an AWS EC2 SDK instance to the CAPA instance type. SDKToInstance populates all instance fields except for rootVolumeSize, because EC2.DescribeInstances does not return the size of storage devices. An additional call to EC2 is required to get this value.

func (*Service) SDKToLaunchTemplate added in v0.6.1

func (s *Service) SDKToLaunchTemplate(d *ec2.LaunchTemplateVersion) (*expinfrav1.AWSLaunchTemplate, string, error)

SDKToLaunchTemplate converts an AWS EC2 SDK instance to the CAPA instance type.

func (*Service) TerminateInstance

func (s *Service) TerminateInstance(instanceID string) error

TerminateInstance terminates an EC2 instance. Returns nil on success, error in all other cases.

func (*Service) TerminateInstanceAndWait

func (s *Service) TerminateInstanceAndWait(instanceID string) error

TerminateInstanceAndWait terminates and waits for an EC2 instance to terminate.

func (*Service) UpdateInstanceSecurityGroups

func (s *Service) UpdateInstanceSecurityGroups(instanceID string, ids []string) error

UpdateInstanceSecurityGroups modifies the security groups of the given EC2 instance.

func (*Service) UpdateResourceTags

func (s *Service) UpdateResourceTags(resourceID *string, create, remove map[string]string) error

UpdateResourceTags updates the tags for an instance. This will be called if there is anything to create (update) or delete. We may not always have to perform each action, so we check what we're receiving to avoid calling AWS if we don't need to.

Directories

Path Synopsis
Run go generate to regenerate this mock.
Run go generate to regenerate this mock.

Jump to

Keyboard shortcuts

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