awsinfra

package
v0.0.0-...-356e3a7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestTokenNotFound = errors.New("request token not found")

Functions

func EmptyTemplate

func EmptyTemplate() string

func IsNoUpdatesError

func IsNoUpdatesError(err error) bool

func ResolveFunc

func ResolveFunc(raw interface{}, params map[string]string) (string, error)

Types

type CFClient

type CFClient struct {
	CallbackARNs []string
	// contains filtered or unexported fields
}

func NewCFAdapter

func NewCFAdapter(clients *DeployerClients, callbackARNs []string) *CFClient

func NewCFAdapterFromConfig

func NewCFAdapterFromConfig(ctx context.Context, config aws.Config, callbackARNs []string) (*CFClient, error)

func (*CFClient) CancelStackUpdate

func (cf *CFClient) CancelStackUpdate(ctx context.Context, reqToken string, msg *awsinfra_tpb.CancelStackUpdateMessage) error

func (*CFClient) CreateChangeSet

func (cf *CFClient) CreateChangeSet(ctx context.Context, reqToken string, msg *awsinfra_tpb.CreateChangeSetMessage) error

func (*CFClient) CreateNewStack

func (cf *CFClient) CreateNewStack(ctx context.Context, reqToken string, msg *awsinfra_tpb.CreateNewStackMessage) error

func (*CFClient) DeleteStack

func (cf *CFClient) DeleteStack(ctx context.Context, reqToken string, stackName string) error

func (*CFClient) GetChangeSet

func (cf *CFClient) GetChangeSet(ctx context.Context, stackName, changeSetName string) (*ChangeSetStatus, error)

func (*CFClient) GetOneStack

func (cf *CFClient) GetOneStack(ctx context.Context, stackName string) (*StackStatus, error)

func (*CFClient) ImportResources

func (cf *CFClient) ImportResources(ctx context.Context, templateBody string, params []types.Parameter) (*ImportOutput, error)

func (*CFClient) ScaleStack

func (cf *CFClient) ScaleStack(ctx context.Context, reqToken string, msg *awsinfra_tpb.ScaleStackMessage) error

func (*CFClient) UpdateStack

func (cf *CFClient) UpdateStack(ctx context.Context, reqToken string, msg *awsinfra_tpb.UpdateStackMessage) error

type ChangeSetStatus

type ChangeSetStatus struct {
	Status    string
	Lifecycle awsdeployer_pb.CFChangesetLifecycle
}

type DBLite

type DBLite interface {
	PublishEvent(context.Context, o5msg.Message) error
	RequestToClientToken(context.Context, *messaging_j5pb.RequestMetadata) (string, error)
	ClientTokenToRequest(context.Context, string) (*messaging_j5pb.RequestMetadata, error)
}

type DBMigrator

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

func NewDBMigrator

func NewDBMigrator(client SecretsManagerAPI) *DBMigrator

func (*DBMigrator) CleanupPostgresDatabase

func (d *DBMigrator) CleanupPostgresDatabase(ctx context.Context, migrationID string, msg *awsdeployer_pb.PostgresCleanupSpec) error

func (*DBMigrator) UpsertPostgresDatabase

func (d *DBMigrator) UpsertPostgresDatabase(ctx context.Context, migrationID string, msg *awsdeployer_pb.PostgresCreationSpec) error

type DBSecret

type DBSecret struct {
	Username string `json:"dbuser"`
	Password string `json:"dbpass"`
	Hostname string `json:"dbhost"`
	DBName   string `json:"dbname"`
	URL      string `json:"dburl"`
}

type DeferredParameterResolver

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

func NewDeferredParameterResolver

func NewDeferredParameterResolver(elbClient ELBV2API, listenerARN string, desiredCount int32) (*DeferredParameterResolver, error)

func (*DeferredParameterResolver) Resolve

type DeployerClients

type DeployerClients struct {
	CloudFormation CloudFormationAPI
	SNS            SNSAPI
	ELB            ELBV2API
	SecretsManager SecretsManagerAPI
	ECS            ECSAPI
	S3             S3API
	Region         string
	AccountID      string
}

func NewDeployerClientsFromConfig

func NewDeployerClientsFromConfig(ctx context.Context, config aws.Config) (*DeployerClients, error)

type ECSAPI

