s3

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// PutObjectWithContext puts a file to S3.
	PutObjectWithContext(ctx aws.Context, input *s3.PutObjectInput, opts ...request.Option) (*s3.PutObjectOutput, error)
	// GetObjectWithContext gets a file from S3.
	GetObjectWithContext(ctx aws.Context, input *s3.GetObjectInput, opts ...request.Option) (*s3.GetObjectOutput, error)
}

Client is an abstraction layer for AWS S3 API. It is intended to be replaced with a mock for testing.

type Config

type Config struct {
	// Name of the bucket.
	Bucket string `hcl:"bucket"`
	// Path to the migration history file.
	Key string `hcl:"key"`

	// AWS region.
	Region string `hcl:"region,optional"`
	// Custom endpoint for the AWS S3 API.
	Endpoint string `hcl:"endpoint,optional"`
	// AWS access key.
	AccessKey string `hcl:"access_key,optional"`
	// AWS secret key.
	SecretKey string `hcl:"secret_key,optional"`
	// Name of AWS profile in AWS shared credentials file.
	Profile string `hcl:"profile,optional"`
	// Amazon Resource Name (ARN) of the IAM Role to assume.
	RoleARN string `hcl:"role_arn,optional"`
	// Skip credentials validation via the STS API.
	SkipCredentialsValidation bool `hcl:"skip_credentials_validation,optional"`
	// Skip usage of EC2 Metadata API.
	SkipMetadataAPICheck bool `hcl:"skip_metadata_api_check,optional"`
	// Enable path-style S3 URLs (https://<HOST>/<BUCKET>
	// instead of https://<BUCKET>.<HOST>).
	ForcePathStyle bool `hcl:"force_path_style,optional"`
	// SSE KMS Key Id for optional server-side encryption enablement
	KmsKeyID string `hcl:"kms_key_id,optional"`
}

Config is a config for s3 storage. This is expected to have almost the same options as Terraform s3 backend. https://www.terraform.io/docs/backends/types/s3.html However, it has many minor options and it's a pain to test all options from first, so we added only options we need for now.

func (*Config) NewStorage

func (c *Config) NewStorage() (storage.Storage, error)

NewStorage returns a new instance of storage.Storage.

type Storage

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

Storage is a storage.Storage implementation for AWS S3.

func NewStorage

func NewStorage(config *Config, client Client) (*Storage, error)

NewStorage returns a new instance of Storage.

func (*Storage) Read

func (s *Storage) Read(ctx context.Context) ([]byte, error)

Read reads migration history data from storage. If the key does not exist, it is assumed to be uninitialized and returns an empty array instead of an error.

func (*Storage) Write

func (s *Storage) Write(ctx context.Context, b []byte) error

Write writes migration history data to storage.

Jump to

Keyboard shortcuts

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