aws

package
v0.0.0-...-17b5b8b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudFormationStackType  resourceType = "cloud formation stack"
	ELBType                  resourceType = "elb"
	HostedZoneType           resourceType = "hosted zone"
	InternetGatewayType      resourceType = "internet gateway"
	InstanceType             resourceType = "instance"
	LaunchConfigurationType  resourceType = "launch configuration"
	NatGatewayType           resourceType = "nat gateway"
	RouteTableType           resourceType = "route table"
	RouteType                resourceType = "route"
	SecurityGroupType        resourceType = "security group"
	SubnetType               resourceType = "subnet"
	VPCType                  resourceType = "vpc"
	VPCPeeringConnectionType resourceType = "vpc peering connection"
)
View Source
const (
	RequesterVpcFilterName = "requester-vpc-info.vpc-id"
	AccepterVpcFilterName  = "accepter-vpc-info.vpc-id"
)
View Source
const (
	RoleNameTemplate         = "EC2-K8S-Role"
	PolicyNameTemplate       = "EC2-K8S-Policy"
	ProfileNameTemplate      = "EC2-K8S-Role"
	AssumeRolePolicyDocument = `` /* 163-byte string literal not displayed */

	MasterPolicyDocumentTempl = `` /* 688-byte string literal not displayed */

	MasterPolicyType          = "master"
	WorkerPolicyDocumentTempl = `` /* 1038-byte string literal not displayed */

	WorkerPolicyType = "worker"
)
View Source
const (
	ASGMetricsGranularity = "1Minute"
)
View Source
const (
	AutoScalingGroupType resourceType = "auto scaling group"
)

Variables

This section is empty.

Functions

func IsAttributeEmpty

func IsAttributeEmpty(err error) bool

IsPortsToOpenEmpty asserts portsToOpenEmptyError.

func IsClientNotInitialized

func IsClientNotInitialized(err error) bool

IsClientNotInitialized asserts clientNotInitializedError.

func IsKMSKeyAliasEmpty

func IsKMSKeyAliasEmpty(err error) bool

IsKMSKeyAliasEmpty asserts kmsKeyAliasEmptyError.

func IsKeyPairCannotCreateAndNotFound

func IsKeyPairCannotCreateAndNotFound(err error) bool

IsKeyPairCannotCreateAndNotFound asserts keyPairCannotCreateAndNotFoundError.

func IsNoBucketInBucketObject

func IsNoBucketInBucketObject(err error) bool

IsNoBucketInBucketObject asserts noBucketInBucketObjectError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound asserts NotFoundError.

func IsNotImplementedMethod

func IsNotImplementedMethod(err error) bool

IsNotImplementedMethod asserts notImplementedMethodError.

func IsResourceDelete

func IsResourceDelete(err error) bool

IsResourceDelete asserts resourceDeleteError.

func IsTooManyResults

func IsTooManyResults(err error) bool

IsTooManyResults asserts tooManyResultsError.

func NewCustomExponentialBackoff

func NewCustomExponentialBackoff() *backoff.ExponentialBackOff

NewCustomExponentialBackoff returns pointer to a backoff.ExponentialBackOff, initialized with custom values. At the moment, we only override the MaxElapsedTime.

func NewNotify

func NewNotify(logger micrologger.Logger, operationName string) func(error, time.Duration)

Types

type ASGStack

type ASGStack struct {
	Client *cloudformation.CloudFormation

	// Settings.
	ASGMaxSize               int
	ASGMinSize               int
	ASGType                  string
	AssociatePublicIPAddress bool
	AvailabilityZone         string
	ClusterID                string
	HealthCheckGracePeriod   int
	IAMInstanceProfileName   string
	ImageID                  string
	LoadBalancerName         string
	InstanceType             string
	KeyName                  string
	Name                     string
	SecurityGroupID          string
	SmallCloudConfig         string
	SubnetID                 string
	// TemplateURL is the S3 URL where the CloudFormation template is stored.
	TemplateURL string
	VPCID       string
}

ASGStack represents a CloudFormation stack for an Auto Scaling Group.

func (*ASGStack) CheckIfExists

func (s *ASGStack) CheckIfExists() (bool, error)

CheckIfExists checks if there is an autoscaling group stack in Cloud Formation with the provided name.

