aws

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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 (p *Provider) ProviderID() string

func (*Provider) SupportsAllocations

func (p *Provider) SupportsAllocations() bool

func (*Provider) SupportsBlocks

func (p *Provider) SupportsBlocks() bool

func (*Provider) SupportsPools

func (p *Provider) SupportsPools() bool

func (*Provider) SupportsPush

func (p *Provider) SupportsPush() bool

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

SyncBlocks discovers AWS IPAM pool allocations (e.g. VPC CIDRs) and returns block create/update diffs.

func (*Provider) SyncPools

SyncPools discovers AWS IPAM pools and returns create/update diffs. Pools are returned in top-down order.

Jump to

Keyboard shortcuts

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