postgresresource

package
v0.15.11 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package postgresresource implements a custom resource for Postgres

Index

Constants

This section is empty.

Variables

View Source
var ErrMasterArnUpdateNotSupported = errors.New("changing the MasterSecretArn for an update is not supported")

ErrMasterArnUpdateNotSupported is returned when the master arn is updated, which is not supported.

Functions

func Prod

func Prod(version string) fx.Option

Prod dependency setup.

func Test

func Test() fx.Option

Test dependency setup.

Types

type Config

type Config struct{}

Config configures the handler from env.

type Handler

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

Handler handles custom resource requests for Fastly.

func New

func New(
	cfg Config,
	logs *zap.Logger,

	smc SecretsManager,
) (*Handler, error)

New inits the handler.

func (Handler) Handle

func (h Handler) Handle(ctx context.Context, in Input) (out Output, err error)

Handle lambda input.

func (Handler) OnOtherDB

func (h Handler) OnOtherDB(
	ctx context.Context, dbcfg *pgx.ConnConfig, dbName string, run func(ctx context.Context, conn *pgx.Conn) error,
) error

OnOtherDB runs code with a connection to another database on the cluster.

type Input

type Input cfn.Event

Input into the handler.

type Output

type Output struct {
	// The allocated/assigned physical ID of the resource. If omitted for Create events, the event's RequestId
	// will be used. For Update, the current physical ID will be used. If a different value is returned,
	// CloudFormation will follow with a subsequent Delete for the previous ID (resource replacement).
	// For Delete, it will always return the current physical resource ID, and if the user returns a different one,
	// an error will occur.
	PhysicalResourceID string `json:"PhysicalResourceId"`
	// Resource attributes, which can later be retrieved through Fn::GetAtt on the custom resource object.
	Data map[string]any `json:"Data"`
	// Whether to mask the output of the custom resource when retrieved by using the Fn::GetAtt function.
	NoEcho bool `json:"NoEcho"`
}

Output into the handler.

type SecretsManager

type SecretsManager interface {
	GetSecretValue(
		ctx context.Context, params *secretsmanager.GetSecretValueInput, optFns ...func(*secretsmanager.Options),
	) (*secretsmanager.GetSecretValueOutput, error)
}

SecretsManager provides an interface for reading AWS secrets.

type TenantName

type TenantName string

TenantName type provides ways to turn it into identifiers.

func TenantNameFromPhysicalResourceID

func TenantNameFromPhysicalResourceID(prid string) TenantName

TenantNameFromPhysicalResourceID allows us to use the physical resource id as a storage medium of the main property we care about: the tenant name.

func (TenantName) ToDatabaseName

func (n TenantName) ToDatabaseName() string

ToDatabaseName allows consistent database naming based on the tenant.

func (TenantName) ToDatabaseUser

func (n TenantName) ToDatabaseUser() string

ToDatabaseUser allows consistent database naming based on the tenant.

func (TenantName) ToOutputData

func (n TenantName) ToOutputData() map[string]any

ToOutputData consitently produces the output data from the tenant name.

func (TenantName) ToPhysicalResourceID

func (n TenantName) ToPhysicalResourceID() string

ToPhysicalResourceID encodes the properties to physical resource id.

type TenantProperties

type TenantProperties struct {
	// Name of the postgres Tenant and user that will be created
	Name TenantName `mapstructure:"Name" validate:"required,resource_ident"`
	// MasterSecretArn must provide the secret for the database's master user
	MasterSecretArn string `mapstructure:"MasterSecretArn" validate:"required"`
}

TenantProperties that configure the custom resource.

Jump to

Keyboard shortcuts

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