func (*ASGStack) CreateOrFail

func (s *ASGStack) CreateOrFail() error

CreateOrFail creates the autoscaling group stack in Cloud Formation or returns the error.

func (*ASGStack) Delete

func (s *ASGStack) Delete() error

Delete deletes the autoscaling group stack in Cloud Formation.

func (*ASGStack) Update

func (s *ASGStack) Update() error

Update updates the autoscaling group stack in Cloud Formation if one of the updatable parameters has changed.

type AWSEntity

type AWSEntity struct {
	Clients     awsutil.Clients
	HostClients awsutil.Clients
}

type AutoScalingGroup

type AutoScalingGroup struct {
	// AvailabilityZone is the AZ the instances will be placed in.
	AvailabilityZone string
	// ClusterID is the ID of the cluster.
	ClusterID string
	// HealthCheckGracePeriod is the time, in seconds, that the instances are
	// given after boot before the healthchecks start.
	HealthCheckGracePeriod int
	// LaunchConfigurationName is the name of the Launch Configuration used for the instances.
	LaunchConfigurationName string
	// LoadBalancerName is the name of the existing ELB that will be placed in
	// the ASG to front the instances.
	LoadBalancerName string
	// MaxSize is the maximum amount of instances that will be created in this ASG.
	MaxSize int
	// MinSize is the minimum amount of instances in this ASG. There will never be
	// less than MinSize instances running.
	MinSize int
	// Name is the ASG name.
	Name string
	// VPCZoneIdentifier is the Subnet ID of the subnet the instances should be
	// placed in.
	VPCZoneIdentifier string

	// Dependencies.
	Client *autoscaling.AutoScaling
}

func (*AutoScalingGroup) CreateIfNotExists

func (asg *AutoScalingGroup) CreateIfNotExists() (bool, error)

func (*AutoScalingGroup) CreateOrFail

func (asg *AutoScalingGroup) CreateOrFail() error

func (*AutoScalingGroup) Delete

func (asg *AutoScalingGroup) Delete() error

func (*AutoScalingGroup) Update

func (asg *AutoScalingGroup) Update() error

type Bucket

type Bucket struct {
	Name string
	AWSEntity
}

func (*Bucket) CreateIfNotExists

func (b *Bucket) CreateIfNotExists() (bool, error)

func (*Bucket) CreateOrFail

func (b *Bucket) CreateOrFail() error

func (*Bucket) Delete

func (b *Bucket) Delete() error

type BucketObject

type BucketObject struct {
	AWSEntity
	Bucket *Bucket
	Data   string
	Name   string
}

func (*BucketObject) CreateIfNotExists

func (bo *BucketObject) CreateIfNotExists() (bool, error)

CreateIfNotExists is not implemeted because S3 overwrites bucket objects in case of name clashes. This means that a newer CloudConfig with the same name as an old one will always overwrite it. If we decide to use the S3 bucket for other types of files, we might have to revisit this.

func (*BucketObject) CreateOrFail

func (bo *BucketObject) CreateOrFail() error

func (*BucketObject) Delete

func (bo *BucketObject) Delete() error

type EC2StateCode

type EC2StateCode int
const (
	// http://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#InstanceState
	EC2PendingState      EC2StateCode = 0
	EC2RunningState      EC2StateCode = 16
	EC2ShuttingDownState EC2StateCode = 32
	EC2TerminatedState   EC2StateCode = 48
	EC2StoppingState     EC2StateCode = 64
	EC2StoppedState      EC2StateCode = 80
)

type ELB

type ELB struct {
	AZ     string
	Client *elb.ELB

	IdleTimeoutSeconds int
	Name               string
	PortsToOpen        PortPairs
	Scheme             string
	SecurityGroup      string
	SubnetID           string
	Tags               []string
	// contains filtered or unexported fields
}

ELB is an Elastic Load Balancer

func NewELBFromExisting

func NewELBFromExisting(name string, client *elb.ELB) (*ELB, error)

NewELBFromExisting initializes an ELB struct with some fields retrieved from the API, such as its FQDN and its Hosted Zone ID. We need these fields when deleting a Record Set. This method doesn't create a new ELB on AWS.

func (*ELB) AssignProxyProtocolPolicy

