cluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cluster provides functionality for managing AWS ECS clusters, including service management, task definitions, and container operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceNotFound is returned when a requested service cannot be found in the cluster.
	ErrServiceNotFound = errors.New("service not found")
	// ErrContainerNotFound is returned when a requested container cannot be found in a task.
	ErrContainerNotFound = errors.New("container not found")
	// ErrTaskNotFound is returned when a requested task cannot be found in the cluster.
	ErrTaskNotFound = errors.New("task not found")
	// ErrNoTasks is returned when there are no running tasks in the service.
	ErrNoTasks = errors.New("no tasks running")
	// ErrInvalidImage is returned when the image format is not valid.
	ErrInvalidImage = errors.New("invalid image format")
	// ErrInvalidTaskDefinition is returned when the task definition ARN format is not valid.
	ErrInvalidTaskDefinition = errors.New("invalid task definition ARN")
	// ErrInvalidOption is returned when an invalid option is provided.
	ErrInvalidOption = errors.New("invalid option")
)

Functions

This section is empty.

Types

type AutoscalingOptions added in v0.2.0

type AutoscalingOptions struct {
	ScaleIn          *bool
	ScaleOut         *bool
	ScheduledScaling *bool
}

AutoscalingOptions contains options for autoscaling a service.

type Cluster

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

Cluster represents an AWS ECS cluster with methods for managing services and tasks.

func NewCluster

func NewCluster(awsCfg aws.Config, clusterName string, logger log.T) *Cluster

NewCluster creates a new Cluster instance with the provided AWS configuration and cluster name.

func (*Cluster) AggregateLogGroupARNs added in v0.3.0

func (c *Cluster) AggregateLogGroupARNs(ctx context.Context, services []ecstypes.Service) ([]string, error)

AggregateLogGroupARNs aggregates the log group ARNs from the task definitions of the provided services.

func (*Cluster) AttachPortForwardingSession added in v0.2.0

func (c *Cluster) AttachPortForwardingSession(ctx context.Context, taskARN arn.ARN, containerName string, host string, portNumber int, localPortNumber int) error

AttachPortForwardingSession attaches to a running container and forwards a port to the local machine.

func (*Cluster) AttachShellSession added in v0.2.0

func (c *Cluster) AttachShellSession(ctx context.Context, taskARN arn.ARN, containerName string, command []string) error

AttachShellSession attaches to a running container and executes a command in a shell session.

func (*Cluster) Autoscale added in v0.2.0

func (c *Cluster) Autoscale(ctx context.Context, serviceName string, options *AutoscalingOptions) error

Autoscale autoscales a service by registering a scalable target with the specified options.

func (*Cluster) Deploy

func (c *Cluster) Deploy(ctx context.Context, serviceName string, taskDefinitionARN arn.ARN) error

Deploy updates a service with a new task definition.

func (*Cluster) DescribeAllServices

func (c *Cluster) DescribeAllServices(ctx context.Context) ([]ecstypes.Service, error)

DescribeAllServices returns a list of all services in the cluster.

func (*Cluster) DescribeService added in v0.2.0

func (c *Cluster) DescribeService(ctx context.Context, serviceName string) (*ecstypes.Service, error)

DescribeService retrieves the details of a specific service in the cluster.

func (*Cluster) DescribeServiceTaskDefinitions

func (c *Cluster) DescribeServiceTaskDefinitions(ctx context.Context) ([]ServiceTaskDefinition, error)

DescribeServiceTaskDefinitions returns all services and their associated task definitions.

func (*Cluster) DescribeTaskDefinition added in v0.2.0

func (c *Cluster) DescribeTaskDefinition(ctx context.Context, family string) (*ecs.DescribeTaskDefinitionOutput, error)

DescribeTaskDefinition retrieves the task definition for a given family.

func (*Cluster) GetFirstTaskARN

func (c *Cluster) GetFirstTaskARN(ctx context.Context, serviceName string) (arn.ARN, error)

GetFirstTaskARN returns the ARN of the first running task for a service.

func (*Cluster) ReplaceTaskDefinitionTag

func (c *Cluster) ReplaceTaskDefinitionTag(ctx context.Context, taskDefinitionARN arn.ARN, replacer func(repo, image, tag string) string) (arn.ARN, error)

ReplaceTaskDefinitionTag updates the image tag in a task definition.

func (*Cluster) Restart added in v0.2.0

func (c *Cluster) Restart(ctx context.Context, serviceName string) error

Restart restarts a service by forcing a new deployment.

func (*Cluster) RunConsole

func (c *Cluster) RunConsole(ctx context.Context, serviceName string, containerName string) (arn.ARN, error)

RunConsole starts a new task with an interactive console session.

func (*Cluster) Scale added in v0.2.0

func (c *Cluster) Scale(ctx context.Context, serviceName string, options *ScaleOptions) error

Scale scales a service to the specified size. If min or max is specified, it will scale to the minimum or maximum capacity of the service.

func (*Cluster) Start added in v0.2.0

func (c *Cluster) Start(ctx context.Context, serviceName string) error

Start starts a service by enabling autoscaling.

func (*Cluster) Stop added in v0.2.0

func (c *Cluster) Stop(ctx context.Context, serviceName string) error

Stop stops a service by disabling autoscaling and setting the desired count to zero.

type ScaleOptions added in v0.2.0

type ScaleOptions struct {
	Min  bool
	Max  bool
	Size int
}

ScaleOptions contains options for scaling a service.

type ServiceTaskDefinition

type ServiceTaskDefinition struct {
	Service        ecstypes.Service
	TaskDefinition ecstypes.TaskDefinition
}

ServiceTaskDefinition represents a service and its associated task definition.

Jump to

Keyboard shortcuts

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