ecs

package
v1.33.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ecs provides a client to make API requests to Amazon Elastic Container Service.

Package ecs provides a client to make API requests to Amazon Elastic Container Service.

Package ecs provides a client to make API requests to Amazon Elastic Container Service.

Index

Constants

View Source
const (
	// ServiceDeploymentStatusPrimary is the status PRIMARY of an ECS service deployment.
	ServiceDeploymentStatusPrimary = "PRIMARY"
	// ServiceDeploymentStatusActive is the status ACTIVE of an ECS service deployment.
	ServiceDeploymentStatusActive = "ACTIVE"
)
View Source
const (

	// TaskContainerHealthStatusUnknown wraps the ECS health status UNKNOWN.
	TaskContainerHealthStatusUnknown = ecs.HealthStatusUnknown
	// TaskContainerHealthStatusHealthy wraps the ECS health status HEALTHY.
	TaskContainerHealthStatusHealthy = ecs.HealthStatusHealthy
	// TaskContainerHealthStatusUnhealthy wraps the ECS health status UNHEALTHY.
	TaskContainerHealthStatusUnhealthy = ecs.HealthStatusUnhealthy

	// TaskCapacityProviderFargate is the capacity provider name for FARGATE.
	TaskCapacityProviderFargate = "FARGATE"
	// TaskCapacityProviderFargateSpot is the capacity provider name for FARGATE_SPOT.
	TaskCapacityProviderFargateSpot = "FARGATE_SPOT"
	// TaskStatusRunning is the task status running.
	TaskStatusRunning = "RUNNING"
)
View Source
const (
	// DesiredStatusStopped represents the desired status "STOPPED" for a task.
	DesiredStatusStopped = ecs.DesiredStatusStopped
)
View Source
const (

	// EndpointsID is the ID to look up the ECS service endpoint.
	EndpointsID = ecs.EndpointsID
)

Variables

View Source
var ErrNoDefaultCluster = errors.New("default cluster does not exist")

ErrNoDefaultCluster occurs when the default cluster is not found.

Functions

func ShortTaskID added in v1.31.0

func ShortTaskID(id string) string

ShortTaskID truncates a string to a maximum length of shortTaskIDLength. If the input is shorter, it remains unchanged.

func TaskDefinitionVersion added in v1.8.0

func TaskDefinitionVersion(taskDefARN string) (int, error)

TaskDefinitionVersion takes a task definition ARN and returns its version. For example, given "arn:aws:ecs:us-east-1:568623488001:task-definition/some-task-def:6", it returns 6.

func TaskID added in v0.4.0

func TaskID(taskARN string) (string, error)

TaskID parses the task ARN and returns the task ID. For example: arn:aws:ecs:us-west-2:123456789:task/my-project-test-Cluster-9F7Y0RLP60R7/4082490ee6c245e09d2145010aa1ba8d, arn:aws:ecs:us-west-2:123456789:task/4082490ee6c245e09d2145010aa1ba8d return 4082490ee6c245e09d2145010aa1ba8d.

Types

type ContainerEnvVar added in v1.1.0

type ContainerEnvVar struct {
	Name      string
	Container string
	Value     string
}

ContainerEnvVar holds basic info of an environment variable.

type ContainerPlatform added in v1.14.0

type ContainerPlatform struct {
	OperatingSystem string
	Architecture    string
}

ContainerPlatform holds basic info of a container's platform.

type ContainerSecret added in v1.1.0

type ContainerSecret struct {
	Name      string
	Container string
	ValueFrom string
}

ContainerSecret holds basic info of a secret.

type Deployment added in v1.8.0

type Deployment struct {
	Id             string    `json:"id"`
	DesiredCount   int64     `json:"desiredCount"`
	RunningCount   int64     `json:"runningCount"`
	UpdatedAt      time.Time `json:"updatedAt"`
	LaunchType     string    `json:"launchType"`
	TaskDefinition string    `json:"taskDefinition"`
	Status         string    `json:"status"`
}

Deployment contains information of a ECS service Deployment.

type ECS

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

ECS wraps an AWS ECS client.

func New

func New(s *session.Session) *ECS

New returns a Service configured against the input session.

func (*ECS) ActiveClusters added in v1.29.0

func (e *ECS) ActiveClusters(arns ...string) ([]string, error)

