Help us shape the future of Go! Take the 2026 Go Developer Survey

replicator

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package replicator copies resources from a source AWS account or endpoint into a running Gopherstack through the public SDK APIs on both sides.

Index

Constants

View Source
const (
	TypeKMS         = "kms"
	TypeIAM         = "iam"
	TypeLogs        = "logs"
	TypeKinesis     = "kinesis"
	TypeS3          = "s3"
	TypeDynamoDB    = "dynamodb"
	TypeSSM         = "ssm"
	TypeSecrets     = "secretsmanager"
	TypeSQS         = "sqs"
	TypeLambda      = "lambda"
	TypeSNS         = "sns"
	TypeEventBridge = "eventbridge"
)

Resource type names accepted by Config.Types.

View Source
const (
	ActionCreated = "created"
	ActionUpdated = "updated"
	ActionSkipped = "skipped"
	ActionFailed  = "failed"
)

Result actions.

Variables

View Source
var ErrUnknownType = errors.New("unknown resource type")

ErrUnknownType is returned for a resource type the replicator does not support.

Functions

func OrderQueues

func OrderQueues(names []string, dlqOf map[string]string) []string

OrderQueues returns names with every dead-letter queue ahead of the queues that redrive to it. dlqOf maps a queue name to its DLQ name ("" when none); cycles are broken arbitrarily.

func OrderTypes

func OrderTypes(selected []string) ([]string, error)

OrderTypes validates selected (empty means all) and returns it in dependency order.

func TypeOrder

func TypeOrder() []string

TypeOrder lists every supported type in dependency order: keys and roles before the resources that reference them, queues and functions before topics, rules last.

Types

type Config

type Config struct {
	Progress       func(Result)
	Identifier     string
	Source         Endpoint
	Target         Endpoint
	Types          []string
	MaxObjectBytes int64
	DryRun         bool
	IncludeData    bool
	WithDecryption bool
}

Config describes one replication run.

type Endpoint

type Endpoint struct {
	Profile         string `json:"profile,omitempty"`
	URL             string `json:"endpoint,omitempty"`
	Region          string `json:"region,omitempty"`
	AccessKeyID     string `json:"access_key_id,omitempty"`
	SecretAccessKey string `json:"secret_access_key,omitempty"`
	SessionToken    string `json:"session_token,omitempty"`
}

Endpoint locates one side of the replication. Static credentials are never logged or persisted.

type Remapper

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

Remapper rewrites source account, region and replicated KMS key ids to target values.

func NewRemapper

func NewRemapper(srcAccount, srcRegion, dstAccount, dstRegion string) *Remapper

NewRemapper builds a Remapper. An empty source account disables account remapping.

func (*Remapper) ARN

func (m *Remapper) ARN(s string) string

ARN remaps one ARN; non-ARNs and foreign-account ARNs are returned unchanged.

func (*Remapper) KeyRef

func (m *Remapper) KeyRef(ref string) (string, bool)

KeyRef maps a KMS key reference (id, key ARN or alias) to its target form. Aliases pass through (the kms type replicates them); AWS-managed aliases and unreplicated keys report false.

func (*Remapper) MapKey

func (m *Remapper) MapKey(src, dst string)

MapKey records that source key id src was replicated as dst.

func (*Remapper) Text

func (m *Remapper) Text(s string) string

Text remaps every ARN embedded in s (policy documents, JSON attributes) and quoted bare account ids.

type Report

type Report struct {
	Counts        map[string]int `json:"counts"`
	SourceAccount string         `json:"source_account,omitempty"`
	TargetAccount string         `json:"target_account,omitempty"`
	Results       []Result       `json:"results"`
	DryRun        bool           `json:"dry_run"`
}

Report is the outcome of a run. In a dry run, actions are what would happen.

func Run

func Run(ctx context.Context, cfg Config) (*Report, error)

Run replicates the configured resource types and returns the per-resource report.

func (*Report) Failed

func (r *Report) Failed() bool

Failed reports whether any resource failed.

type Result

type Result struct {
	Type   string `json:"type"`
	ID     string `json:"id"`
	Action string `json:"action"`
	Reason string `json:"reason,omitempty"`
}

Result is the outcome for one resource.

Jump to

Keyboard shortcuts

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