Documentation
¶
Overview ¶
package lb provides an abstraction around creating load balancers.
Index ¶
- Constants
- type CreateLoadBalancerOpts
- type ELBManager
- func (m *ELBManager) CreateLoadBalancer(ctx context.Context, o CreateLoadBalancerOpts) (*LoadBalancer, error)
- func (m *ELBManager) DestroyLoadBalancer(ctx context.Context, lb *LoadBalancer) error
- func (m *ELBManager) LoadBalancers(ctx context.Context, tags map[string]string) ([]*LoadBalancer, error)
- func (m *ELBManager) UpdateLoadBalancer(ctx context.Context, opts UpdateLoadBalancerOpts) error
- type LoadBalancer
- type LoggedManager
- type Manager
- type Nameserver
- type Route53Nameserver
- type UpdateLoadBalancerOpts
Constants ¶
const AppTag = "App"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateLoadBalancerOpts ¶
type CreateLoadBalancerOpts struct {
// The port to route requests to on the hosts.
InstancePort int64
// An arbitrary list of tags to assign to the load balancer.
Tags map[string]string
// True if the load balancer should be publicy exposed.
External bool
// The SSL Certificate
SSLCert string
}
CreateLoadBalancerOpts are options that can be provided when creating a LoadBalancer.
type ELBManager ¶
type ELBManager struct {
// The ID of the security group to assign to internal load balancers.
InternalSecurityGroupID string
// The ID of the security group to assign to external load balancers.
ExternalSecurityGroupID string
// The Subnet IDs to assign when creating internal load balancers.
InternalSubnetIDs []string
// The Subnet IDs to assign when creating external load balancers.
ExternalSubnetIDs []string
// contains filtered or unexported fields
}
ELBManager is an implementation of the Manager interface that creates Elastic Load Balancers.
func NewELBManager ¶
func NewELBManager(p client.ConfigProvider) *ELBManager
NewELBManager returns a new ELBManager backed by the aws config.
func (*ELBManager) CreateLoadBalancer ¶
func (m *ELBManager) CreateLoadBalancer(ctx context.Context, o CreateLoadBalancerOpts) (*LoadBalancer, error)
CreateLoadBalancer creates a new ELB:
* The ELB is created and connection draining is enabled. * An internal DNS CNAME record is created, pointing the the DNSName of the ELB.
func (*ELBManager) DestroyLoadBalancer ¶
func (m *ELBManager) DestroyLoadBalancer(ctx context.Context, lb *LoadBalancer) error
DestroyLoadBalancer destroys an ELB.
func (*ELBManager) LoadBalancers ¶
func (m *ELBManager) LoadBalancers(ctx context.Context, tags map[string]string) ([]*LoadBalancer, error)
LoadBalancers returns all load balancers. If tags are provided, then the resulting load balancers will be filtered to only those containing the provided tags.
func (*ELBManager) UpdateLoadBalancer ¶ added in v0.10.0
func (m *ELBManager) UpdateLoadBalancer(ctx context.Context, opts UpdateLoadBalancerOpts) error
type LoadBalancer ¶
type LoadBalancer struct {
// The name of the load balancer.
Name string
// DNSName is the DNS name for the load balancer. CNAME records can be
// created that point to this location.
DNSName string
// True if the load balancer is exposed externally.
External bool
// The SSL Certificate to associate with the load balancer.
SSLCert string
// InstancePort is the port that this load balancer forwards requests to
// on the host.
InstancePort int64
// Tags contain the tags attached to the LoadBalancer
Tags map[string]string
}
LoadBalancer represents a load balancer.
type LoggedManager ¶
type LoggedManager struct {
Manager
}
LoggedManager is an implementation of the Manager interface that logs when LoadBalancers are created and destroyed.
func WithLogging ¶
func WithLogging(m Manager) *LoggedManager
WithLogging wraps the manager with logging.
func (*LoggedManager) CreateLoadBalancer ¶
func (m *LoggedManager) CreateLoadBalancer(ctx context.Context, o CreateLoadBalancerOpts) (*LoadBalancer, error)
func (*LoggedManager) DestroyLoadBalancer ¶
func (m *LoggedManager) DestroyLoadBalancer(ctx context.Context, lb *LoadBalancer) error
type Manager ¶
type Manager interface {
// CreateLoadBalancer creates a new LoadBalancer with the given options.
CreateLoadBalancer(context.Context, CreateLoadBalancerOpts) (*LoadBalancer, error)
// UpdateLoadBalancer updates an existing load balancer.
UpdateLoadBalancer(context.Context, UpdateLoadBalancerOpts) error
// DestroyLoadBalancer destroys a load balancer by name.
DestroyLoadBalancer(ctx context.Context, lb *LoadBalancer) error
// LoadBalancers returns a list of LoadBalancers, optionally provide
// tags to filter by.
LoadBalancers(ctx context.Context, tags map[string]string) ([]*LoadBalancer, error)
}
Manager is our API interface for interacting with LoadBalancers.
func WithCNAME ¶
func WithCNAME(m Manager, n Nameserver) Manager
WithCNAME wraps a Manager to create CNAME records for the LoadBalancer using a Nameserver.
type Nameserver ¶
type Nameserver interface {
// CNAME creates a cname record pointed at record.
CreateCNAME(cname, record string) error
DeleteCNAME(cname, record string) error
}
Nameserver represents a service for creating dns records.
type Route53Nameserver ¶
type Route53Nameserver struct {
// The Hosted Zone ID that records will be created under.
ZoneID string
// contains filtered or unexported fields
}
Route53Nameserver is an implementation of the nameserver interface backed by route53.
func NewRoute53Nameserver ¶
func NewRoute53Nameserver(p client.ConfigProvider) *Route53Nameserver
NewRoute53Nameserver returns a Route53Nameserver instance with a configured route53 client.
func (*Route53Nameserver) CreateCNAME ¶
func (n *Route53Nameserver) CreateCNAME(cname, record string) error
CreateCNAME creates a CNAME record under the HostedZone specified by ZoneID.
func (*Route53Nameserver) DeleteCNAME ¶
func (n *Route53Nameserver) DeleteCNAME(cname, record string) error
DeleteCNAME deletes the CNAME of an ELB from the internal zone
type UpdateLoadBalancerOpts ¶ added in v0.10.0
type UpdateLoadBalancerOpts struct {
// The name of the load balancer.
Name string
// The SSL Certificate
SSLCert *string
}
UpdateLoadBalancerOpts are options that can be provided when updating an existing load balancer.