vpc

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package vpc provides an in-memory mock implementation of AWS VPC networking.

Index

Constants

View Source
const (
	TrafficTypeAll    = "ALL"
	TrafficTypeAccept = "ACCEPT"
	TrafficTypeReject = "REJECT"
)

Flow log traffic type constants.

View Source
const (
	IGWStateDetached = "detached"
	IGWStateAttached = "attached"
)

Internet gateway state constants.

View Source
const (
	NATStateAvailable = "available"
	NATStateDeleted   = "deleted"
)

NAT gateway state constants.

View Source
const (
	PeeringStatusPending  = "pending-acceptance"
	PeeringStatusActive   = "active"
	PeeringStatusRejected = "rejected"
	PeeringStatusDeleted  = "deleted"
)

Peering status constants.

View Source
const (
	FlowLogStatusActive = "ACTIVE"
)

Flow log status constants.

View Source
const (
	RouteTargetLocal = "local"
)

Route target type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

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

Mock is an in-memory mock implementation of the AWS VPC networking service.

func New

func New(opts *config.Options) *Mock

New creates a new VPC mock with the given configuration options.

func (*Mock) AcceptPeeringConnection added in v1.2.0

func (m *Mock) AcceptPeeringConnection(_ context.Context, peeringID string) error

AcceptPeeringConnection accepts a pending peering connection.

func (*Mock) AddEgressRule

func (m *Mock) AddEgressRule(_ context.Context, groupID string, rule driver.SecurityRule) error

AddEgressRule adds an egress rule to the specified security group.

func (*Mock) AddIngressRule

func (m *Mock) AddIngressRule(_ context.Context, groupID string, rule driver.SecurityRule) error

AddIngressRule adds an ingress rule to the specified security group.

func (*Mock) AddNetworkACLRule added in v1.2.0

func (m *Mock) AddNetworkACLRule(_ context.Context, aclID string, rule *driver.NetworkACLRule) error

AddNetworkACLRule adds a rule to the specified network ACL, keeping rules sorted by number.

func (*Mock) AllocateAddress added in v1.3.2

func (m *Mock) AllocateAddress(
	_ context.Context, cfg driver.ElasticIPConfig,
) (*driver.ElasticIP, error)

AllocateAddress allocates a new elastic IP address.

func (*Mock) AssociateAddress added in v1.3.2

func (m *Mock) AssociateAddress(
	_ context.Context, allocationID, instanceID string,
) (string, error)

AssociateAddress associates an elastic IP with an instance.

func (*Mock) AssociateRouteTable added in v1.3.2

func (m *Mock) AssociateRouteTable(
	_ context.Context, routeTableID, subnetID string,
) (*driver.RouteTableAssociation, error)

AssociateRouteTable associates a route table with a subnet.

func (*Mock) AttachInternetGateway added in v1.3.2

func (m *Mock) AttachInternetGateway(
	_ context.Context, igwID, vpcID string,
) error

AttachInternetGateway attaches an internet gateway to a VPC.

func (*Mock) CreateFlowLog added in v1.2.0

func (m *Mock) CreateFlowLog(_ context.Context, cfg driver.FlowLogConfig) (*driver.FlowLog, error)

CreateFlowLog creates a flow log for a VPC or subnet resource.

func (*Mock) CreateInternetGateway added in v1.3.2

func (m *Mock) CreateInternetGateway(
	_ context.Context, cfg driver.InternetGatewayConfig,
) (*driver.InternetGateway, error)

CreateInternetGateway creates a new internet gateway.

func (*Mock) CreateNATGateway added in v1.2.0

func (m *Mock) CreateNATGateway(_ context.Context, cfg driver.NATGatewayConfig) (*driver.NATGateway, error)

CreateNATGateway creates a NAT gateway in the specified subnet.

func (*Mock) CreateNetworkACL added in v1.2.0

func (m *Mock) CreateNetworkACL(_ context.Context, vpcID string, tags map[string]string) (*driver.NetworkACL, error)

CreateNetworkACL creates a network ACL for the specified VPC.

func (*Mock) CreatePeeringConnection added in v1.2.0

func (m *Mock) CreatePeeringConnection(
	_ context.Context, cfg driver.PeeringConfig,
) (*driver.PeeringConnection, error)

CreatePeeringConnection creates a VPC peering connection between two VPCs.

func (*Mock) CreateRoute added in v1.2.0