func (lb *ELB) AssignProxyProtocolPolicy() error

AssignProxyProtocolPolicy creates a ProxyProtocol policy and assigns it to the Load Balancer. This is needed for ELBs that listen/forward over TCP, in order to add a header with the address, port of the source and destination. Without this, `kubectl log/exec` don't work. See https://github.com/kubernetes/ingress/tree/4601775c18f5c6968e56e1eeaa26efc629590bb0/controllers/nginx#proxy-protocol

func (*ELB) CreateIfNotExists

func (lb *ELB) CreateIfNotExists() (bool, error)

func (*ELB) CreateOrFail

func (lb *ELB) CreateOrFail() error

func (ELB) DNSName

func (lb ELB) DNSName() string

func (ELB) Delete

func (lb ELB) Delete() error

func (ELB) HostedZoneID

func (lb ELB) HostedZoneID() string

func (*ELB) RegisterInstances

func (lb *ELB) RegisterInstances(instanceIDs []string) error

type FSKeyPairProvider

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

func NewFSKeyPairProvider

func NewFSKeyPairProvider(pubKeyFile string) *FSKeyPairProvider

type FindInstancesInput

type FindInstancesInput struct {
	Clients awsutil.Clients
	Logger  micrologger.Logger
	Pattern string
}

type Instance

