aws_client

package
v0.0.0-...-4da6f2b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockClusterTag             = "kubernetes.io/cluster/mock-12345"
	MockClusterNameTag         = "mock-12345-vpce"
	MockHostedZoneId           = "R53HZ12345"
	MockPublicSubnetId         = "subnet-pub12345"
	MockPrivateSubnetId        = "subnet-priv12345"
	MockSecurityGroupId        = "sg-12345"
	MockVpcId                  = "vpc-12345"
	MockVpcEndpointServiceName = "com.amazonaws.vpce.service.mock-12345"
	MockVpcEndpointServiceId   = "vpce-svc-12345"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSClient

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

func NewAwsClient

func NewAwsClient(cfg aws.Config) *AWSClient

NewAwsClient returns an AWSClient with the provided session

func NewAwsClientWithServiceClients

func NewAwsClientWithServiceClients(ec2 AvoEC2API, r53 AvoRoute53API) *AWSClient

NewAwsClientWithServiceClients returns an AWSClient with the provided EC2 and Route53 clients. Typically, not used directly except for building a mock for testing.

func NewMockedAwsClient

func NewMockedAwsClient() *AWSClient

func NewMockedAwsClientWithSubnets

func NewMockedAwsClientWithSubnets() *AWSClient

func (*AWSClient) AuthorizeSecurityGroupRules

AuthorizeSecurityGroupRules authorizes provided ingress and egress rules for a security group, returning the updated security group rules and any errors

func (*AWSClient) AutodiscoverPrivateSubnets

func (c *AWSClient) AutodiscoverPrivateSubnets(ctx context.Context, clusterTag string, tags ...v1alpha2.Tag) ([]types.Subnet, error)

AutodiscoverPrivateSubnets attempts to automatically return a slice of ROSA cluster private subnet ids. A ROSA cluster's subnets are tagged with a tag key in AWS: "kubernetes.io/cluster/<cluster-name>". Private subnets for non-BYOVPC clusters also have the `kubernetes.io/role/internal-elb` tag key.

func (*AWSClient) ChangeTagsForResource

ChangeTagsForResource adds, edits, or deletes tags for a health check or a hosted zone.

func (*AWSClient) CreateDefaultInterfaceVPCEndpoint

func (c *AWSClient) CreateDefaultInterfaceVPCEndpoint(ctx context.Context, name, vpcId, serviceName, tagKey string) (*ec2.CreateVpcEndpointOutput, error)

CreateDefaultInterfaceVPCEndpoint creates an interface VPC endpoint with the default (open to all) VPC Endpoint policy. It attaches no security groups nor associates the VPC Endpoint with any subnets.

func (*AWSClient) CreateHostedZone

func (c *AWSClient) CreateHostedZone(ctx context.Context, domain, vpcId, region string) (*route53.CreateHostedZoneOutput, error)

CreateHostedZone creates a Route 53 Private Hosted Zone with the specified domain, associated to the specified vpcId + region.

func (*AWSClient) CreateSecurityGroup

func (c *AWSClient) CreateSecurityGroup(ctx context.Context, name, vpcId, tagKey string) (*ec2.CreateSecurityGroupOutput, error)

CreateSecurityGroup creates a security group with the specified name and cluster tag key in a specified VPC

func (*AWSClient) CreateTags

func (c *AWSClient) CreateTags(ctx context.Context, input *ec2.CreateTagsInput) (*ec2.CreateTagsOutput, error)

CreateTags creates tags in an idempotent fashion

func (*AWSClient) CreateVPCAssociationAuthorization

func (c *AWSClient) CreateVPCAssociationAuthorization(ctx context.Context, hostedZoneId, vpcId, region string) (*route53.CreateVPCAssociationAuthorizationOutput, error)

func (*AWSClient) DeleteHostedZone

func (c *AWSClient) DeleteHostedZone(ctx context.Context, id string) (*route53.DeleteHostedZoneOutput, error)

DeleteHostedZone deletes a Route 53 Hosted Zone by ID

func (*AWSClient) DeleteResourceRecordSet

func (c *AWSClient) DeleteResourceRecordSet(ctx context.Context, rrs *types.ResourceRecordSet, hostedZoneId string) (*route53.ChangeResourceRecordSetsOutput, error)

DeleteResourceRecordSet deletes a specific record from a hosted zone NOTE: To delete a resource record set, you must specify all the same values that you specified when you created it.

func (*AWSClient) DeleteSecurityGroup

func (c *AWSClient) DeleteSecurityGroup(ctx context.Context, groupId string) (*ec2.DeleteSecurityGroupOutput, error)