func (m *Mock) CreateRoute(
	_ context.Context, routeTableID, destinationCIDR, targetID, targetType string,
) error

CreateRoute adds a route to the specified route table.

func (*Mock) CreateRouteTable added in v1.2.0

func (m *Mock) CreateRouteTable(_ context.Context, cfg driver.RouteTableConfig) (*driver.RouteTable, error)

CreateRouteTable creates a route table for the specified VPC.

func (*Mock) CreateSecurityGroup

func (m *Mock) CreateSecurityGroup(_ context.Context, cfg driver.SecurityGroupConfig) (*driver.SecurityGroupInfo, error)

CreateSecurityGroup creates a new security group with the given configuration.

func (*Mock) CreateSubnet

func (m *Mock) CreateSubnet(_ context.Context, cfg driver.SubnetConfig) (*driver.SubnetInfo, error)

CreateSubnet creates a new subnet with the given configuration.

func (*Mock) CreateVPC

func (m *Mock) CreateVPC(_ context.Context, cfg driver.VPCConfig) (*driver.VPCInfo, error)

CreateVPC creates a new VPC with the given configuration.

func (*Mock) CreateVPCEndpoint added in v1.4.0

func (m *Mock) CreateVPCEndpoint(
	_ context.Context, cfg driver.VPCEndpointConfig,
) (*driver.VPCEndpoint, error)

CreateVPCEndpoint creates a new VPC endpoint.

func (*Mock) DeleteFlowLog added in v1.2.0

func (m *Mock) DeleteFlowLog(_ context.Context, id string) error

DeleteFlowLog deletes the flow log with the given ID.

func (*Mock) DeleteInternetGateway added in v1.3.2

func (m *Mock) DeleteInternetGateway(
	_ context.Context, id string,
) error

DeleteInternetGateway deletes the internet gateway.

func (*Mock) DeleteNATGateway added in v1.2.0

func (m *Mock) DeleteNATGateway(_ context.Context, id string) error

DeleteNATGateway deletes the NAT gateway with the given ID.

func (*Mock) DeleteNetworkACL added in v1.2.0

func (m *Mock) DeleteNetworkACL(_ context.Context, id string) error

DeleteNetworkACL deletes the network ACL with the given ID.

func (*Mock) DeletePeeringConnection added in v1.2.0

func (m *Mock) DeletePeeringConnection(_ context.Context, peeringID string) error

DeletePeeringConnection deletes a peering connection.

func (*Mock) DeleteRoute added in v1.2.0

func (m *Mock) DeleteRoute(_ context.Context, routeTableID, destinationCIDR string) error

DeleteRoute removes a route from the specified route table.

func (*Mock) DeleteRouteTable added in v1.2.0

func (m *Mock) DeleteRouteTable(_ context.Context, id string) error

DeleteRouteTable deletes the route table with the given ID.

func (*Mock) DeleteSecurityGroup

func (m *Mock) DeleteSecurityGroup(_ context.Context, id string) error

DeleteSecurityGroup deletes the security group with the given ID.

func (*Mock) DeleteSubnet

func (m *Mock) DeleteSubnet(_ context.Context, id string) error

DeleteSubnet deletes the subnet with the given ID.

func (*Mock) DeleteVPC

func (m *Mock) DeleteVPC(_ context.Context, id string) error

DeleteVPC deletes the VPC with the given ID.

func (*Mock) DeleteVPCEndpoint added in v1.4.0

func (m *Mock) DeleteVPCEndpoint(
	_ context.Context, id string,
) error

DeleteVPCEndpoint deletes the VPC endpoint with the given ID.

func (*Mock) DescribeAddresses added in v1.3.2

func (m *Mock) DescribeAddresses(
	_ context.Context, ids []string,
) ([]driver.ElasticIP, error)

DescribeAddresses returns elastic IPs matching the given allocation IDs, or all if ids is empty.

func (*Mock) DescribeFlowLogs added in v1.2.0

func (m *Mock) DescribeFlowLogs(_ context.Context, ids []string) ([]driver.FlowLog, error)

DescribeFlowLogs returns flow logs matching the given IDs, or all if empty.

func (*Mock) DescribeInternetGateways added in v1.3.2

func (m *Mock) DescribeInternetGateways(
	_ context.Context, ids []string,
) ([]driver.InternetGateway, error)

DescribeInternetGateways returns internet gateways matching the given IDs, or all if ids is empty.

func (*Mock) DescribeNATGateways added in v1.2.0

