awsutil

package
v0.0.0-...-53d1af7 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Session is a pointer to the AWS session
	Session *session.Session
	// Route53svc is a pointer to the awsutil Route53 service
	Route53svc *Route53
	// ALBsvc is a pointer to the awsutil ELBV2 service
	ALBsvc *ELBV2
	// Ec2svc is a pointer to the awsutil EC2 service
	Ec2svc *EC2
	// ACMsvc is a pointer to the awsutil ACM service
	ACMsvc *ACM
	// IAMsvc is a pointer to the awsutil IAM service
	IAMsvc *IAM
	// AWSDebug turns on AWS API debug logging
	AWSDebug bool

	// OnUpdateCount is a counter of the controller OnUpdate calls
	OnUpdateCount = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "albingress_updates",
		Help: "Number of times OnUpdate has been called.",
	},
	)

	// ReloadCount is a counter of the controller Reload calls
	ReloadCount = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "albingress_reloads",
		Help: "Number of times Reload has been called.",
	},
	)

	// AWSErrorCount is a counter of AWS errors
	AWSErrorCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "albingress_aws_errors",
		Help: "Number of errors from the AWS API",
	},
		[]string{"service", "request"},
	)

	// ManagedIngresses contains the current tally of managed ingresses
	ManagedIngresses = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "albingress_managed_ingresses",
		Help: "Number of ingresses being managed",
	})

	// AWSCache contains the hits and misses to our caches
	AWSCache = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "albingress_cache",
		Help: "Number of ingresses being managed",
	},
		[]string{"cache", "action"})

	// AWSRequest contains the requests made to the AWS API
	AWSRequest = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "albingress_aws_requests",
		Help: "Number of requests made to the AWS API",
	},
		[]string{"service", "operation"})
)

Functions

func DeepEqual

func DeepEqual(a interface{}, b interface{}) bool

DeepEqual wraps github.com/aws/aws-sdk-go/aws/awsutil.Prettify. Preventing the need to import it in each package.

func LookupExistingRecord

func LookupExistingRecord(hostname *string) *route53.ResourceRecordSet

LookupExistingRecord returns the route53.ResourceRecordSet for a hostname

func NewSession

func NewSession(awsconfig *aws.Config) *session.Session

NewSession returns an AWS session based off of the provided AWS config

func Prettify

func Prettify(i interface{}) string

Prettify wraps github.com/aws/aws-sdk-go/aws/awsutil.Prettify. Preventing the need to import it in each package.

Types

type ACM

type ACM struct {
	Svc acmiface.ACMAPI
}

ACM is our extension to AWS's ACM.acm

func NewACM

func NewACM(awsSession *session.Session) *ACM

NewACM returns an ACM based off of the provided AWS session

func (*ACM) CertExists

func (a *ACM) CertExists(arn *string) bool

CertExists checks whether the provided ARN existing in AWS.

type APICache

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

func (APICache) Get

func (ac APICache) Get(key string) *ccache.Item

Get retrieves a key in the API cache. If they key doesn't exist or it expired, nil is returned.

func (APICache) Set

func (ac APICache) Set(key string, value interface{}, duration time.Duration)

Set add a key and value to the API cache.

type EC2

type EC2 struct {
	Svc ec2iface.EC2API
	// contains filtered or unexported fields
}

EC2 is our extension to AWS's ec2.EC2

func NewEC2

func NewEC2(awsSession *session.Session) *EC2

NewEC2 returns an awsutil EC2 service

func (*EC2) DescribeSecurityGroups

func (e *EC2) DescribeSecurityGroups(in ec2.DescribeSecurityGroupsInput) ([]*ec2.SecurityGroup, error)

DescribeSecurityGroups looks up Security Groups based on input and returns a list of Security Groups.

func (*EC2) DescribeSubnets

func (e *EC2) DescribeSubnets(in ec2.DescribeSubnetsInput) ([]*ec2.Subnet, error)

DescribeSubnets looks up Subnets based on input and returns a list of Subnets.

func (*EC2) GetVPCID

func (e *EC2) GetVPCID(subnets []*string) (*string, error)

GetVPCID retrieves the VPC that the subents passed are contained in.

type ELBV2

type ELBV2 struct {
	Svc elbv2iface.ELBV2API
}

ELBV2 is our extension to AWS's elbv2.ELBV2

func NewELBV2

func NewELBV2(awsSession *session.Session) *ELBV2

NewELBV2 returns an ELBV2 based off of the provided AWS session

func (*ELBV2) AddListener

func (e *ELBV2) AddListener(in elbv2.CreateListenerInput) (*elbv2.Listener, error)

AddListener creates a new Listener and associates it with the ELBV2 (ALB). It returns the elbv2.Listener created on success or an error on failure.

func (*ELBV2) AddRule

func (e *ELBV2) AddRule(in elbv2.CreateRuleInput) (*elbv2.Rule, error)

AddRule creates a new Rule and associates it with the Listener. It returns the elbv2.Rule created on success or an error returned on failure.

func (*ELBV2) AddTargetGroup

func (e *ELBV2) AddTargetGroup(in elbv2.CreateTargetGroupInput) (*elbv2.TargetGroup, error)

AddTargetGroup creates a new TargetGroup in AWS. It returns the created elbv2.TargetGroup on success and an error on failure.

func (*ELBV2) Create

Create makes a new ELBV2 (ALB) in AWS. It returns the elbv2.LoadBalancer created on success or an error on failure.

func (*ELBV2) Delete

func (e *ELBV2) Delete(in elbv2.DeleteLoadBalancerInput) error

Delete removes an ELBV2 (ALB) in AWS. It returns an error if the delete fails. Deletions of ALBs in AWS will also remove all listeners and rules associated with them.

func (*ELBV2) DescribeListeners