type Instance struct {
	Name                   string
	ClusterName            string
	ImageID                string
	InstanceType           string
	KeyName                string
	MinCount               int
	MaxCount               int
	UserData               string
	SmallCloudconfig       string
	IamInstanceProfileName string
	PlacementAZ            string
	SecurityGroupID        string
	SubnetID               string
	PrivateIpAddress       string

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

func FindInstances

func FindInstances(input FindInstancesInput) ([]*Instance, error)

func (*Instance) CreateIfNotExists

func (i *Instance) CreateIfNotExists() (bool, error)

func (*Instance) CreateOrFail

func (i *Instance) CreateOrFail() error

func (*Instance) Delete

func (i *Instance) Delete() error

func (Instance) ID

func (i Instance) ID() string

type InstanceProfile

type InstanceProfile struct {
	ClusterID string

	AWSEntity
	// contains filtered or unexported fields
}

func (*InstanceProfile) CreateIfNotExists

func (ip *InstanceProfile) CreateIfNotExists() (bool, error)

func (*InstanceProfile) CreateOrFail

func (ip *InstanceProfile) CreateOrFail() error

func (*InstanceProfile) Delete

func (ip *InstanceProfile) Delete() error

func (InstanceProfile) GetName

func (ip InstanceProfile) GetName() string

type InternetGateway

type InternetGateway struct {
	Name  string
	VpcID string

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

func (*InternetGateway) CreateIfNotExists

func (g *InternetGateway) CreateIfNotExists() (bool, error)

func (*InternetGateway) CreateOrFail

func (g *InternetGateway) CreateOrFail() error

func (*InternetGateway) Delete

func (g *InternetGateway) Delete() error

func (InternetGateway) GetID

func (g InternetGateway) GetID() (string, error)

type KMSKey

type KMSKey struct {
	Name string

	AWSEntity
	// contains filtered or unexported fields
}

func (KMSKey) Arn

func (kk KMSKey) Arn() string

func (*KMSKey) CreateIfNotExists

func (kk *KMSKey) CreateIfNotExists() (bool, error)

func (*KMSKey) CreateOrFail

func (kk *KMSKey) CreateOrFail() error

func (*KMSKey) Delete

func (kk *KMSKey) Delete() error

type KeyPair

type KeyPair struct {
	ClusterName string
	Provider    KeyPairProvider
	AWSEntity
}

func (*KeyPair) CreateIfNotExists

func (k *KeyPair) CreateIfNotExists() (bool, error)

func (*KeyPair) CreateOrFail

func (k *KeyPair) CreateOrFail() error

func (*KeyPair) Delete

func (k *KeyPair) Delete() error

type KeyPairProvider

type KeyPairProvider interface {
	// contains filtered or unexported methods
}

type LaunchConfiguration

type LaunchConfiguration struct {
	AssociatePublicIpAddress bool
	EBSStorage               bool
	IamInstanceProfileName   string
	ImageID                  string
	InstanceType             string
	KeyName                  string
	Name                     string
	SecurityGroupID          string
	SmallCloudConfig         string

	// Dependencies
	Client *autoscaling.AutoScaling
}

LaunchConfiguration is a template for launching EC2 instances into an auto scaling group.

func (*LaunchConfiguration) CreateIfNotExists

func (lc *LaunchConfiguration) CreateIfNotExists() (bool, error)

CreateIfNotExists creates the launch config if it doesn't exist.

func (*LaunchConfiguration) CreateOrFail

func (lc *LaunchConfiguration) CreateOrFail() error

CreateOrFail creates the launch config or returns the error.

func (*LaunchConfiguration) Delete

func (lc *LaunchConfiguration) Delete() error

Delete deletes the launch config.

type NatGateway

type NatGateway struct {
	Name   string
	Subnet *Subnet

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

func (*NatGateway) CreateIfNotExists

func (g *NatGateway) CreateIfNotExists() (bool, error)

func (*NatGateway) CreateOrFail

func (g *NatGateway) CreateOrFail() error

func (*NatGateway) Delete

func (g *NatGateway) Delete() error

func (NatGateway) GetID

func (g NatGateway) GetID() (string, error)

type Policy

type Policy struct {
	ClusterID  string
	KMSKeyArn  string
	PolicyType string
	S3Bucket   string

	AWSEntity
	// contains filtered or unexported fields
}

func (*Policy) CreateIfNotExists

func (p *Policy) CreateIfNotExists() (bool, error)

func (*Policy) CreateOrFail

func (p *Policy) CreateOrFail() error

func (*Policy) Delete

func (p *Policy) Delete() error

func (Policy) GetName

func (p Policy) GetName() string

type PortPair

type PortPair struct {
	// PortELB is the port the ELB should listen on.
	PortELB int
	// PortInstance is the port on the instance the ELB forwards traffic to.
	PortInstance int
}

PortPair is a pair of ports.

type PortPairs

type PortPairs []PortPair

PortPairs is an array of PortPair.

type RecordSet

type RecordSet struct {
	// Domain is the domain name for the record.
	Domain string
	// HostedZoneID is the ID of the Hosted Zone the record should be created in.
	HostedZoneID string
	Type         string
	// Client is the AWS client.
	Client *route53.Route53
	// Resource is the AWS resource the record should be created for.
	Resource resources.DNSNamedResource
	Value    string
}

func (RecordSet) CreateIfNotExists

func (record RecordSet) CreateIfNotExists() (bool, error)

CreateIfNotExists is not implemented because AWS provides UPSERT functionality for DNS records

func (RecordSet) CreateOrFail

func (record RecordSet) CreateOrFail() error

func (RecordSet) Delete

func (record RecordSet) Delete() error

type Route

type Route struct {
	DestinationCidrBlock   string
	VpcPeeringConnectionID string
	RouteTable             RouteTable
	AWSEntity
}

func (*Route) CreateIfNotExists

func (r *Route) CreateIfNotExists() (bool, error)

func (*Route) CreateOrFail

func (r *Route) CreateOrFail() error

func (*Route) Delete

func (r *Route) Delete() error

type RouteTable

type RouteTable struct {
	Name  string
	VpcID string

	// Dependencies.
	Client *ec2.EC2
	Logger micrologger.Logger
	// contains filtered or unexported fields
}

func (*RouteTable) CreateIfNotExists

func (r *RouteTable) CreateIfNotExists() (bool, error)

func (RouteTable) CreateNatGatewayRoute

func (r RouteTable) CreateNatGatewayRoute(natGatewayID string) (bool, error)

CreateNatGatewayRoute creates a default route to the NAT gateway for the private subnet. Retry is needed due to a delay while the gateway is created.

func (*RouteTable) CreateOrFail

func (r *RouteTable) CreateOrFail() error

func (*RouteTable) Delete

func (r *RouteTable) Delete() error

func (RouteTable) GetID

func (r RouteTable) GetID() (string, error)

func (RouteTable) MakePublic

func (r RouteTable) MakePublic() error

MakePublic creates a route that allows traffic from outside the VPC. To do that, it needs to add a route on the Internet Gateway of the VPC.

type SecurityGroup

type SecurityGroup struct {
	Description string
	GroupName   string
	VpcID       string
	Rules       []SecurityGroupRule

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

SecurityGroup is an AWS security group.

func (SecurityGroup) ApplyRules

func (s SecurityGroup) ApplyRules(rules []SecurityGroupRule) error

ApplyRules creates the security group rules.

func (*SecurityGroup) CreateIfNotExists

func (s *SecurityGroup) CreateIfNotExists() (bool, error)

CreateIfNotExists creates the security group if it does not exist.

func (*SecurityGroup) CreateOrFail

func (s *SecurityGroup) CreateOrFail() error

CreateOrFail creates the security group or returns an error.

func (*SecurityGroup) Delete

func (s *SecurityGroup) Delete() error

Delete deletes the security group. A security group cannot be deleted if it references another securty group. So first we delete any rules referencing other groups.

func (SecurityGroup) GetID

func (s SecurityGroup) GetID() (string, error)

GetID gets the AWS security group ID.

type SecurityGroupRule

type SecurityGroupRule struct {
	// Port is the port to open.
	Port int
	// Protocol is the IP protocol.
	Protocol string
	// SourceCIDR is the CIDR of the source.
	SourceCIDR string
	// SecurityGroupID is the ID of the source Security Group.
	SecurityGroupID string
}

SecurityGroupRule is an AWS security group rule.

type SecurityGroupRules

type SecurityGroupRules struct {
	Description string
	GroupName   string
	AWSEntity
}

SecurityGroupRules allows AWS security group rules to be deleted. Any rules referencing other security groups must be deleted before the group can be deleted.

func (SecurityGroupRules) Delete

func (s SecurityGroupRules) Delete() error

Delete deletes any security group rules that reference other groups. This must happen before the security group can be deleted. Rules using a CIDR do not need to be deleted.

type Subnet

type Subnet struct {
	AvailabilityZone string
	CidrBlock        string
	Name             string
	VpcID            string
	ClusterName      string

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

func (*Subnet) AssociateRouteTable

func (s *Subnet) AssociateRouteTable(routeTable *RouteTable) error

func (*Subnet) CreateIfNotExists

func (s *Subnet) CreateIfNotExists() (bool, error)

func (*Subnet) CreateOrFail

func (s *Subnet) CreateOrFail() error

func (*Subnet) Delete

func (s *Subnet) Delete() error

func (Subnet) GetID

func (s Subnet) GetID() (string, error)

func (*Subnet) MakePublic

func (s *Subnet) MakePublic() error

type VPC

type VPC struct {
	CidrBlock        string
	InstallationName string
	Name             string

	// Dependencies.
	Logger micrologger.Logger
	AWSEntity
	// contains filtered or unexported fields
}

func (*VPC) CreateIfNotExists

func (v *VPC) CreateIfNotExists() (bool, error)

func (*VPC) CreateOrFail

func (v *VPC) CreateOrFail() error

func (*VPC) Delete

func (v *VPC) Delete() error

func (VPC) GetID

func (v VPC) GetID() (string, error)

GetID retrieves the ID from the API if it isn't defined on the VPC struct.

func (VPC) List

func (v VPC) List() ([]VPC, error)

List lists the VPCs for this installation.

type VPCPeeringConnection

type VPCPeeringConnection struct {
	VPCId     string // VPCId is the ID of the VPC in the guest cluster.
	PeerVPCId string // PeerVPCId the ID of the VPC in the host cluster.

	AWSEntity

	Logger micrologger.Logger
	// contains filtered or unexported fields
}

func (*VPCPeeringConnection) CreateIfNotExists

func (v *VPCPeeringConnection) CreateIfNotExists() (bool, error)

func (*VPCPeeringConnection) CreateOrFail

func (v *VPCPeeringConnection) CreateOrFail() error

func (*VPCPeeringConnection) Delete

func (v *VPCPeeringConnection) Delete() error

func (VPCPeeringConnection) FindExisting

func (v VPCPeeringConnection) FindExisting() (*ec2.VpcPeeringConnection, error)

func (*VPCPeeringConnection) GetID

func (v *VPCPeeringConnection) GetID() (string, error)

Jump to

Keyboard shortcuts

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