ActiveClusters returns the subset of cluster arns that have an ACTIVE status.

func (*ECS) ActiveServices added in v1.29.1

func (e *ECS) ActiveServices(clusterARN string, serviceARNs ...string) ([]string, error)

ActiveServices returns the subset of service arns that have an ACTIVE status from the given cluster.

func (*ECS) DefaultCluster

func (e *ECS) DefaultCluster() (string, error)

DefaultCluster returns the default cluster ARN in the account and region.

func (*ECS) DescribeTasks added in v0.3.0

func (e *ECS) DescribeTasks(cluster string, taskARNs []string) ([]*Task, error)

DescribeTasks returns the tasks with the taskARNs in the cluster.

func (*ECS) ExecuteCommand added in v1.4.0

func (e *ECS) ExecuteCommand(in ExecuteCommandInput) (err error)

ExecuteCommand executes commands in a running container, and then terminate the session.

func (*ECS) HasDefaultCluster added in v0.3.0

func (e *ECS) HasDefaultCluster() (bool, error)

HasDefaultCluster tries to find the default cluster and returns true if there is one.

func (*ECS) ListServicesByNamespace added in v1.32.0

func (e *ECS) ListServicesByNamespace(namespace string) ([]string, error)

ListServicesByNamespace returns a list of service ARNs of services that are in the given namespace.

func (*ECS) NetworkConfiguration added in v1.6.0

func (e *ECS) NetworkConfiguration(cluster, serviceName string) (*NetworkConfiguration, error)

NetworkConfiguration returns the network configuration of a service.

func (*ECS) RunTask

func (e *ECS) RunTask(input RunTaskInput) ([]*Task, error)

RunTask runs a number of tasks with the task definition and network configurations in a cluster, and returns after the task(s) is running or fails to run, along with task ARNs if possible.

func (*ECS) RunningTasks added in v1.1.0

func (e *ECS) RunningTasks(cluster string) ([]*Task, error)

RunningTasks calls ECS API and returns ECS tasks with the desired status to be RUNNING.

func (*ECS) RunningTasksInFamily added in v1.0.0

func (e *ECS) RunningTasksInFamily(cluster, family string) ([]*Task, error)

RunningTasksInFamily calls ECS API and returns ECS tasks with the desired status to be RUNNING within the same task definition family.

func (*ECS) Service

func (e *ECS) Service(clusterName, serviceName string) (*Service, error)

Service calls ECS API and returns the specified service running in the cluster.

func (*ECS) ServiceRunningTasks added in v1.8.0

func (e *ECS) ServiceRunningTasks(cluster, service string) ([]*Task, error)

ServiceRunningTasks calls ECS API and returns the ECS tasks spun up by the service, with the desired status to be set to be RUNNING.

func (*ECS) Services added in v1.32.0

func (e *ECS) Services(cluster string, services ...string) ([]*Service, error)

Services calls the ECS API and returns all of the specified services running in cluster.

func (*ECS) StopTasks added in v1.0.0

func (e *ECS) StopTasks(tasks []string, opts ...StopTasksOpts) error

StopTasks stops multiple running tasks given their IDs or ARNs.

func (*ECS) StoppedServiceTasks added in v1.8.0

func (e *ECS) StoppedServiceTasks(cluster, service string) ([]*Task, error)

StoppedServiceTasks calls ECS API and returns stopped ECS tasks in a service.

func (*ECS) TaskDefinition

func (e *ECS) TaskDefinition(taskDefName string) (*TaskDefinition, error)

TaskDefinition calls ECS API and returns the task definition.

func (*ECS) UpdateService added in v1.10.0

func (e *ECS) UpdateService(clusterName, serviceName string, opts ...UpdateServiceOpts) error

UpdateService calls ECS API and updates the specific service running in the cluster.

type ErrExecuteCommand added in v1.4.0

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

ErrExecuteCommand occurs when ecs:ExecuteCommand fails.

func (*ErrExecuteCommand) Error added in v1.4.0

func (e *ErrExecuteCommand) Error() string

type ErrTaskENIInfoNotFound added in v1.4.0

type ErrTaskENIInfoNotFound struct {
	MissingField string
	TaskARN      string
}

ErrTaskENIInfoNotFound when some ENI information is not found in a ECS task.