func (e *ELBV2) DescribeListeners(loadBalancerArn *string) ([]*elbv2.Listener, error)

DescribeListeners looks up all ELBV2 (ALB) listeners in AWS that are part of the cluster.

func (*ELBV2) DescribeLoadBalancers

func (e *ELBV2) DescribeLoadBalancers(clusterName *string) ([]*elbv2.LoadBalancer, error)

DescribeLoadBalancers looks up all ELBV2 (ALB) instances in AWS that are part of the cluster.

func (*ELBV2) DescribeRules

func (e *ELBV2) DescribeRules(listenerArn *string) ([]*elbv2.Rule, error)

DescribeRules looks up all rules for a listener ARN.

func (*ELBV2) DescribeTags

func (e *ELBV2) DescribeTags(arn *string) (util.Tags, error)

DescribeTags looks up all tags for a given ARN.

func (*ELBV2) DescribeTargetGroup

func (e *ELBV2) DescribeTargetGroup(arn *string) (*elbv2.TargetGroup, error)

DescribeTargetGroup looks up a target group by an ARN.

func (*ELBV2) DescribeTargetGroupTargets

func (e *ELBV2) DescribeTargetGroupTargets(arn *string) (util.AWSStringSlice, error)

DescribeTargetGroupTargets looks up target group targets by an ARN.

func (*ELBV2) DescribeTargetGroups

func (e *ELBV2) DescribeTargetGroups(loadBalancerArn *string) ([]*elbv2.TargetGroup, error)

DescribeTargetGroups looks up all ELBV2 (ALB) target groups in AWS that are part of the cluster.

func (*ELBV2) ModifyTargetGroup

func (e *ELBV2) ModifyTargetGroup(in elbv2.ModifyTargetGroupInput) (*elbv2.TargetGroup, error)

ModifyTargetGroup alters a Target Group in AWS. The modified elbv2.TargetGroup is returned on success and an error is returned on failure.

func (*ELBV2) RegisterTargets

func (e *ELBV2) RegisterTargets(in elbv2.RegisterTargetsInput) error

RegisterTargets adds EC2 instances to a Target Group. It returns an error when unsuccessful.

func (*ELBV2) RemoveListener

func (e *ELBV2) RemoveListener(in elbv2.DeleteListenerInput) error

RemoveListener removes a Listener from an ELBV2 (ALB) by deleting it in AWS. If the deletion attempt returns a elbv2.ErrCodeListenerNotFoundException, it's considered a success as the listener has already been removed. If removal fails for another reason, an error is returned.

func (*ELBV2) RemoveRule

func (e *ELBV2) RemoveRule(in elbv2.DeleteRuleInput) error

RemoveRule removes a Rule from a listener by deleting it in AWS. If the deletion fails, an error is returned.

func (*ELBV2) RemoveTargetGroup

func (e *ELBV2) RemoveTargetGroup(in elbv2.DeleteTargetGroupInput) error

RemoveTargetGroup removes a Target Group from AWS by deleting it. If the deletion fails, an error is returned. Often, a Listener that references the Target Group is still being deleted when this method is accessed. Thus, this method makes multiple attempts to delete the Target Group when it receives an elbv2.ErrCodeResourceInUseException.

func (*ELBV2) SetSecurityGroups

func (e *ELBV2) SetSecurityGroups(in elbv2.SetSecurityGroupsInput) error

SetSecurityGroups updates the security groups attached to an ELBV2 (ALB). It returns an error when unsuccessful.

func (*ELBV2) SetSubnets

func (e *ELBV2) SetSubnets(in elbv2.SetSubnetsInput) error

SetSubnets updates the subnets attached to an ELBV2 (ALB). It returns an error when unsuccessful.

func (*ELBV2) UpdateTags

func (e *ELBV2) UpdateTags(arn *string, old util.Tags, new util.Tags) error

UpdateTags compares the new (desired) tags against the old (current) tags. It then adds and removes tags as needed.

type IAM

type IAM struct {
	Svc iamiface.IAMAPI
}

IAM is our extension to AWS's IAM.iam

func NewIAM

func NewIAM(awsSession *session.Session) *IAM

NewIAM returns an IAM based off of the provided aws.Config

func (*IAM) CertExists

func (i *IAM) CertExists(arn *string) bool

CertExists checks whether the provided ARN exists in AWS.

type Route53

type Route53 struct {
	Svc route53iface.Route53API
	// contains filtered or unexported fields
}

Route53 is our extension to AWS's route53.Route53

func NewRoute53

func NewRoute53(awsSession *session.Session) *Route53

NewRoute53 returns a new Route53 based off of an AWS session

func (*Route53) Delete

Delete removes a Route53 Resource Record Set from Route 53. When a route53.InvalidChangeBatch error is detected, it's considered a failure as the Route 53 record no longer exists in its current states (is likley already deleted). All other failures return an error.

func (*Route53) DescribeResourceRecordSets

func (r *Route53) DescribeResourceRecordSets(zoneID *string, hostname *string) (*route53.ResourceRecordSet, error)

DescribeResourceRecordSets returns the route53.ResourceRecordSet for a zone & hostname

func (*Route53) GetZoneID

func (r *Route53) GetZoneID(hostname *string) (*route53.HostedZone, error)

GetZoneID looks for the Route53 zone ID of the hostname passed to it. It iteratively looks up very possible domain combination the hosted zone could represent. The most qualified will always win. e.g. If your domain is 1.2.example.com and you have 2.example.com and example.com both as hosted zones Route 53, 2.example.com will always win.

func (*Route53) Modify

Modify is the general way to interact with Route 53 Resource Record Sets. It handles create and modifications based on the input passed. It will verify the AWS DNS is propogated before returning.

Jump to

Keyboard shortcuts

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