Documentation
¶
Overview ¶
Package vpc provides utilities for working with AWS VPCs.
Index ¶
- type Client
- type Config
- type DNSEntry
- type DNSOptions
- type Endpoint
- type EndpointError
- type Option
- type SecurityGroupInfo
- type SubnetIPPrefixes
- type SubnetInfo
- type T
- func (v *T) CreateEndpoint(ctx context.Context, ep Endpoint) (string, error)
- func (v *T) DeleteEndpoint(ctx context.Context, endpointIDs ...string) error
- func (v *T) Describe(ctx context.Context) error
- func (v *T) DescribeEndpoints(ctx context.Context, ids []string, filters ...types.Filter) ([]Endpoint, error)
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
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)
DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)
DescribeSecurityGroups(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)
DescribeVpcEndpoints(ctx context.Context, params *ec2.DescribeVpcEndpointsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcEndpointsOutput, error)
DescribeRouteTables(ctx context.Context, params *ec2.DescribeRouteTablesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRouteTablesOutput, error)
}
Client defines the methods required to manage VPC endpoints.
type Config ¶
type Config struct {
VPCID string `yaml:"vpc_id"`
Subnets []SubnetInfo `yaml:"subnets"`
SecurityGroups []SecurityGroupInfo `yaml:"security_groups"`
RouteTableIDs []string `yaml:"route_table_ids"`
Endpoints []Endpoint `yaml:"endpoints"`
}
Config holds all VPC information required to create and delete endpoints.
type DNSEntry ¶
type DNSEntry struct {
DNSName string `yaml:"dns_name"`
HostedZoneID string `yaml:"hosted_zone_id"`
}
DNSEntry holds the DNS name and hosted zone for a VPC endpoint DNS record.
type DNSOptions ¶
type DNSOptions struct {
DNSRecordIPType types.DnsRecordIpType `yaml:"dns_record_ip_type"`
PrivateDNSOnlyForInboundResolverEndpoint bool `yaml:"private_dns_only_for_inbound_resolver_endpoint"`
PrivateDNSPreference string `yaml:"private_dns_preference"`
PrivateDNSSpecifiedDomains []string `yaml:"private_dns_specified_domains"`
}
DNSOptions holds the DNS configuration for a VPC endpoint.
type Endpoint ¶
type Endpoint struct {
// Core identity
ID string `yaml:"id"`
VPCID string `yaml:"vpc_id"`
OwnerID string `yaml:"owner_id"`
ServiceName string `yaml:"service_name"`
Type types.VpcEndpointType `yaml:"type"`
State types.State `yaml:"state"`
// Networking
SubnetIDs []string `yaml:"subnet_ids"`
SecurityGroupIDs []string `yaml:"security_group_ids"`
RouteTableIDs []string `yaml:"route_table_ids"`
NetworkInterfaceIDs []string `yaml:"network_interface_ids"`
IPAddressType types.IpAddressType `yaml:"ip_address_type"`
IPv4Prefixes []SubnetIPPrefixes `yaml:"ipv4_prefixes"`
IPv6Prefixes []SubnetIPPrefixes `yaml:"ipv6_prefixes"`
// DNS
DNSEntries []DNSEntry `yaml:"dns_entries"`
DNSOptions *DNSOptions `yaml:"dns_options"`
PrivateDNSEnabled bool `yaml:"private_dns_enabled"`
// Policy and routing
PolicyDocument string `yaml:"policy_document"`
// Service topology
ServiceNetworkARN string `yaml:"service_network_arn"`
ServiceRegion string `yaml:"service_region"`
ResourceConfigurationARN string `yaml:"resource_configuration_arn"`
// Management
CreatedAt *time.Time `yaml:"created_at"`
RequesterManaged bool `yaml:"requester_managed"`
FailureReason string `yaml:"failure_reason"`
LastError *EndpointError `yaml:"last_error"`
Tags []Tag `yaml:"tags"`
}
Endpoint describes an existing VPC endpoint, mirroring all fields of types.VpcEndpoint with Go-idiomatic naming and value (not pointer) scalars.
func DescribeEndpoints ¶
DescribeEndpoints returns the VPC endpoints matching the given endpoint IDs and/or filters. optsOrFilters may be a mix of types.Filter and Option values (e.g. WithClient). ids narrows the results to specific endpoint IDs; pass nil to return all. Filters are ANDed together. The context must carry an aws.Config (see awsconfig.ContextWith) unless a client is supplied via WithClient.
func (Endpoint) Params ¶
func (e Endpoint) Params() ec2.CreateVpcEndpointInput
Params returns an ec2.CreateVpcEndpointInput populated from the endpoint's fields. Read-only fields returned by the AWS API (ID, VPCID, OwnerID, State, NetworkInterfaceIDs, DNS entries, creation time, etc.) are not included — only the fields that are meaningful inputs to CreateEndpoint. VpcId is not set; it is supplied by CreateEndpoint from the VPC. ClientToken, DryRun, and SubnetConfigurations are left at their zero values and must be set by the caller if needed.
type EndpointError ¶
EndpointError holds the last error recorded for a VPC endpoint.
type Option ¶
type Option func(*options)
Option represents an option to multiple functions in this package.
func WithClient ¶
WithClient allows callers to specify a custom Client implementation (e.g. for testing). If not provided, a default client will be automatically created from the aws.Config stored in the context (see awsconfig.ContextWith). If a client is provided, the context does not need to carry an aws.Config.
func WithConfig ¶
WithConfig allows callers to specify an aws.Config directly, which will be used to create a default client. If not provided, the aws.Config will be retrieved from the context (see awsconfig.ContextWith) to create the default client. If a config is provided, the context does not need to carry an aws.Config.
type SecurityGroupInfo ¶
SecurityGroupInfo holds the essential details of a security group.
type SubnetIPPrefixes ¶
type SubnetIPPrefixes struct {
SubnetID string `yaml:"subnet_id"`
IPPrefixes []string `yaml:"ip_prefixes"`
}
SubnetIPPrefixes holds the IP prefix allocation for a subnet within an endpoint.
type SubnetInfo ¶
SubnetInfo holds the essential details of a VPC subnet.
type T ¶
type T struct {
Config *Config
// contains filtered or unexported fields
}
T represents a VPC whose configuration can be read via Describe.
func NewVPC ¶
NewVPC creates a new T instance for the given VPC ID using the provided AWS config and options. It will only fail if both WithClient and WithConfig are not provided and the context does not carry an aws.Config.
func (*T) CreateEndpoint ¶
CreateEndpoint creates a VPC endpoint in the VPC. It returns the new endpoint ID. input.VpcId is overwritten with the VPC's ID.
func (*T) DeleteEndpoint ¶
DeleteEndpoint deletes the VPC endpoint with the given ID.