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 (
    	// DesiredStatusStopped represents the desired status "STOPPED" for a task.
    	DesiredStatusStopped = ecs.DesiredStatusStopped
    )

    Variables

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

      ErrNoDefaultCluster occurs when the default cluster is not found.

      Functions

      func TaskID

      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

        type ContainerEnvVar struct {
        	Name      string
        	Container string
        	Value     string
        }

          ContainerEnvVar holds basic info of an environment variable.

          type ContainerSecret

          type ContainerSecret struct {
          	Name      string
          	Container string
          	ValueFrom string
          }

            ContainerSecret holds basic info of a secret.

            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) DefaultCluster

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

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

                  func (*ECS) DescribeTasks

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

                    DescribeTasks returns the tasks with the taskARNs in the cluster.

                    func (*ECS) ExecuteCommand

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

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

                      func (*ECS) HasDefaultCluster

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

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

                        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

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

                          func (*ECS) RunningTasksInFamily

                          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) ServiceTasks

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

                                ServiceTasks calls ECS API and returns ECS tasks running by a service.

                                func (*ECS) StopTasks

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

                                  StopTasks stops multiple running tasks given their IDs or ARNs.

                                  func (*ECS) TaskDefinition

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

                                    TaskDefinition calls ECS API and returns the task definition.

                                    type ErrExecuteCommand

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

                                      ErrExecuteCommand occurs when ecs:ExecuteCommand fails.

                                      func (*ErrExecuteCommand) Error

                                      func (e *ErrExecuteCommand) Error() string

                                      type ErrTaskENIInfoNotFound

                                      type ErrTaskENIInfoNotFound struct {
                                      	MissingField string
                                      	TaskARN      string
                                      }

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

                                        func (*ErrTaskENIInfoNotFound) Error

                                        func (e *ErrTaskENIInfoNotFound) Error() string

                                        type ErrWaiterResourceNotReadyForTasks

                                        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

                                          type ExecuteCommandInput

                                          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 RunTaskInput

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

                                                RunTaskInput holds the fields needed to run tasks.

                                                type Service

                                                type Service ecs.Service

                                                  Service wraps up ECS Service struct.

                                                  func (*Service) ServiceStatus

                                                  func (s *Service) ServiceStatus() ServiceStatus

                                                    ServiceStatus returns the status of the running service.

                                                    type ServiceArn

                                                    type ServiceArn string

                                                      ServiceArn is the arn of an ECS service.

                                                      func (*ServiceArn) ClusterName

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

                                                        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, error)

                                                          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

                                                          type ServiceStatus

                                                          type ServiceStatus struct {
                                                          	DesiredCount     int64     `json:"desiredCount"`
                                                          	RunningCount     int64     `json:"runningCount"`
                                                          	Status           string    `json:"status"`
                                                          	LastDeploymentAt time.Time `json:"lastDeploymentAt"`
                                                          	TaskDefinition   string    `json:"taskDefinition"`
                                                          }

                                                            ServiceStatus contains the status info of a service.

                                                            type StopTasksOpts

                                                            type StopTasksOpts func(*ecs.StopTaskInput)

                                                              StopTasksOpts sets the optional parameter for StopTasks.

                                                              func WithStopTaskCluster

                                                              func WithStopTaskCluster(cluster string) StopTasksOpts

                                                                WithStopTaskCluster sets the cluster that hosts the task to stop.

                                                                func WithStopTaskReason

                                                                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

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

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

                                                                      func (*Task) ENI

                                                                      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) String

                                                                        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) EnvironmentVariables

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

                                                                                EnvironmentVariables returns environment variables of the task definition.

                                                                                func (*TaskDefinition) Secrets

                                                                                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"`
                                                                                  }

                                                                                    TaskStatus contains the status info of a task.

                                                                                    func (TaskStatus) HumanString

                                                                                    func (t TaskStatus) HumanString() string

                                                                                      HumanString returns the stringified TaskStatus struct with human readable format. Example output:

                                                                                      6ca7a60d          f884127d            RUNNING             UNKNOWN             19 hours ago        -
                                                                                      

                                                                                      Directories

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