client

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0, MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoSuchHostedZoneError added in v1.28.0

func IsNoSuchHostedZoneError(err error) bool

IsNoSuchHostedZoneError returns true if the error indicates a non-existing route53 hosted zone.

func IsNotFoundError added in v1.29.0

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the given error is a awserr.Error indicating that a AWS resource was not found.

func IsNotPermittedInZoneError added in v1.28.0

func IsNotPermittedInZoneError(err error) bool

IsNotPermittedInZoneError returns true if the error indicates that the DNS name is not permitted in the route53 hosted zone.

Types

type Client

type Client struct {
	EC2                ec2iface.EC2API
	STS                stsiface.STSAPI
	IAM                iamiface.IAMAPI
	S3                 s3iface.S3API
	ELB                elbiface.ELBAPI
	ELBv2              elbv2iface.ELBV2API
	Route53            route53iface.Route53API
	Route53RateLimiter *rate.Limiter
	Logger             logr.Logger
}

Client is a struct containing several clients for the different AWS services it needs to interact with. * EC2 is the standard client for the EC2 service. * STS is the standard client for the STS service. * IAM is the standard client for the IAM service. * S3 is the standard client for the S3 service. * ELB is the standard client for the ELB service. * ELBv2 is the standard client for the ELBv2 service. * Route53 is the standard client for the Route53 service.

func NewClient

func NewClient(accessKeyID, secretAccessKey, region string) (*Client, error)

NewClient creates a new Client for the given AWS credentials <accessKeyID>, <secretAccessKey>, and the AWS region <region>. It initializes the clients for the various services like EC2, ELB, etc.

func (*Client) CreateBucketIfNotExists

func (c *Client) CreateBucketIfNotExists(ctx context.Context, bucket, region string) error

CreateBucketIfNotExists creates the s3 bucket with name <bucket> in <region>. If it already exist, no error is returned.

func (*Client) CreateDNSHostedZone added in v1.27.0

func (c *Client) CreateDNSHostedZone(ctx context.Context, name, comment string) (string, error)

CreateDNSHostedZone creates the DNS hosted zone with the given name and comment, and returns the ID of the newly created zone.

func (*Client) CreateOrUpdateDNSRecordSet added in v1.27.0

func (c *Client) CreateOrUpdateDNSRecordSet(ctx context.Context, zoneId, name, recordType string, values []string, ttl int64) error

CreateOrUpdateDNSRecordSet creates or updates the DNS recordset in the DNS hosted zone with the given zone ID, with the given name, type, values, and TTL.

func (*Client) DeleteBucketIfExists

func (c *Client) DeleteBucketIfExists(ctx context.Context, bucket string) error

DeleteBucketIfExists deletes the s3 bucket with name <bucket>. If it does not exist, no error is returned.

func (*Client) DeleteDNSHostedZone added in v1.27.0

func (c *Client) DeleteDNSHostedZone(ctx context.Context, zoneId string) error

DeleteDNSHostedZone deletes the DNS hosted zone with the given ID.

func (*Client) DeleteDNSRecordSet added in v1.27.0

func (c *Client) DeleteDNSRecordSet(ctx context.Context, zoneId, name, recordType string, values []string, ttl int64) error

DeleteDNSRecordSet deletes the DNS recordset in the DNS hosted zone with the given zone ID, with the given name, type, values, and TTL. If values is empty and TTL is 0, the actual state will be determined by reading the recordset from the zone. Otherwise, an attempt will be made to delete the recordset with the given values / TTL. If this results in a "values do not match" error, the actual state will again be determined by reading the recordset from the zone, and a second attempt to delete it will be made. The idea is to ensure a consistent and foolproof behavior while sending as few requests as possible to avoid rate limit issues.

func (*Client) DeleteELB

func (c *Client) DeleteELB(ctx context.Context, name string) error

DeleteELB deletes the loadbalancer with the specific <name>. If it does not exist, no error is returned.

func (*Client) DeleteELBV2

func (c *Client) DeleteELBV2(ctx context.Context, arn string) error

DeleteELBV2 deletes the loadbalancer (NLB or ALB) as well as its target groups with its Amazon Resource Name (ARN). If it does not exist, no error is returned.

func (*Client) DeleteObjectsWithPrefix

func (c *Client) DeleteObjectsWithPrefix(ctx context.Context, bucket, prefix string) error

DeleteObjectsWithPrefix deletes the s3 objects with the specific <prefix> from <bucket>. If it does not exist, no error is returned.

func (*Client) DeleteSecurityGroup

func (c *Client) DeleteSecurityGroup(ctx context.Context, id string) error

DeleteSecurityGroup deletes the security group with the specific <id>. If it does not exist, no error is returned.

func (*Client) GetAccountID

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