type ECSAPI interface {
	RunTask(ctx context.Context, params *ecs.RunTaskInput, optFns ...func(*ecs.Options)) (*ecs.RunTaskOutput, error)

	// used by the TasksStoppedWaiter
	ecs.DescribeTasksAPIClient
}

type ECSTaskStateChangeEvent

type ECSTaskStateChangeEvent struct {
	ClusterArn    string                              `json:"clusterArn"`
	TaskArn       string                              `json:"taskArn"`
	LastStatus    string                              `json:"lastStatus"`
	StoppedAt     string                              `json:"stoppedAt"`
	StoppedReason string                              `json:"stoppedReason"`
	StopCode      *string                             `json:"stopCode"`
	Group         *string                             `json:"group"`
	Containers    []ECSTaskStateChangeEvent_Container `json:"containers"`
	StartedBy     string                              `json:"startedBy"`
}

type ECSTaskStateChangeEvent_Container

type ECSTaskStateChangeEvent_Container struct {
	ContainerArn string  `json:"containerArn"`
	LastStatus   string  `json:"lastStatus"`
	Reason       *string `json:"reason"`
	Name         string  `json:"name"`
	ExitCode     *int    `json:"exitCode"`
}

type ECSWorker

type ECSWorker struct {
	awsinfra_tpb.UnimplementedECSRequestTopicServer
	// contains filtered or unexported fields
}

func NewECSWorker

func NewECSWorker(db DBLite, ecsClient ECSAPI) (*ECSWorker, error)

func (*ECSWorker) HandleECSTaskEvent

func (handler *ECSWorker) HandleECSTaskEvent(ctx context.Context, eventID string, taskEvent *ECSTaskStateChangeEvent) error

func (*ECSWorker) RunECSTask

func (handler *ECSWorker) RunECSTask(ctx context.Context, msg *awsinfra_tpb.RunECSTaskMessage) (*emptypb.Empty, error)

type ELBV2API

type ELBV2API interface {
	DescribeRules(ctx context.Context, params *elbv2.DescribeRulesInput, optFns ...func(*elbv2.Options)) (*elbv2.DescribeRulesOutput, error)
}

type FuncJoin

type FuncJoin struct {
	Join   string
	Values []interface{}
}

func (*FuncJoin) MarshalJSON

func (f *FuncJoin) MarshalJSON() ([]byte, error)

func (*FuncJoin) UnmarshalJSON

func (f *FuncJoin) UnmarshalJSON(data []byte) error

type IDBMigrator

type IDBMigrator interface {
	UpsertPostgresDatabase(ctx context.Context, migrationID string, msg *awsdeployer_pb.PostgresCreationSpec) error
	CleanupPostgresDatabase(ctx context.Context, migrationID string, msg *awsdeployer_pb.PostgresCleanupSpec) error
}

type ImportOutput

type ImportOutput struct {
	Imports     []types.ResourceToImport
	NewTemplate string
}

type InfraEvent

type InfraEvent struct {
	Source     string          `json:"source"`
	DetailType string          `json:"detail-type"`
	Detail     json.RawMessage `json:"detail"`
	ID         string          `json:"id"`
}

func (*InfraEvent) Valid

func (ie *InfraEvent) Valid() bool

type InfraWorker

type InfraWorker struct {
	awsinfra_tpb.UnimplementedCloudFormationRequestTopicServer

	*CFClient
	// contains filtered or unexported fields
}

func NewInfraWorker

func NewInfraWorker(db DBLite, adapter *CFClient) *InfraWorker

func (*InfraWorker) CancelStackUpdate

func (cf *InfraWorker) CancelStackUpdate(ctx context.Context, msg *awsinfra_tpb.CancelStackUpdateMessage) (*emptypb.Empty, error)

func (*InfraWorker) CreateChangeSet

func (cf *InfraWorker) CreateChangeSet(ctx context.Context, msg *awsinfra_tpb.CreateChangeSetMessage) (*emptypb.Empty, error)

func (*InfraWorker) CreateNewStack

func (cf *InfraWorker) CreateNewStack(ctx context.Context, msg *awsinfra_tpb.CreateNewStackMessage) (*emptypb.Empty, error)

func (*InfraWorker) HandleCloudFormationEvent

func (cf *InfraWorker) HandleCloudFormationEvent(ctx context.Context, fields map[string]string) error