DeleteSecurityGroup deletes a security group with the specified ID

func (*AWSClient) DeleteVPCEndpoint

func (c *AWSClient) DeleteVPCEndpoint(ctx context.Context, id string) (*ec2.DeleteVpcEndpointsOutput, error)

DeleteVPCEndpoint deletes a VPC endpoint with the given id.

func (*AWSClient) DescribeSecurityGroupRules

func (c *AWSClient) DescribeSecurityGroupRules(ctx context.Context, groupId string) (*ec2.DescribeSecurityGroupRulesOutput, error)

DescribeSecurityGroupRules describes the security group rules attached to a specific security group id

func (*AWSClient) DescribeSingleVPCEndpointById

func (c *AWSClient) DescribeSingleVPCEndpointById(ctx context.Context, id string) (*ec2.DescribeVpcEndpointsOutput, error)

DescribeSingleVPCEndpointById returns information about a VPC endpoint with a given id.

func (*AWSClient) DescribeSubnetsByTags

func (c *AWSClient) DescribeSubnetsByTags(ctx context.Context, tags ...v1alpha2.Tag) (*ec2.DescribeSubnetsOutput, error)

DescribeSubnetsByTags returns a list of subnets filtered by the provided tags If there is no value in the provided tag, filtering is done by tag-key only

func (*AWSClient) FetchPrivateZoneTags

func (c *AWSClient) FetchPrivateZoneTags(ctx context.Context, zoneId string) (*route53.ListTagsForResourceOutput, error)

FetchPrivateZoneTags takes context and a Route53 ZoneID and returns the output provided by ListTagsForResource for a hosted zone

func (*AWSClient) FilterClusterNodeSecurityGroupsByDefaultTags

func (c *AWSClient) FilterClusterNodeSecurityGroupsByDefaultTags(ctx context.Context, infraName string) (*ec2.DescribeSecurityGroupsOutput, error)

FilterClusterNodeSecurityGroupsByDefaultTags describes the security groups attached to the cluster nodes by filtering by the clusterTag and expected Name tags

func (*AWSClient) FilterSecurityGroupByDefaultTags

func (c *AWSClient) FilterSecurityGroupByDefaultTags(ctx context.Context, infraName, sgNameTag string) (*ec2.DescribeSecurityGroupsOutput, error)

FilterSecurityGroupByDefaultTags describes the security group attached to the VPC Endpoint this operator manages by filtering by the clusterTag and operator tag

func (*AWSClient) FilterSecurityGroupById

func (c *AWSClient) FilterSecurityGroupById(ctx context.Context, groupId string) (*ec2.DescribeSecurityGroupsOutput, error)

FilterSecurityGroupById describes a specific security group by ID

func (*AWSClient) FilterVPCEndpointByDefaultTags

func (c *AWSClient) FilterVPCEndpointByDefaultTags(ctx context.Context, clusterTag, vpceNameTag string) (*ec2.DescribeVpcEndpointsOutput, error)

FilterVPCEndpointByDefaultTags returns information about a VPC endpoint with the default expected tags.

func (*AWSClient) FilterVpcIdsByTags

func (c *AWSClient) FilterVpcIdsByTags(ctx context.Context, tags []avov1alpha2.Tag) ([]string, error)

FilterVpcIdsByTags tags in a list of tags and returns a list of AWS VPC Ids that have all of the provided tags

func (*AWSClient) GenerateDefaultTagsForHostedZoneInput

func (c *AWSClient) GenerateDefaultTagsForHostedZoneInput(zoneId, clusterTagKey string) (*route53.ChangeTagsForResourceInput, error)

GenerateDefaultTagsForHostedZoneInput generates the ChangeTagsForResourceInput using the default tags for the zoneId

func (*AWSClient) GetDefaultPrivateHostedZoneId

func (c *AWSClient) GetDefaultPrivateHostedZoneId(ctx context.Context, domainName, vpcId, region string) (*types.HostedZoneSummary, error)

GetDefaultPrivateHostedZoneId returns the cluster's Route53 private hosted zone

func (*AWSClient) GetHostedZone

func (c *AWSClient) GetHostedZone(ctx context.Context, id string) (*route53.GetHostedZoneOutput, error)

GetHostedZone is a wrapper around Route53 GetHostedZone

func (*AWSClient) GetVPCId

func (c *AWSClient) GetVPCId(ctx context.Context, subnetIds []string) (string, error)

GetVPCId returns the VPC ID of the provided subnetIds. Returns an error if the subnets are not in the same VPC.