func (*ErrTaskENIInfoNotFound) Error added in v1.4.0

func (e *ErrTaskENIInfoNotFound) Error() string

type ErrWaitServiceStableTimeout added in v1.10.0

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

ErrWaitServiceStableTimeout occurs when the max retries number waiting for the service to be stable exceeded the limit.

func (*ErrWaitServiceStableTimeout) Error added in v1.10.0

func (*ErrWaitServiceStableTimeout) Timeout added in v1.10.0

func (e *ErrWaitServiceStableTimeout) Timeout() bool

Timeout allows ErrWaitServiceStableTimeout to implement a timeout error interface.

type ErrWaiterResourceNotReadyForTasks added in v0.3.0

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

ErrWaiterResourceNotReadyForTasks contains the STOPPED reason for the container of the first task that failed to start.

func (*ErrWaiterResourceNotReadyForTasks) Error added in v0.3.0

type ExecuteCommandInput added in v1.4.0

type ExecuteCommandInput struct {
	Cluster   string
	Command   string
	Task      string
	Container string
}

ExecuteCommandInput holds the fields needed to execute commands in a running container.

type Image

type Image struct {
	ID     string
	Digest string
}

Image contains very basic info of a container image.

type NetworkConfiguration added in v1.6.0

type NetworkConfiguration struct {
	AssignPublicIp string
	SecurityGroups []string
	Subnets        []string
}

NetworkConfiguration holds service's NetworkConfiguration.

type RunTaskInput

type RunTaskInput struct {
	Cluster         string
	Count           int
	Subnets         []string
	SecurityGroups  []string
	TaskFamilyName  string
	StartedBy       string
	PlatformVersion string
	EnableExec      bool
}

RunTaskInput holds the fields needed to run tasks.

type Service

type Service ecs.Service

Service wraps up ECS Service struct.

func (*Service) LastUpdatedAt added in v1.24.0

func (s *Service) LastUpdatedAt() time.Time

LastUpdatedAt returns the last updated time of the ECS service.

func (*Service) ServiceConnectAliases added in v1.24.0

func (s *Service) ServiceConnectAliases() []string

ServiceConnectAliases returns the ECS Service Connect client aliases for a service.

func (*Service) ServiceStatus

func (s *Service) ServiceStatus() ServiceStatus

ServiceStatus returns the status of the running service.

func (*Service) TargetGroups added in v1.8.0

func (s *Service) TargetGroups() []string

TargetGroups returns the ARNs of target groups attached to the service.

type ServiceArn

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

ServiceArn is the arn of an ECS service.

func ParseServiceArn added in v1.29.1

func ParseServiceArn(s string) (*ServiceArn, error)

ParseServiceArn parses an arn into ServiceArn. For example: arn:aws:ecs:us-west-2:1234567890:service/my-project-test-Cluster-9F7Y0RLP60R7/my-project-test-myService-JSOH5GYBFAIB

func (*ServiceArn) ClusterArn added in v1.29.1

func (s *ServiceArn) ClusterArn() string

ClusterArn returns the cluster arn. For example: arn:aws:ecs:us-west-2:1234567890:service/my-project-test-Cluster-9F7Y0RLP60R7/my-project-test-myService-JSOH5GYBFAIB will return arn:aws:ecs:us-west-2:1234567890:cluster/my-project-test-Cluster-9F7Y0RLP60R7

func (*ServiceArn) ClusterName

func (s *ServiceArn) ClusterName() string

ClusterName returns the cluster name. For example: arn:aws:ecs:us-west-2:1234567890:service/my-project-test-Cluster-9F7Y0RLP60R7/my-project-test-myService-JSOH5GYBFAIB will return my-project-test-Cluster-9F7Y0RLP60R7

func (*ServiceArn) ServiceName

func (s *ServiceArn) ServiceName() string

ServiceName returns the service name. For example: arn:aws:ecs:us-west-2:1234567890:service/my-project-test-Cluster-9F7Y0RLP60R7/my-project-test-myService-JSOH5GYBFAIB will return my-project-test-myService-JSOH5GYBFAIB

func (*ServiceArn) String added in v1.29.1

func (s *ServiceArn) String() string

type ServiceStatus