func (m *Mock) DescribeNATGateways(_ context.Context, ids []string) ([]driver.NATGateway, error)

DescribeNATGateways returns NAT gateways matching the given IDs, or all if empty.

func (*Mock) DescribeNetworkACLs added in v1.2.0

func (m *Mock) DescribeNetworkACLs(_ context.Context, ids []string) ([]driver.NetworkACL, error)

DescribeNetworkACLs returns network ACLs matching the given IDs, or all if empty.

func (*Mock) DescribePeeringConnections added in v1.2.0

func (m *Mock) DescribePeeringConnections(
	_ context.Context, ids []string,
) ([]driver.PeeringConnection, error)

DescribePeeringConnections returns peering connections matching the given IDs.

func (*Mock) DescribeRouteTables added in v1.2.0

func (m *Mock) DescribeRouteTables(_ context.Context, ids []string) ([]driver.RouteTable, error)

DescribeRouteTables returns route tables matching the given IDs, or all if empty.

func (*Mock) DescribeSecurityGroups

func (m *Mock) DescribeSecurityGroups(_ context.Context, ids []string) ([]driver.SecurityGroupInfo, error)

DescribeSecurityGroups returns security groups matching the given IDs, or all if ids is empty.

func (*Mock) DescribeSubnets

func (m *Mock) DescribeSubnets(_ context.Context, ids []string) ([]driver.SubnetInfo, error)

DescribeSubnets returns subnets matching the given IDs, or all subnets if ids is empty.

func (*Mock) DescribeVPCEndpoints added in v1.4.0

func (m *Mock) DescribeVPCEndpoints(
	_ context.Context, ids []string,
) ([]driver.VPCEndpoint, error)

DescribeVPCEndpoints returns VPC endpoints matching the given IDs, or all endpoints if ids is empty.

func (*Mock) DescribeVPCs

func (m *Mock) DescribeVPCs(_ context.Context, ids []string) ([]driver.VPCInfo, error)

DescribeVPCs returns VPCs matching the given IDs, or all VPCs if ids is empty.

func (*Mock) DetachInternetGateway added in v1.3.2

func (m *Mock) DetachInternetGateway(
	_ context.Context, igwID, vpcID string,
) error

DetachInternetGateway detaches an internet gateway from a VPC.

func (*Mock) DisassociateAddress added in v1.3.2

func (m *Mock) DisassociateAddress(
	_ context.Context, associationID string,
) error

DisassociateAddress removes an elastic IP association.

func (*Mock) DisassociateRouteTable added in v1.3.2

func (m *Mock) DisassociateRouteTable(
	_ context.Context, associationID string,
) error

DisassociateRouteTable removes a route table association.

func (*Mock) GetFlowLogRecords added in v1.2.0

func (m *Mock) GetFlowLogRecords(
	_ context.Context, flowLogID string, limit int,
) ([]driver.FlowLogRecord, error)

GetFlowLogRecords generates mock flow log records for the given flow log.

func (*Mock) ModifyVPCEndpoint added in v1.4.0

func (m *Mock) ModifyVPCEndpoint(
	_ context.Context, id string, cfg driver.VPCEndpointConfig,
) (*driver.VPCEndpoint, error)

ModifyVPCEndpoint updates a VPC endpoint configuration.

func (*Mock) RejectPeeringConnection added in v1.2.0

func (m *Mock) RejectPeeringConnection(_ context.Context, peeringID string) error

RejectPeeringConnection rejects a pending peering connection.

func (*Mock) ReleaseAddress added in v1.3.2

func (m *Mock) ReleaseAddress(
	_ context.Context, allocationID string,
) error

ReleaseAddress releases an elastic IP address.

func (*Mock) RemoveEgressRule

func (m *Mock) RemoveEgressRule(_ context.Context, groupID string, rule driver.SecurityRule) error

RemoveEgressRule removes a matching egress rule from the specified security group.

func (*Mock) RemoveIngressRule

func (m *Mock) RemoveIngressRule(_ context.Context, groupID string, rule driver.SecurityRule) error

RemoveIngressRule removes a matching ingress rule from the specified security group.

func (*Mock) RemoveNetworkACLRule added in v1.2.0

func (m *Mock) RemoveNetworkACLRule(_ context.Context, aclID string, ruleNumber int, egress bool) error

RemoveNetworkACLRule removes a rule from the specified network ACL by rule number and direction.

Jump to

Keyboard shortcuts

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