func (*AWSClient) GetVpcEndpointServiceAZs

func (c *AWSClient) GetVpcEndpointServiceAZs(ctx context.Context, serviceName string) ([]string, error)

GetVpcEndpointServiceAZs returns a slice of strings indicating which AZs the specified VPC Endpoint Service supports

func (*AWSClient) ListHostedZonesByVPC

func (c *AWSClient) ListHostedZonesByVPC(ctx context.Context, vpc, region string) (*route53.ListHostedZonesByVPCOutput, error)

ListHostedZonesByVPC is a wrapper around route53:ListHostedZonesByVPC

func (*AWSClient) ListResourceRecordSets

func (c *AWSClient) ListResourceRecordSets(ctx context.Context, hostedZoneId string) (*route53.ListResourceRecordSetsOutput, error)

ListResourceRecordSets returns a list of records for a given hosted zone ID

func (*AWSClient) ListTagsForResource

ListTagsForResource will fetch tags of a hosted zone or healthcheck

func (*AWSClient) ModifyVpcEndpoint

func (c *AWSClient) ModifyVpcEndpoint(ctx context.Context, input *ec2.ModifyVpcEndpointInput) (*ec2.ModifyVpcEndpointOutput, error)

ModifyVpcEndpoint modifies a VPC endpoint

func (*AWSClient) SelectVPCForVPCEndpoint

func (c *AWSClient) SelectVPCForVPCEndpoint(ctx context.Context, ids ...string) (string, error)

SelectVPCForVPCEndpoint uses a "least connection" strategy to place a VPC Endpoint in the provided VPC ID with the fewest existing VPC Endpoints in it to balance out quota usage. https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html#vpc-limits-endpoints

func (*AWSClient) UpsertResourceRecordSet

func (c *AWSClient) UpsertResourceRecordSet(ctx context.Context, rrs *types.ResourceRecordSet, hostedZoneId string) (*route53.ChangeResourceRecordSetsOutput, error)

UpsertResourceRecordSet updates or creates a resource record set

type AvoEC2API

type AvoEC2API interface {
	AuthorizeSecurityGroupEgress(ctx context.Context, params *ec2.AuthorizeSecurityGroupEgressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupEgressOutput, error)
	AuthorizeSecurityGroupIngress(ctx context.Context, params *ec2.AuthorizeSecurityGroupIngressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)
	CreateSecurityGroup(ctx context.Context, params *ec2.CreateSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)
	DeleteSecurityGroup(ctx context.Context, params *ec2.DeleteSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error)
	DescribeSecurityGroups(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)
	DescribeSecurityGroupRules(ctx context.Context, params *ec2.DescribeSecurityGroupRulesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupRulesOutput, error)

	DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)
	DescribeVpcs(ctx context.Context, params *ec2.DescribeVpcsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error)

	CreateTags(ctx context.Context, params *ec2.CreateTagsInput, optFns ...func(*ec2.Options)) (*ec2.CreateTagsOutput, error)

	CreateVpcEndpoint(ctx context.Context, params *ec2.CreateVpcEndpointInput, optFns ...func(*ec2.Options)) (*ec2.CreateVpcEndpointOutput, error)
	DeleteVpcEndpoints(ctx context.Context, params *ec2.DeleteVpcEndpointsInput, optFns ...func(*ec2.Options)) (*ec2.DeleteVpcEndpointsOutput, error)
	DescribeVpcEndpoints(ctx context.Context, params *ec2.DescribeVpcEndpointsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointsOutput, error)
	ModifyVpcEndpoint(ctx context.Context, params *ec2.ModifyVpcEndpointInput, optFns ...func(*ec2.Options)) (*ec2.ModifyVpcEndpointOutput, error)

	DescribeVpcEndpointServices(ctx context.Context, params *ec2.DescribeVpcEndpointServicesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointServicesOutput, error)
}

AvoEC2API defines the subset of the AWS EC2 API that AVO needs to interact with

type AvoRoute53API

