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
- Variables
- func TaskDefinitionVersion(taskDefARN string) (int, error)
- func TaskID(taskARN string) (string, error)
- type ContainerEnvVar
- type ContainerPlatform
- type ContainerSecret
- type Deployment
- type ECS
- func (e *ECS) DefaultCluster() (string, error)
- func (e *ECS) DescribeTasks(cluster string, taskARNs []string) ([]*Task, error)
- func (e *ECS) ExecuteCommand(in ExecuteCommandInput) (err error)
- func (e *ECS) HasDefaultCluster() (bool, error)
- func (e *ECS) NetworkConfiguration(cluster, serviceName string) (*NetworkConfiguration, error)
- func (e *ECS) RunTask(input RunTaskInput) ([]*Task, error)
- func (e *ECS) RunningTasks(cluster string) ([]*Task, error)
- func (e *ECS) RunningTasksInFamily(cluster, family string) ([]*Task, error)
- func (e *ECS) Service(clusterName, serviceName string) (*Service, error)
- func (e *ECS) ServiceRunningTasks(cluster, service string) ([]*Task, error)
- func (e *ECS) StopTasks(tasks []string, opts ...StopTasksOpts) error
- func (e *ECS) StoppedServiceTasks(cluster, service string) ([]*Task, error)
- func (e *ECS) TaskDefinition(taskDefName string) (*TaskDefinition, error)
- func (e *ECS) UpdateService(clusterName, serviceName string, opts ...UpdateServiceOpts) error
- type ErrExecuteCommand
- type ErrTaskENIInfoNotFound
- type ErrWaitServiceStableTimeout
- type ErrWaiterResourceNotReadyForTasks
- type ExecuteCommandInput
- type Image
- type NetworkConfiguration
- type RunTaskInput
- type Service
- type ServiceArn
- type ServiceStatus
- type StopTasksOpts
- type Task
- type TaskDefinition
- func (t *TaskDefinition) Command(containerName string) ([]string, error)
- func (t *TaskDefinition) EntryPoint(containerName string) ([]string, error)
- func (t *TaskDefinition) EnvironmentVariables() []*ContainerEnvVar
- func (t *TaskDefinition) Image(containerName string) (string, error)
- func (t *TaskDefinition) Platform() *ContainerPlatform
- func (t *TaskDefinition) Secrets() []*ContainerSecret
- type TaskStatus
- type UpdateServiceOpts
Constants ¶
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" )
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" )
const ( // DesiredStatusStopped represents the desired status "STOPPED" for a task. DesiredStatusStopped = ecs.DesiredStatusStopped )
const ( // EndpointsID is the ID to look up the ECS service endpoint. EndpointsID = ecs.EndpointsID )
Variables ¶
var ErrNoDefaultCluster = errors.New("default cluster does not exist")
ErrNoDefaultCluster occurs when the default cluster is not found.
Functions ¶
func TaskDefinitionVersion ¶ added in v1.8.0
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
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
ContainerEnvVar holds basic info of an environment variable.
type ContainerPlatform ¶ added in v1.14.0
ContainerPlatform holds basic info of a container's platform.
type ContainerSecret ¶ added in v1.1.0
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 (*ECS) DefaultCluster ¶
DefaultCluster returns the default cluster ARN in the account and region.
func (*ECS) DescribeTasks ¶ added in v0.3.0
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
HasDefaultCluster tries to find the default cluster and returns true if there is one.
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
RunningTasks calls ECS API and returns ECS tasks with the desired status to be RUNNING.
func (*ECS) RunningTasksInFamily ¶ added in v1.0.0
RunningTasksInFamily calls ECS API and returns ECS tasks with the desired status to be RUNNING within the same task definition family.
func (*ECS) Service ¶
Service calls ECS API and returns the specified service running in the cluster.
func (*ECS) ServiceRunningTasks ¶ added in v1.8.0
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) 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
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
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 (e *ErrWaitServiceStableTimeout) Error() string
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
func (e *ErrWaiterResourceNotReadyForTasks) Error() string
type ExecuteCommandInput ¶ added in v1.4.0
ExecuteCommandInput holds the fields needed to execute commands in a running container.
type NetworkConfiguration ¶ added in v1.6.0
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 ¶
Service wraps up ECS Service struct.
func (*Service) LastUpdatedAt ¶ added in v1.24.0
LastUpdatedAt returns the last updated time of the ECS service.
func (*Service) ServiceConnectAliases ¶ added in v1.24.0
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
TargetGroups returns the ARNs of target groups attached to the 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"` 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 ¶
Task wraps up ECS Task struct.
func FilterRunningTasks ¶ added in v1.4.0
FilterRunningTasks returns only tasks with the last status to be RUNNING.
func (*Task) ENI ¶ added in v1.4.0
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 ¶ added in v1.1.0
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.