GetAccountID returns the ID of the AWS account the Client is interacting with.

func (*Client) GetDNSHostedZones added in v1.27.0

func (c *Client) GetDNSHostedZones(ctx context.Context) (map[string]string, error)

GetDNSHostedZones returns a map of all DNS hosted zone names mapped to their IDs.

func (*Client) GetDNSRecordSet added in v1.27.0

func (c *Client) GetDNSRecordSet(ctx context.Context, zoneId, name, recordType string) (*route53.ResourceRecordSet, error)

GetDNSRecordSet returns the DNS recordset in the DNS hosted zone with the given zone ID, and with the given name and type.

func (*Client) GetVPCAttribute added in v1.29.0

func (c *Client) GetVPCAttribute(ctx context.Context, vpcID string, attribute string) (bool, error)

GetVPCAttribute returns the value of the specified VPC attribute.

func (*Client) GetVPCInternetGateway added in v1.29.0

func (c *Client) GetVPCInternetGateway(ctx context.Context, vpcID string) (string, error)

GetVPCInternetGateway returns the ID of the internet gateway attached to the given VPC <vpcID>. If there is no internet gateway attached, the returned string will be empty.

func (*Client) ListKubernetesELBs

func (c *Client) ListKubernetesELBs(ctx context.Context, vpcID, clusterName string) ([]string, error)

ListKubernetesELBs returns the list of ELB loadbalancers in the given <vpcID> tagged with <clusterName>.

func (*Client) ListKubernetesELBsV2

func (c *Client) ListKubernetesELBsV2(ctx context.Context, vpcID, clusterName string) ([]string, error)

ListKubernetesELBsV2 returns the list of ELBv2 loadbalancers in the given <vpcID> tagged with <clusterName>.

func (*Client) ListKubernetesSecurityGroups

func (c *Client) ListKubernetesSecurityGroups(ctx context.Context, vpcID, clusterName string) ([]string, error)

ListKubernetesSecurityGroups returns the list of security groups in the given <vpcID> tagged with <clusterName>.

type Factory added in v1.27.0

type Factory interface {
	// NewClient creates a new instance of Interface for the given AWS credentials and region.
	NewClient(accessKeyID, secretAccessKey, region string) (Interface, error)
}

Factory creates instances of Interface.

func NewRoute53Factory added in v1.30.0

func NewRoute53Factory(limit rate.Limit, burst int) Factory

NewRoute53Factory creates a new Factory that initializes a route53 rate limiter with the given limit and burst when creating new clients.

type FactoryFunc added in v1.27.0

type FactoryFunc func(accessKeyID, secretAccessKey, region string) (Interface, error)

FactoryFunc is a function that implements Factory.

func (FactoryFunc) NewClient added in v1.27.0

func (f FactoryFunc) NewClient(accessKeyID, secretAccessKey, region string) (Interface, error)

NewClient creates a new instance of Interface for the given AWS credentials and region.

type Interface

type Interface interface {
	GetAccountID(ctx context.Context) (string, error)
	GetVPCInternetGateway(ctx context.Context, vpcID string) (string, error)
	GetVPCAttribute(ctx context.Context, vpcID string, attribute string) (bool, error)

	// S3 wrappers
	DeleteObjectsWithPrefix(ctx context.Context, bucket, prefix string) error
	CreateBucketIfNotExists(ctx context.Context, bucket, region string) error
	DeleteBucketIfExists(ctx context.Context, bucket string) error

	// Route53 wrappers
	GetDNSHostedZones(ctx context.Context) (map[string]string, error)
	CreateOrUpdateDNSRecordSet(ctx context.Context, zoneId, name, recordType string, values []string, ttl int64) error
	DeleteDNSRecordSet(ctx context.Context, zoneId, name, recordType string, values []string, ttl int64) error

	// The following functions are only temporary needed due to https://github.com/gardener/gardener/issues/129.
	ListKubernetesELBs(ctx context.Context, vpcID, clusterName string) ([]string, error)
	ListKubernetesELBsV2(ctx context.Context, vpcID, clusterName string) ([]string, error)
	ListKubernetesSecurityGroups(ctx context.Context, vpcID, clusterName string) ([]string, error)
	DeleteELB(ctx context.Context, name string) error
	DeleteELBV2(ctx context.Context, arn string) error
	DeleteSecurityGroup(ctx context.Context, id string) error
}

Interface is an interface which must be implemented by AWS clients.

func NewInterface added in v1.27.0

func NewInterface(accessKeyID, secretAccessKey, region string) (Interface, error)

NewInterface creates a new instance of Interface for the given AWS credentials and region.

Directories

Path Synopsis
Package client is a generated GoMock package.
Package client is a generated GoMock package.

Jump to

Keyboard shortcuts

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