Documentation
¶
Index ¶
- type AWSConnectionConfig
- type EC2IPAMAPI
- type Provider
- func (p *Provider) AllocateBlockInCloud(ctx context.Context, conn *store.CloudConnection, poolExternalID string, ...) (externalID string, err error)
- func (p *Provider) CreateAllocationInCloud(ctx context.Context, conn *store.CloudConnection, blockExternalID string, ...) (externalID string, err error)
- func (p *Provider) CreatePoolInCloud(ctx context.Context, conn *store.CloudConnection, pool *network.Pool, ...) (externalID string, err error)
- func (p *Provider) DeleteAllocationInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
- func (p *Provider) DeleteBlockInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
- func (p *Provider) DeletePoolInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
- func (p *Provider) ProviderID() string
- func (p *Provider) SupportsAllocations() bool
- func (p *Provider) SupportsBlocks() bool
- func (p *Provider) SupportsPools() bool
- func (p *Provider) SupportsPush() bool
- func (p *Provider) SyncAllocations(ctx context.Context, conn *store.CloudConnection, s store.Storer, ...) (*integrations.AllocationSyncResult, error)
- func (p *Provider) SyncBlocks(ctx context.Context, conn *store.CloudConnection, s store.Storer) (*integrations.BlockSyncResult, error)
- func (p *Provider) SyncPools(ctx context.Context, conn *store.CloudConnection) (*integrations.PoolSyncResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSConnectionConfig ¶
type AWSConnectionConfig struct {
// Region is the AWS region for the EC2/IPAM API (e.g. "us-east-1").
Region string `json:"region"`
// IpamScopeId optionally limits sync to pools in this IPAM scope (private or public).
IpamScopeId string `json:"ipam_scope_id,omitempty"`
// EnvironmentID is the app environment to attach synced pools (and blocks) to.
EnvironmentID uuid.UUID `json:"environment_id,omitempty"`
// SyncPools, SyncBlocks, SyncAllocations control which resource types are synced (pull and push). Nil or true = sync; false = skip. Default all true.
SyncPools *bool `json:"sync_pools,omitempty"`
SyncBlocks *bool `json:"sync_blocks,omitempty"`
SyncAllocations *bool `json:"sync_allocations,omitempty"`
}
AWSConnectionConfig is the config stored in CloudConnection.Config for provider "aws".
func ParseAWSConfig ¶
func ParseAWSConfig(config []byte) (*AWSConnectionConfig, error)
ParseAWSConfig parses conn.Config into AWSConnectionConfig. Returns nil if invalid.
func (*AWSConnectionConfig) SyncResources ¶
func (c *AWSConnectionConfig) SyncResources() (pools, blocks, allocations bool)
SyncResources returns whether to sync pools, blocks, and allocations. Defaults to true when unset.
type EC2IPAMAPI ¶
type EC2IPAMAPI interface {
DescribeIpamPools(ctx context.Context, input *ec2.DescribeIpamPoolsInput) ([]ec2types.IpamPool, error)
GetIpamPoolCidrs(ctx context.Context, ipamPoolID string) (string, error)
GetIpamPoolAllocations(ctx context.Context, ipamPoolID string) ([]ec2types.IpamPoolAllocation, error)
DescribeSubnets(ctx context.Context, vpcID string) ([]ec2types.Subnet, error)
}
EC2IPAMAPI abstracts EC2/IPAM API operations used by the provider for sync. Use this interface for dependency injection so tests can mock API calls. See: https://docs.aws.amazon.com/sdk-for-go/v2/developer-guide/unit-testing.html
type Provider ¶
type Provider struct{}
func (*Provider) AllocateBlockInCloud ¶
func (p *Provider) AllocateBlockInCloud(ctx context.Context, conn *store.CloudConnection, poolExternalID string, block *network.Block) (externalID string, err error)
AllocateBlockInCloud allocates the block's CIDR from the IPAM pool and creates a VPC with it; returns the VPC ID (block external_id). If the pool already has a VPC allocation with the same CIDR, returns that VPC ID to avoid duplicates.
func (*Provider) CreateAllocationInCloud ¶
func (p *Provider) CreateAllocationInCloud(ctx context.Context, conn *store.CloudConnection, blockExternalID string, alloc *network.Allocation) (externalID string, err error)
CreateAllocationInCloud creates a subnet in the VPC (block) and returns the subnet ID (allocation external_id). alloc.Block.CIDR is the allocation's CIDR (subnet CIDR). If the VPC already has a subnet with the same CIDR, returns that subnet ID to avoid duplicates.
func (*Provider) CreatePoolInCloud ¶
func (p *Provider) CreatePoolInCloud(ctx context.Context, conn *store.CloudConnection, pool *network.Pool, parentExternalID string) (externalID string, err error)
CreatePoolInCloud creates an IPAM pool in AWS and returns its pool ID (external_id). If a pool already exists in the scope (and parent) with the same Name and optional CIDR, returns that pool ID to avoid duplicates. parentExternalID is the parent pool's AWS pool ID when creating a sub-pool; empty for top-level.
func (*Provider) DeleteAllocationInCloud ¶
func (p *Provider) DeleteAllocationInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
DeleteAllocationInCloud deletes the subnet in AWS (allocation external_id is subnet ID).
func (*Provider) DeleteBlockInCloud ¶
func (p *Provider) DeleteBlockInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
DeleteBlockInCloud deletes the VPC in AWS (block external_id is VPC ID). Skips without error if externalID is not a VPC ID (e.g. legacy ipam-pool-* mistaken as block); caller will still remove the row.
func (*Provider) DeletePoolInCloud ¶
func (p *Provider) DeletePoolInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
DeletePoolInCloud deletes the IPAM pool in AWS. Uses Cascade to delete the pool and its allocations/CIDRs when possible.
func (*Provider) ProviderID ¶
func (*Provider) SupportsAllocations ¶
func (*Provider) SupportsBlocks ¶
func (*Provider) SupportsPools ¶
func (*Provider) SupportsPush ¶
SupportsPush returns true; AWS provider supports write (push to cloud).
func (*Provider) SyncAllocations ¶
func (p *Provider) SyncAllocations(ctx context.Context, conn *store.CloudConnection, s store.Storer, syncedBlocks []*network.Block) (*integrations.AllocationSyncResult, error)
SyncAllocations discovers VPC subnets for each synced block (VPC) and returns allocation create/update diffs.
func (*Provider) SyncBlocks ¶
func (p *Provider) SyncBlocks(ctx context.Context, conn *store.CloudConnection, s store.Storer) (*integrations.BlockSyncResult, error)
SyncBlocks discovers AWS IPAM pool allocations (e.g. VPC CIDRs) and returns block create/update diffs.
func (*Provider) SyncPools ¶
func (p *Provider) SyncPools(ctx context.Context, conn *store.CloudConnection) (*integrations.PoolSyncResult, error)
SyncPools discovers AWS IPAM pools and returns create/update diffs. Pools are returned in top-down order.