type ServiceStatus struct {
	DesiredCount     int64        `json:"desiredCount"`
	RunningCount     int64        `json:"runningCount"`
	Status           string       `json:"status"`
	Deployments      []Deployment `json:"deployments"`
	LastDeploymentAt time.Time    `json:"lastDeploymentAt"` // kept to avoid breaking change
	TaskDefinition   string       `json:"taskDefinition"`   // kept to avoid breaking change
}

ServiceStatus contains the status info of a service.

type StopTasksOpts added in v1.0.0

type StopTasksOpts func(*ecs.StopTaskInput)

StopTasksOpts sets the optional parameter for StopTasks.

func WithStopTaskCluster added in v1.0.0

func WithStopTaskCluster(cluster string) StopTasksOpts

WithStopTaskCluster sets the cluster that hosts the task to stop.

func WithStopTaskReason added in v1.0.0

func WithStopTaskReason(reason string) StopTasksOpts

WithStopTaskReason sets an optional message specified when a task is stopped.

type Task

type Task ecs.Task

Task wraps up ECS Task struct.

func FilterRunningTasks added in v1.4.0

func FilterRunningTasks(tasks []*Task) []*Task

FilterRunningTasks returns only tasks with the last status to be RUNNING.

func (*Task) ENI added in v1.4.0

func (t *Task) ENI() (string, error)

ENI returns the network interface ID of the running task. Every Fargate task is provided with an ENI by default (https://docs.aws.amazon.com/AmazonECS/latest/userguide/fargate-task-networking.html).

func (*Task) PrivateIP added in v1.8.0

func (t *Task) PrivateIP() (string, error)

PrivateIP returns the private IPv4 address of the task.

func (Task) String added in v1.1.0

func (t Task) String() string

String returns the human readable format of an ECS task. For example, a task with ARN arn:aws:ecs:us-west-2:123456789:task/4082490ee6c245e09d2145010aa1ba8d and task definition ARN arn:aws:ecs:us-west-2:123456789012:task-definition/sample-fargate:2 becomes "4082490e (sample-fargate:2)"

func (*Task) TaskStatus

func (t *Task) TaskStatus() (*TaskStatus, error)

TaskStatus returns the status of the running task.

type TaskDefinition

type TaskDefinition ecs.TaskDefinition

TaskDefinition wraps up ECS TaskDefinition struct.

func (*TaskDefinition) Command added in v1.6.0

func (t *TaskDefinition) Command(containerName string) ([]string, error)

Command returns the container's command overrides of the task definition.

func (*TaskDefinition) EntryPoint added in v1.6.0

func (t *TaskDefinition) EntryPoint(containerName string) ([]string, error)

EntryPoint returns the container's entrypoint overrides of the task definition.

func (*TaskDefinition) EnvironmentVariables

func (t *TaskDefinition) EnvironmentVariables() []*ContainerEnvVar

EnvironmentVariables returns environment variables of the task definition.

func (*TaskDefinition) Image added in v1.6.0

func (t *TaskDefinition) Image(containerName string) (string, error)

Image returns the container's image of the task definition.

func (*TaskDefinition) Platform added in v1.14.0

func (t *TaskDefinition) Platform() *ContainerPlatform

Platform returns the platform of the task definition.

func (*TaskDefinition) Secrets added in v1.1.0

func (t *TaskDefinition) Secrets() []*ContainerSecret

Secrets returns secrets of the task definition.

type TaskStatus

type TaskStatus struct {
	Health           string    `json:"health"`
	ID               string    `json:"id"`
	Images           []Image   `json:"images"`
	LastStatus       string    `json:"lastStatus"`
	StartedAt        time.Time `json:"startedAt"`
	StoppedAt        time.Time `json:"stoppedAt"`
	StoppedReason    string    `json:"stoppedReason"`
	CapacityProvider string    `json:"capacityProvider"`
	TaskDefinition   string    `json:"taskDefinitionARN"`
}

TaskStatus contains the status info of a task.

type UpdateServiceOpts added in v1.10.0

type UpdateServiceOpts func(*ecs.UpdateServiceInput)

UpdateServiceOpts sets the optional parameter for UpdateService.

func WithForceUpdate added in v1.10.0

func WithForceUpdate() UpdateServiceOpts

WithForceUpdate sets ForceNewDeployment to force an update.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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