type AvoRoute53API interface {
	ChangeResourceRecordSets(ctx context.Context, params *route53.ChangeResourceRecordSetsInput, optFns ...func(*route53.Options)) (*route53.ChangeResourceRecordSetsOutput, error)
	ChangeTagsForResource(ctx context.Context, input *route53.ChangeTagsForResourceInput, optFns ...func(*route53.Options)) (*route53.ChangeTagsForResourceOutput, error)
	CreateHostedZone(ctx context.Context, params *route53.CreateHostedZoneInput, optFns ...func(*route53.Options)) (*route53.CreateHostedZoneOutput, error)
	CreateVPCAssociationAuthorization(ctx context.Context, params *route53.CreateVPCAssociationAuthorizationInput, optFns ...func(*route53.Options)) (*route53.CreateVPCAssociationAuthorizationOutput, error)
	DeleteHostedZone(ctx context.Context, params *route53.DeleteHostedZoneInput, optFns ...func(*route53.Options)) (*route53.DeleteHostedZoneOutput, error)
	GetHostedZone(ctx context.Context, params *route53.GetHostedZoneInput, optFns ...func(*route53.Options)) (*route53.GetHostedZoneOutput, error)
	ListHostedZonesByVPC(ctx context.Context, params *route53.ListHostedZonesByVPCInput, optFns ...func(*route53.Options)) (*route53.ListHostedZonesByVPCOutput, error)
	ListResourceRecordSets(ctx context.Context, params *route53.ListResourceRecordSetsInput, optFns ...func(*route53.Options)) (*route53.ListResourceRecordSetsOutput, error)
	ListTagsForResource(ctx context.Context, params *route53.ListTagsForResourceInput, optFns ...func(*route53.Options)) (*route53.ListTagsForResourceOutput, error)
}

AvoRoute53API defines the subset of the AWS Route53 API that AVO needs to interact with

type AvoVpcEndpointAcceptanceEc2Api

type AvoVpcEndpointAcceptanceEc2Api interface {
	AcceptVpcEndpointConnections(ctx context.Context, params *ec2.AcceptVpcEndpointConnectionsInput, optFns ...func(*ec2.Options)) (*ec2.AcceptVpcEndpointConnectionsOutput, error)
	DescribeVpcEndpointConnections(ctx context.Context, params *ec2.DescribeVpcEndpointConnectionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointConnectionsOutput, error)
}

type MockedEC2

type MockedEC2 struct {
	AvoEC2API

	Subnets []*ec2Types.Subnet
}

func NewMockedEC2WithSubnets

func NewMockedEC2WithSubnets() *MockedEC2

func (*MockedEC2) AcceptVpcEndpointConnections

func (m *MockedEC2) AcceptVpcEndpointConnections(ctx context.Context, params *ec2.AcceptVpcEndpointConnectionsInput, optFns ...func(*ec2.Options)) (*ec2.AcceptVpcEndpointConnectionsOutput, error)

func (*MockedEC2) AuthorizeSecurityGroupEgress

func (m *MockedEC2) AuthorizeSecurityGroupEgress(ctx context.Context, params *ec2.AuthorizeSecurityGroupEgressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupEgressOutput, error)

func (*MockedEC2) AuthorizeSecurityGroupIngress

func (m *MockedEC2) AuthorizeSecurityGroupIngress(ctx context.Context, params *ec2.AuthorizeSecurityGroupIngressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)

func (*MockedEC2) CreateSecurityGroup

func (m *MockedEC2) CreateSecurityGroup(ctx context.Context, params *ec2.CreateSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)

func (*MockedEC2) CreateTags

func (m *MockedEC2) CreateTags(ctx context.Context, params *ec2.CreateTagsInput, optFns ...func(*ec2.Options)) (*ec2.CreateTagsOutput, error)

func (*MockedEC2) CreateVpcEndpoint

func (m *MockedEC2) CreateVpcEndpoint(ctx context.Context, params *ec2.CreateVpcEndpointInput, optFns ...func(*ec2.Options)) (*ec2.CreateVpcEndpointOutput, error)

func (*MockedEC2) DeleteSecurityGroup

func (m *MockedEC2) DeleteSecurityGroup(ctx context.Context, params *ec2.DeleteSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error)

func (*MockedEC2) DeleteVpcEndpoints

func (m *MockedEC2) DeleteVpcEndpoints(ctx context.Context, params *ec2.DeleteVpcEndpointsInput, optFns ...func(*ec2.Options)) (*ec2.DeleteVpcEndpointsOutput, error)

func (*MockedEC2) DescribeSecurityGroupRules

func (m *MockedEC2) DescribeSecurityGroupRules(ctx context.Context, params *ec2.DescribeSecurityGroupRulesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupRulesOutput, error)

func (*MockedEC2) DescribeSecurityGroups

func (m *MockedEC2) DescribeSecurityGroups(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)

func (*MockedEC2) DescribeSubnets

func (m *MockedEC2) DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)

func (*MockedEC2) DescribeVpcEndpointConnections

func (m *MockedEC2) DescribeVpcEndpointConnections(ctx context.Context, params *ec2.DescribeVpcEndpointConnectionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointConnectionsOutput, error)