func (*InfraWorker) ScaleStack

func (*InfraWorker) StabalizeStack

func (cf *InfraWorker) StabalizeStack(ctx context.Context, msg *awsinfra_tpb.StabalizeStackMessage) (*emptypb.Empty, error)

StabalizeStack is sent to check that the stack is ready for a new deployment. It will emit a 'fake' status change event if the stack is in a stable state, so that the deployer can catch up with remote status.

func (*InfraWorker) UpdateStack

type PostgresMigrateWorker

type PostgresMigrateWorker struct {
	awsinfra_tpb.UnimplementedPostgresRequestTopicServer
	awsinfra_tpb.UnimplementedECSReplyTopicServer
	// contains filtered or unexported fields
}

func NewPostgresMigrateWorker

func NewPostgresMigrateWorker(db DBLite, migrator IDBMigrator) *PostgresMigrateWorker

func (*PostgresMigrateWorker) CleanupPostgresDatabase

func (*PostgresMigrateWorker) ECSTaskStatus

func (*PostgresMigrateWorker) MigratePostgresDatabase

func (*PostgresMigrateWorker) UpsertPostgresDatabase

type RawMessageWorker

type RawMessageWorker struct {
	messaging_tpb.UnimplementedRawMessageTopicServer
	// contains filtered or unexported fields
}

func NewRawMessageWorker

func NewRawMessageWorker(cfHandler RawWorkerCFHandler, ecsHandler RawWorkerECSHandler) *RawMessageWorker

func (*RawMessageWorker) HandleInfraJSON

func (worker *RawMessageWorker) HandleInfraJSON(ctx context.Context, payload []byte) error

func (*RawMessageWorker) HandleInfraNonJSON

func (worker *RawMessageWorker) HandleInfraNonJSON(ctx context.Context, payload []byte) error

func (*RawMessageWorker) Raw

type RawWorkerCFHandler

type RawWorkerCFHandler interface {
	HandleCloudFormationEvent(ctx context.Context, payload map[string]string) error
}

type RawWorkerECSHandler

type RawWorkerECSHandler interface {
	HandleECSTaskEvent(ctx context.Context, eventID string, event *ECSTaskStateChangeEvent) error
}

type Resource

type Resource struct {
	Type           string                 `json:"Type"`
	DeletionPolicy string                 `json:"DeletionPolicy,omitempty"`
	Properties     map[string]interface{} `json:"Properties,omitempty"`
}

type S3API

type S3API interface {
	PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	GetBucketLocation(ctx context.Context, params *s3.GetBucketLocationInput, optFns ...func(*s3.Options)) (*s3.GetBucketLocationOutput, error)
}

type SNSAPI

type SNSAPI interface {
	CreateTopic(ctx context.Context, params *sns.CreateTopicInput, optsFns ...func(*sns.Options)) (*sns.CreateTopicOutput, error)
}

type StackArgs

type StackArgs struct {
	Template   *awsdeployer_pb.DeploymentState
	Parameters []types.Parameter
}

type StackStatus

type StackStatus struct {
	StackStatus types.StackStatus
	SummaryType awsdeployer_pb.CFLifecycle
	IsOK        bool
	Stable      bool
	Parameters  []*awsdeployer_pb.KeyValue
	Outputs     []*awsdeployer_pb.KeyValue
}

type Storage

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

func NewStorage

func NewStorage(conn sqrlx.Connection) (*Storage, error)

func (*Storage) ClientTokenToRequest

func (s *Storage) ClientTokenToRequest(ctx context.Context, token string) (*messaging_j5pb.RequestMetadata, error)

func (*Storage) PublishEvent

func (s *Storage) PublishEvent(ctx context.Context, msg o5msg.Message) error

func (*Storage) RequestToClientToken

func (s *Storage) RequestToClientToken(ctx context.Context, req *messaging_j5pb.RequestMetadata) (string, error)

type Template

type Template struct {
	AWSTemplateFormatVersion string                 `json:"AWSTemplateFormatVersion"`
	Resources                map[string]Resource    `json:"Resources"`
	Parameters               map[string]interface{} `json:"Parameters"`
	Outputs                  map[string]interface{} `json:"Outputs,omitempty"`
}

Jump to

Keyboard shortcuts

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