func (*MockedEC2) DescribeVpcEndpoints

func (m *MockedEC2) DescribeVpcEndpoints(ctx context.Context, params *ec2.DescribeVpcEndpointsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointsOutput, error)

func (*MockedEC2) ModifyVpcEndpoint

func (m *MockedEC2) ModifyVpcEndpoint(ctx context.Context, params *ec2.ModifyVpcEndpointInput, optFns ...func(*ec2.Options)) (*ec2.ModifyVpcEndpointOutput, error)

type MockedRoute53

type MockedRoute53 struct {
	AvoRoute53API
}

func (*MockedRoute53) ChangeResourceRecordSets

func (m *MockedRoute53) ChangeResourceRecordSets(ctx context.Context, params *route53.ChangeResourceRecordSetsInput, optFns ...func(*route53.Options)) (*route53.ChangeResourceRecordSetsOutput, error)

func (*MockedRoute53) ListHostedZonesByName

func (m *MockedRoute53) ListHostedZonesByName(ctx context.Context, params *route53.ListHostedZonesByNameInput, optFns ...func(*route53.Options)) (*route53.ListHostedZonesByNameOutput, error)

func (*MockedRoute53) ListResourceRecordSets

func (m *MockedRoute53) ListResourceRecordSets(ctx context.Context, params *route53.ListResourceRecordSetsInput, optFns ...func(*route53.Options)) (*route53.ListResourceRecordSetsOutput, error)

type VpcAssociationAPI

type VpcAssociationAPI interface {
	AssociateVPCWithHostedZone(ctx context.Context, params *route53.AssociateVPCWithHostedZoneInput, optFns ...func(*route53.Options)) (*route53.AssociateVPCWithHostedZoneOutput, error)
}

type VpcAssociationClient

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

func NewVpcAssociationClient

func NewVpcAssociationClient(cfg aws.Config) *VpcAssociationClient

NewVpcAssociationClient returns a VpcAssociationClient with the provided session

func NewVpcAssociationClientWithServiceClients

func NewVpcAssociationClientWithServiceClients(r53 VpcAssociationAPI) *VpcAssociationClient

NewVpcAssociationClientWithServiceClients returns an VpcAssociationClient with the provided Route53 client. Typically, not used directly except for building a mock for testing.

func (*VpcAssociationClient) AssociateVPCWithHostedZone

func (a *VpcAssociationClient) AssociateVPCWithHostedZone(ctx context.Context, hostedZoneId, vpcId, region string) (*route53.AssociateVPCWithHostedZoneOutput, error)

type VpcEndpointAcceptanceAWSClient

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

func NewMockedVpceAcceptanceAwsClient

func NewMockedVpceAcceptanceAwsClient() *VpcEndpointAcceptanceAWSClient

func NewVpcEndpointAcceptanceAwsClient

func NewVpcEndpointAcceptanceAwsClient(cfg aws.Config) *VpcEndpointAcceptanceAWSClient

NewVpcEndpointAcceptanceAwsClient returns an VpcEndpointAcceptanceAWSClient with the provided session

func NewVpcEndpointAcceptanceAwsClientWithServiceClients

func NewVpcEndpointAcceptanceAwsClientWithServiceClients(ec2 AvoVpcEndpointAcceptanceEc2Api) *VpcEndpointAcceptanceAWSClient

NewVpcEndpointAcceptanceAwsClientWithServiceClients returns a VpcEndpointAcceptanceAWSClient with the provided EC2 client. Typically, not used directly except for building a mock for testing.

func (*VpcEndpointAcceptanceAWSClient) AcceptVpcEndpointConnections

func (c *VpcEndpointAcceptanceAWSClient) AcceptVpcEndpointConnections(ctx context.Context, serviceId string, vpcEndpointIds ...string) (*ec2.AcceptVpcEndpointConnectionsOutput, error)

AcceptVpcEndpointConnections is a wrapper around ec2:AcceptVpcEndpointConnections for a give VPC Endpoint serviceId and a slice of vpcEndpointIds

func (*VpcEndpointAcceptanceAWSClient) GetVpcEndpointConnectionsPendingAcceptance

func (c *VpcEndpointAcceptanceAWSClient) GetVpcEndpointConnectionsPendingAcceptance(ctx context.Context, id string) (*ec2.DescribeVpcEndpointConnectionsOutput, error)

GetVpcEndpointConnectionsPendingAcceptance returns information about a VPC endpoint with a given id.

Jump to

Keyboard shortcuts

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