AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

ECS

import "github.com/aws/aws-sdk-go/service/ecs"

type ECS struct { *client.Client }

ECS provides the API operation methods for making requests to Amazon EC2 Container Service. See this package's package overview docs for details on the service.

ECS methods are safe to use concurrently. It is not safe to modify mutate any of the struct's properties though.

Client

Type: *client.Client

Method

CreateCluster

func (c *ECS) CreateCluster(input *CreateClusterInput) (*CreateClusterOutput, error)

CreateCluster API operation for Amazon EC2 Container Service.

Creates a new Amazon ECS cluster. By default, your account receives a default cluster when you launch your first container instance. However, you can create your own cluster with a unique name with the CreateCluster action.

When you call the CreateCluster API operation, Amazon ECS attempts to create the service-linked role for your account so that required resources in other AWS services can be managed on your behalf. However, if the IAM user that makes the call does not have permissions to create the service-linked role, it is not created. For more information, see Using Service-Linked Roles for Amazon ECS (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using-service-linked-roles.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation CreateCluster for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/CreateCluster

Example

ECS CreateCluster shared00

To create a new cluster

This example creates a cluster in your default region.

{ svc := ecs.New(session.New()) input := &ecs.CreateClusterInput{ ClusterName: aws.String("my_cluster"), } result, err := svc.CreateCluster(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

CreateClusterRequest

func (c *ECS) CreateClusterRequest(input *CreateClusterInput) (req *request.Request, output *CreateClusterOutput)

CreateClusterRequest generates a "aws/request.Request" representing the client's request for the CreateCluster operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See CreateCluster for more information on using the CreateCluster API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the CreateClusterRequest method. req, resp := client.CreateClusterRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/CreateCluster

CreateClusterWithContext

func (c *ECS) CreateClusterWithContext(ctx aws.Context, input *CreateClusterInput, opts ...request.Option) (*CreateClusterOutput, error)

CreateClusterWithContext is the same as CreateCluster with the addition of the ability to pass a context and additional request options.

See CreateCluster for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

CreateService

func (c *ECS) CreateService(input *CreateServiceInput) (*CreateServiceOutput, error)

CreateService API operation for Amazon EC2 Container Service.

Runs and maintains a desired number of tasks from a specified task definition. If the number of tasks running in a service drops below desiredCount, Amazon ECS spawns another copy of the task in the specified cluster. To update an existing service, see UpdateService.

In addition to maintaining the desired count of tasks in your service, you can optionally run your service behind a load balancer. The load balancer distributes traffic across the tasks that are associated with the service. For more information, see Service Load Balancing (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-load-balancing.html) in the Amazon Elastic Container Service Developer Guide.

You can optionally specify a deployment configuration for your service. The deployment is triggered by changing properties, such as the task definition or the desired count of a service, with an UpdateService operation.

If a service is using the ECS deployment controller, the minimum healthy percent represents a lower limit on the number of tasks in a service that must remain in the RUNNING state during a deployment, as a percentage of the desired number of tasks (rounded up to the nearest integer), and while any container instances are in the DRAINING state if the service contains tasks using the EC2 launch type. This parameter enables you to deploy without using additional cluster capacity. For example, if your service has a desired number of four tasks and a minimum healthy percent of 50%, the scheduler may stop two existing tasks to free up cluster capacity before starting two new tasks. Tasks for services that do not use a load balancer are considered healthy if they are in the RUNNING state; tasks for services that do use a load balancer are considered healthy if they are in the RUNNING state and they are reported as healthy by the load balancer. The default value for minimum healthy percent is 100%.

If a service is using the ECS deployment controller, the maximum percent parameter represents an upper limit on the number of tasks in a service that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desired number of tasks (rounded down to the nearest integer), and while any container instances are in the DRAINING state if the service contains tasks using the EC2 launch type. This parameter enables you to define the deployment batch size. For example, if your service has a desired number of four tasks and a maximum percent value of 200%, the scheduler may start four new tasks before stopping the four older tasks (provided that the cluster resources required to do this are available). The default value for maximum percent is 200%.

If a service is using the CODE_DEPLOY deployment controller and tasks that use the EC2 launch type, the minimum healthy percent and maximum percent values are only used to define the lower and upper limit on the number of the tasks in the service that remain in the RUNNING state while the container instances are in the DRAINING state. If the tasks in the service use the Fargate launch type, the minimum healthy percent and maximum percent values are not used, although they are currently visible when describing your service.

Tasks for services that do not use a load balancer are considered healthy if they are in the RUNNING state. Tasks for services that do use a load balancer are considered healthy if they are in the RUNNING state and the container instance they are hosted on is reported as healthy by the load balancer. The default value for a replica service for minimumHealthyPercent is 100%. The default value for a daemon service for minimumHealthyPercent is 0%.

When the service scheduler launches new tasks, it determines task placement in your cluster using the following logic:

  • Determine which of the container instances in your cluster can support your service's task definition (for example, they have the required CPU, memory, ports, and container instance attributes).

  • By default, the service scheduler attempts to balance tasks across Availability Zones in this manner (although you can choose a different placement strategy) with the placementStrategy parameter):

Sort the valid container instances, giving priority to instances that have

the fewest number of running tasks for this service in their respective Availability Zone. For example, if zone A has one running service task and zones B and C each have zero, valid container instances in either zone B or C are considered optimal for placement.

Place the new service task on a valid container instance in an optimal Availability

Zone (based on the previous steps), favoring container instances with the fewest number of running tasks for this service.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation CreateService for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeUnsupportedFeatureException "UnsupportedFeatureException" The specified task is not supported in this Region.

  • ErrCodePlatformUnknownException "PlatformUnknownException" The specified platform version does not exist.

  • ErrCodePlatformTaskDefinitionIncompatibilityException "PlatformTaskDefinitionIncompatibilityException" The specified platform version does not satisfy the task definition's required capabilities.

  • ErrCodeAccessDeniedException "AccessDeniedException" You do not have authorization to perform the requested action.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/CreateService

Examples

ECS CreateService shared00

To create a new service

This example creates a service in your default region called ``ecs-simple-service``. The service uses the ``hello_world`` task definition and it maintains 10 copies of that task.

{ svc := ecs.New(session.New()) input := &ecs.CreateServiceInput{ DesiredCount: aws.Int64(10), ServiceName: aws.String("ecs-simple-service"), TaskDefinition: aws.String("hello_world"), } result, err := svc.CreateService(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS CreateService shared01

To create a new service behind a load balancer

This example creates a service in your default region called ``ecs-simple-service-elb``. The service uses the ``ecs-demo`` task definition and it maintains 10 copies of that task. You must reference an existing load balancer in the same region by its name.

{ svc := ecs.New(session.New()) input := &ecs.CreateServiceInput{ DesiredCount: aws.Int64(10), LoadBalancers: []*ecs.LoadBalancer{ { ContainerName: aws.String("simple-app"), ContainerPort: aws.Int64(80), LoadBalancerName: aws.String("EC2Contai-EcsElast-15DCDAURT3ZO2"), }, }, Role: aws.String("ecsServiceRole"), ServiceName: aws.String("ecs-simple-service-elb"), TaskDefinition: aws.String("console-sample-app-static"), } result, err := svc.CreateService(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

CreateServiceRequest

func (c *ECS) CreateServiceRequest(input *CreateServiceInput) (req *request.Request, output *CreateServiceOutput)

CreateServiceRequest generates a "aws/request.Request" representing the client's request for the CreateService operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See CreateService for more information on using the CreateService API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the CreateServiceRequest method. req, resp := client.CreateServiceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/CreateService

CreateServiceWithContext

func (c *ECS) CreateServiceWithContext(ctx aws.Context, input *CreateServiceInput, opts ...request.Option) (*CreateServiceOutput, error)

CreateServiceWithContext is the same as CreateService with the addition of the ability to pass a context and additional request options.

See CreateService for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeleteAccountSetting

func (c *ECS) DeleteAccountSetting(input *DeleteAccountSettingInput) (*DeleteAccountSettingOutput, error)

DeleteAccountSetting API operation for Amazon EC2 Container Service.

Modifies the ARN and resource ID format of a resource for a specified IAM user, IAM role, or the root user for an account. You can specify whether the new ARN and resource ID format are disabled for new resources that are created.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeleteAccountSetting for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteAccountSetting

Examples

ECS DeleteAccountSetting shared00

To delete your account setting

This example deletes the account setting for your user for the specified resource type.

{ svc := ecs.New(session.New()) input := &ecs.DeleteAccountSettingInput{ Name: aws.String("serviceLongArnFormat"), } result, err := svc.DeleteAccountSetting(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS DeleteAccountSetting shared01

To delete the account settings for a specific IAM user or IAM role

This example deletes the account setting for a specific IAM user or IAM role for the specified resource type. Only the root user can view or modify the account settings for another user.

{ svc := ecs.New(session.New()) input := &ecs.DeleteAccountSettingInput{ Name: aws.String("containerInstanceLongArnFormat"), PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), } result, err := svc.DeleteAccountSetting(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DeleteAccountSettingRequest

func (c *ECS) DeleteAccountSettingRequest(input *DeleteAccountSettingInput) (req *request.Request, output *DeleteAccountSettingOutput)

DeleteAccountSettingRequest generates a "aws/request.Request" representing the client's request for the DeleteAccountSetting operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeleteAccountSetting for more information on using the DeleteAccountSetting API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeleteAccountSettingRequest method. req, resp := client.DeleteAccountSettingRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteAccountSetting

DeleteAccountSettingWithContext

func (c *ECS) DeleteAccountSettingWithContext(ctx aws.Context, input *DeleteAccountSettingInput, opts ...request.Option) (*DeleteAccountSettingOutput, error)

DeleteAccountSettingWithContext is the same as DeleteAccountSetting with the addition of the ability to pass a context and additional request options.

See DeleteAccountSetting for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeleteAttributes

func (c *ECS) DeleteAttributes(input *DeleteAttributesInput) (*DeleteAttributesOutput, error)

DeleteAttributes API operation for Amazon EC2 Container Service.

Deletes one or more custom attributes from an Amazon ECS resource.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeleteAttributes for usage and error information.

Returned Error Codes:

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeTargetNotFoundException "TargetNotFoundException" The specified target could not be found. You can view your available container instances with ListContainerInstances. Amazon ECS container instances are cluster-specific and Region-specific.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteAttributes

DeleteAttributesRequest

func (c *ECS) DeleteAttributesRequest(input *DeleteAttributesInput) (req *request.Request, output *DeleteAttributesOutput)

DeleteAttributesRequest generates a "aws/request.Request" representing the client's request for the DeleteAttributes operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeleteAttributes for more information on using the DeleteAttributes API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeleteAttributesRequest method. req, resp := client.DeleteAttributesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteAttributes

DeleteAttributesWithContext

func (c *ECS) DeleteAttributesWithContext(ctx aws.Context, input *DeleteAttributesInput, opts ...request.Option) (*DeleteAttributesOutput, error)

DeleteAttributesWithContext is the same as DeleteAttributes with the addition of the ability to pass a context and additional request options.

See DeleteAttributes for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeleteCluster

func (c *ECS) DeleteCluster(input *DeleteClusterInput) (*DeleteClusterOutput, error)

DeleteCluster API operation for Amazon EC2 Container Service.

Deletes the specified cluster. You must deregister all container instances from this cluster before you may delete it. You can list the container instances in a cluster with ListContainerInstances and deregister them with DeregisterContainerInstance.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeleteCluster for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeClusterContainsContainerInstancesException "ClusterContainsContainerInstancesException" You cannot delete a cluster that has registered container instances. First, deregister the container instances before you can delete the cluster. For more information, see DeregisterContainerInstance.

  • ErrCodeClusterContainsServicesException "ClusterContainsServicesException" You cannot delete a cluster that contains services. First, update the service to reduce its desired task count to 0 and then delete the service. For more information, see UpdateService and DeleteService.

  • ErrCodeClusterContainsTasksException "ClusterContainsTasksException" You cannot delete a cluster that has active tasks.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteCluster

Example

ECS DeleteCluster shared00

To delete an empty cluster

This example deletes an empty cluster in your default region.

{ svc := ecs.New(session.New()) input := &ecs.DeleteClusterInput{ Cluster: aws.String("my_cluster"), } result, err := svc.DeleteCluster(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeClusterContainsContainerInstancesException: fmt.Println(ecs.ErrCodeClusterContainsContainerInstancesException, aerr.Error()) case ecs.ErrCodeClusterContainsServicesException: fmt.Println(ecs.ErrCodeClusterContainsServicesException, aerr.Error()) case ecs.ErrCodeClusterContainsTasksException: fmt.Println(ecs.ErrCodeClusterContainsTasksException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DeleteClusterRequest

func (c *ECS) DeleteClusterRequest(input *DeleteClusterInput) (req *request.Request, output *DeleteClusterOutput)

DeleteClusterRequest generates a "aws/request.Request" representing the client's request for the DeleteCluster operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeleteCluster for more information on using the DeleteCluster API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeleteClusterRequest method. req, resp := client.DeleteClusterRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteCluster

DeleteClusterWithContext

func (c *ECS) DeleteClusterWithContext(ctx aws.Context, input *DeleteClusterInput, opts ...request.Option) (*DeleteClusterOutput, error)

DeleteClusterWithContext is the same as DeleteCluster with the addition of the ability to pass a context and additional request options.

See DeleteCluster for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeleteService

func (c *ECS) DeleteService(input *DeleteServiceInput) (*DeleteServiceOutput, error)

DeleteService API operation for Amazon EC2 Container Service.

Deletes a specified service within a cluster. You can delete a service if you have no running tasks in it and the desired task count is zero. If the service is actively maintaining tasks, you cannot delete it, and you must update the service to a desired task count of zero. For more information, see UpdateService.

When you delete a service, if there are still running tasks that require cleanup, the service status moves from ACTIVE to DRAINING, and the service is no longer visible in the console or in the ListServices API operation. After the tasks have stopped, then the service status moves from DRAINING to INACTIVE. Services in the DRAINING or INACTIVE status can still be viewed with the DescribeServices API operation. However, in the future, INACTIVE services may be cleaned up and purged from Amazon ECS record keeping, and DescribeServices calls on those services return a ServiceNotFoundException error.

If you attempt to create a new service with the same name as an existing service in either ACTIVE or DRAINING status, you receive an error.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeleteService for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeServiceNotFoundException "ServiceNotFoundException" The specified service could not be found. You can view your available services with ListServices. Amazon ECS services are cluster-specific and Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteService

Example

ECS DeleteService shared00

To delete a service

This example deletes the my-http-service service. The service must have a desired count and running count of 0 before you can delete it.

{ svc := ecs.New(session.New()) input := &ecs.DeleteServiceInput{ Service: aws.String("my-http-service"), } result, err := svc.DeleteService(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DeleteServiceRequest

func (c *ECS) DeleteServiceRequest(input *DeleteServiceInput) (req *request.Request, output *DeleteServiceOutput)

DeleteServiceRequest generates a "aws/request.Request" representing the client's request for the DeleteService operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeleteService for more information on using the DeleteService API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeleteServiceRequest method. req, resp := client.DeleteServiceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeleteService

DeleteServiceWithContext

func (c *ECS) DeleteServiceWithContext(ctx aws.Context, input *DeleteServiceInput, opts ...request.Option) (*DeleteServiceOutput, error)

DeleteServiceWithContext is the same as DeleteService with the addition of the ability to pass a context and additional request options.

See DeleteService for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeregisterContainerInstance

func (c *ECS) DeregisterContainerInstance(input *DeregisterContainerInstanceInput) (*DeregisterContainerInstanceOutput, error)

DeregisterContainerInstance API operation for Amazon EC2 Container Service.

Deregisters an Amazon ECS container instance from the specified cluster. This instance is no longer available to run tasks.

If you intend to use the container instance for some other purpose after deregistration, you should stop all of the tasks running on the container instance before deregistration. That prevents any orphaned tasks from consuming resources.

Deregistering a container instance removes the instance from a cluster, but it does not terminate the EC2 instance. If you are finished using the instance, be sure to terminate it in the Amazon EC2 console to stop billing.

If you terminate a running container instance, Amazon ECS automatically deregisters the instance from your cluster (stopped container instances or instances with disconnected agents are not automatically deregistered when terminated).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeregisterContainerInstance for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeregisterContainerInstance

Example

ECS DeregisterContainerInstance shared00

To deregister a container instance from a cluster

This example deregisters a container instance from the specified cluster in your default region. If there are still tasks running on the container instance, you must either stop those tasks before deregistering, or use the force option.

{ svc := ecs.New(session.New()) input := &ecs.DeregisterContainerInstanceInput{ Cluster: aws.String("default"), ContainerInstance: aws.String("container_instance_UUID"), Force: aws.Bool(true), } result, err := svc.DeregisterContainerInstance(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DeregisterContainerInstanceRequest

func (c *ECS) DeregisterContainerInstanceRequest(input *DeregisterContainerInstanceInput) (req *request.Request, output *DeregisterContainerInstanceOutput)

DeregisterContainerInstanceRequest generates a "aws/request.Request" representing the client's request for the DeregisterContainerInstance operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeregisterContainerInstance for more information on using the DeregisterContainerInstance API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeregisterContainerInstanceRequest method. req, resp := client.DeregisterContainerInstanceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeregisterContainerInstance

DeregisterContainerInstanceWithContext

func (c *ECS) DeregisterContainerInstanceWithContext(ctx aws.Context, input *DeregisterContainerInstanceInput, opts ...request.Option) (*DeregisterContainerInstanceOutput, error)

DeregisterContainerInstanceWithContext is the same as DeregisterContainerInstance with the addition of the ability to pass a context and additional request options.

See DeregisterContainerInstance for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DeregisterTaskDefinition

func (c *ECS) DeregisterTaskDefinition(input *DeregisterTaskDefinitionInput) (*DeregisterTaskDefinitionOutput, error)

DeregisterTaskDefinition API operation for Amazon EC2 Container Service.

Deregisters the specified task definition by family and revision. Upon deregistration, the task definition is marked as INACTIVE. Existing tasks and services that reference an INACTIVE task definition continue to run without disruption. Existing services that reference an INACTIVE task definition can still scale up or down by modifying the service's desired count.

You cannot use an INACTIVE task definition to run new tasks or create new services, and you cannot update an existing service to reference an INACTIVE task definition. However, there may be up to a 10-minute window following deregistration where these restrictions have not yet taken effect.

At this time, INACTIVE task definitions remain discoverable in your account indefinitely. However, this behavior is subject to change in the future, so you should not rely on INACTIVE task definitions persisting beyond the lifecycle of any associated tasks and services.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DeregisterTaskDefinition for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeregisterTaskDefinition

DeregisterTaskDefinitionRequest

func (c *ECS) DeregisterTaskDefinitionRequest(input *DeregisterTaskDefinitionInput) (req *request.Request, output *DeregisterTaskDefinitionOutput)

DeregisterTaskDefinitionRequest generates a "aws/request.Request" representing the client's request for the DeregisterTaskDefinition operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DeregisterTaskDefinition for more information on using the DeregisterTaskDefinition API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DeregisterTaskDefinitionRequest method. req, resp := client.DeregisterTaskDefinitionRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DeregisterTaskDefinition

DeregisterTaskDefinitionWithContext

func (c *ECS) DeregisterTaskDefinitionWithContext(ctx aws.Context, input *DeregisterTaskDefinitionInput, opts ...request.Option) (*DeregisterTaskDefinitionOutput, error)

DeregisterTaskDefinitionWithContext is the same as DeregisterTaskDefinition with the addition of the ability to pass a context and additional request options.

See DeregisterTaskDefinition for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeClusters

func (c *ECS) DescribeClusters(input *DescribeClustersInput) (*DescribeClustersOutput, error)

DescribeClusters API operation for Amazon EC2 Container Service.

Describes one or more of your clusters.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DescribeClusters for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeClusters

Example

ECS DescribeClusters shared00

To describe a cluster

This example provides a description of the specified cluster in your default region.

{ svc := ecs.New(session.New()) input := &ecs.DescribeClustersInput{ Clusters: []*string{ aws.String("default"), }, } result, err := svc.DescribeClusters(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeClustersRequest

func (c *ECS) DescribeClustersRequest(input *DescribeClustersInput) (req *request.Request, output *DescribeClustersOutput)

DescribeClustersRequest generates a "aws/request.Request" representing the client's request for the DescribeClusters operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeClusters for more information on using the DescribeClusters API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeClustersRequest method. req, resp := client.DescribeClustersRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeClusters

DescribeClustersWithContext

func (c *ECS) DescribeClustersWithContext(ctx aws.Context, input *DescribeClustersInput, opts ...request.Option) (*DescribeClustersOutput, error)

DescribeClustersWithContext is the same as DescribeClusters with the addition of the ability to pass a context and additional request options.

See DescribeClusters for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeContainerInstances

func (c *ECS) DescribeContainerInstances(input *DescribeContainerInstancesInput) (*DescribeContainerInstancesOutput, error)

DescribeContainerInstances API operation for Amazon EC2 Container Service.

Describes Amazon Elastic Container Service container instances. Returns metadata about registered and remaining resources on each container instance requested.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DescribeContainerInstances for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeContainerInstances

Example

ECS DescribeContainerInstances shared00

To describe container instance

This example provides a description of the specified container instance in your default region, using the container instance UUID as an identifier.

{ svc := ecs.New(session.New()) input := &ecs.DescribeContainerInstancesInput{ Cluster: aws.String("default"), ContainerInstances: []*string{ aws.String("f2756532-8f13-4d53-87c9-aed50dc94cd7"), }, } result, err := svc.DescribeContainerInstances(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeContainerInstancesRequest

func (c *ECS) DescribeContainerInstancesRequest(input *DescribeContainerInstancesInput) (req *request.Request, output *DescribeContainerInstancesOutput)

DescribeContainerInstancesRequest generates a "aws/request.Request" representing the client's request for the DescribeContainerInstances operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeContainerInstances for more information on using the DescribeContainerInstances API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeContainerInstancesRequest method. req, resp := client.DescribeContainerInstancesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeContainerInstances

DescribeContainerInstancesWithContext

func (c *ECS) DescribeContainerInstancesWithContext(ctx aws.Context, input *DescribeContainerInstancesInput, opts ...request.Option) (*DescribeContainerInstancesOutput, error)

DescribeContainerInstancesWithContext is the same as DescribeContainerInstances with the addition of the ability to pass a context and additional request options.

See DescribeContainerInstances for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeServices

func (c *ECS) DescribeServices(input *DescribeServicesInput) (*DescribeServicesOutput, error)

DescribeServices API operation for Amazon EC2 Container Service.

Describes the specified services running in your cluster.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DescribeServices for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeServices

Example

ECS DescribeServices shared00

To describe a service

This example provides descriptive information about the service named ``ecs-simple-service``.

{ svc := ecs.New(session.New()) input := &ecs.DescribeServicesInput{ Services: []*string{ aws.String("ecs-simple-service"), }, } result, err := svc.DescribeServices(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeServicesRequest

func (c *ECS) DescribeServicesRequest(input *DescribeServicesInput) (req *request.Request, output *DescribeServicesOutput)

DescribeServicesRequest generates a "aws/request.Request" representing the client's request for the DescribeServices operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeServices for more information on using the DescribeServices API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeServicesRequest method. req, resp := client.DescribeServicesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeServices

DescribeServicesWithContext

func (c *ECS) DescribeServicesWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.Option) (*DescribeServicesOutput, error)

DescribeServicesWithContext is the same as DescribeServices with the addition of the ability to pass a context and additional request options.

See DescribeServices for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeTaskDefinition

func (c *ECS) DescribeTaskDefinition(input *DescribeTaskDefinitionInput) (*DescribeTaskDefinitionOutput, error)

DescribeTaskDefinition API operation for Amazon EC2 Container Service.

Describes a task definition. You can specify a family and revision to find information about a specific task definition, or you can simply specify the family to find the latest ACTIVE revision in that family.

You can only describe INACTIVE task definitions while an active task or service references them.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DescribeTaskDefinition for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeTaskDefinition

Example

ECS DescribeTaskDefinition shared00

To describe a task definition

This example provides a description of the specified task definition.

{ svc := ecs.New(session.New()) input := &ecs.DescribeTaskDefinitionInput{ TaskDefinition: aws.String("hello_world:8"), } result, err := svc.DescribeTaskDefinition(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeTaskDefinitionRequest

func (c *ECS) DescribeTaskDefinitionRequest(input *DescribeTaskDefinitionInput) (req *request.Request, output *DescribeTaskDefinitionOutput)

DescribeTaskDefinitionRequest generates a "aws/request.Request" representing the client's request for the DescribeTaskDefinition operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeTaskDefinition for more information on using the DescribeTaskDefinition API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeTaskDefinitionRequest method. req, resp := client.DescribeTaskDefinitionRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeTaskDefinition

DescribeTaskDefinitionWithContext

func (c *ECS) DescribeTaskDefinitionWithContext(ctx aws.Context, input *DescribeTaskDefinitionInput, opts ...request.Option) (*DescribeTaskDefinitionOutput, error)

DescribeTaskDefinitionWithContext is the same as DescribeTaskDefinition with the addition of the ability to pass a context and additional request options.

See DescribeTaskDefinition for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DescribeTasks

func (c *ECS) DescribeTasks(input *DescribeTasksInput) (*DescribeTasksOutput, error)

DescribeTasks API operation for Amazon EC2 Container Service.

Describes a specified task or tasks.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DescribeTasks for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeTasks

Example

ECS DescribeTasks shared00

To describe a task

This example provides a description of the specified task, using the task UUID as an identifier.

{ svc := ecs.New(session.New()) input := &ecs.DescribeTasksInput{ Tasks: []*string{ aws.String("c5cba4eb-5dad-405e-96db-71ef8eefe6a8"), }, } result, err := svc.DescribeTasks(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

DescribeTasksRequest

func (c *ECS) DescribeTasksRequest(input *DescribeTasksInput) (req *request.Request, output *DescribeTasksOutput)

DescribeTasksRequest generates a "aws/request.Request" representing the client's request for the DescribeTasks operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DescribeTasks for more information on using the DescribeTasks API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DescribeTasksRequest method. req, resp := client.DescribeTasksRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DescribeTasks

DescribeTasksWithContext

func (c *ECS) DescribeTasksWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.Option) (*DescribeTasksOutput, error)

DescribeTasksWithContext is the same as DescribeTasks with the addition of the ability to pass a context and additional request options.

See DescribeTasks for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

DiscoverPollEndpoint

func (c *ECS) DiscoverPollEndpoint(input *DiscoverPollEndpointInput) (*DiscoverPollEndpointOutput, error)

DiscoverPollEndpoint API operation for Amazon EC2 Container Service.

This action is only used by the Amazon ECS agent, and it is not intended for use outside of the agent.

Returns an endpoint for the Amazon ECS agent to poll for updates.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation DiscoverPollEndpoint for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DiscoverPollEndpoint

DiscoverPollEndpointRequest

func (c *ECS) DiscoverPollEndpointRequest(input *DiscoverPollEndpointInput) (req *request.Request, output *DiscoverPollEndpointOutput)

DiscoverPollEndpointRequest generates a "aws/request.Request" representing the client's request for the DiscoverPollEndpoint operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See DiscoverPollEndpoint for more information on using the DiscoverPollEndpoint API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the DiscoverPollEndpointRequest method. req, resp := client.DiscoverPollEndpointRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/DiscoverPollEndpoint

DiscoverPollEndpointWithContext

func (c *ECS) DiscoverPollEndpointWithContext(ctx aws.Context, input *DiscoverPollEndpointInput, opts ...request.Option) (*DiscoverPollEndpointOutput, error)

DiscoverPollEndpointWithContext is the same as DiscoverPollEndpoint with the addition of the ability to pass a context and additional request options.

See DiscoverPollEndpoint for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListAccountSettings

func (c *ECS) ListAccountSettings(input *ListAccountSettingsInput) (*ListAccountSettingsOutput, error)

ListAccountSettings API operation for Amazon EC2 Container Service.

Lists the account settings for an Amazon ECS resource for a specified principal.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListAccountSettings for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListAccountSettings

Examples

ECS ListAccountSettings shared00

To view your effective account settings

This example displays the effective account settings for your account.

{ svc := ecs.New(session.New()) input := &ecs.ListAccountSettingsInput{ EffectiveSettings: aws.Bool(true), } result, err := svc.ListAccountSettings(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS ListAccountSettings shared01

To view the effective account settings for a specific IAM user or IAM role

This example displays the effective account settings for the specified user or role.

{ svc := ecs.New(session.New()) input := &ecs.ListAccountSettingsInput{ EffectiveSettings: aws.Bool(true), PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), } result, err := svc.ListAccountSettings(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListAccountSettingsRequest

func (c *ECS) ListAccountSettingsRequest(input *ListAccountSettingsInput) (req *request.Request, output *ListAccountSettingsOutput)

ListAccountSettingsRequest generates a "aws/request.Request" representing the client's request for the ListAccountSettings operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListAccountSettings for more information on using the ListAccountSettings API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListAccountSettingsRequest method. req, resp := client.ListAccountSettingsRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListAccountSettings

ListAccountSettingsWithContext

func (c *ECS) ListAccountSettingsWithContext(ctx aws.Context, input *ListAccountSettingsInput, opts ...request.Option) (*ListAccountSettingsOutput, error)

ListAccountSettingsWithContext is the same as ListAccountSettings with the addition of the ability to pass a context and additional request options.

See ListAccountSettings for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListAttributes

func (c *ECS) ListAttributes(input *ListAttributesInput) (*ListAttributesOutput, error)

ListAttributes API operation for Amazon EC2 Container Service.

Lists the attributes for Amazon ECS resources within a specified target type and cluster. When you specify a target type and cluster, ListAttributes returns a list of attribute objects, one for each attribute on each resource. You can filter the list of results to a single attribute name to only return results that have that name. You can also filter the results by attribute name and value, for example, to see which container instances in a cluster are running a Linux AMI (ecs.os-type=linux).

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListAttributes for usage and error information.

Returned Error Codes:

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListAttributes

ListAttributesRequest

func (c *ECS) ListAttributesRequest(input *ListAttributesInput) (req *request.Request, output *ListAttributesOutput)

ListAttributesRequest generates a "aws/request.Request" representing the client's request for the ListAttributes operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListAttributes for more information on using the ListAttributes API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListAttributesRequest method. req, resp := client.ListAttributesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListAttributes

ListAttributesWithContext

func (c *ECS) ListAttributesWithContext(ctx aws.Context, input *ListAttributesInput, opts ...request.Option) (*ListAttributesOutput, error)

ListAttributesWithContext is the same as ListAttributes with the addition of the ability to pass a context and additional request options.

See ListAttributes for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListClusters

func (c *ECS) ListClusters(input *ListClustersInput) (*ListClustersOutput, error)

ListClusters API operation for Amazon EC2 Container Service.

Returns a list of existing clusters.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListClusters for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListClusters

Example

ECS ListClusters shared00

To list your available clusters

This example lists all of your available clusters in your default region.

{ svc := ecs.New(session.New()) input := &ecs.ListClustersInput{} result, err := svc.ListClusters(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListClustersPages

func (c *ECS) ListClustersPages(input *ListClustersInput, fn func(*ListClustersOutput, bool) bool) error

ListClustersPages iterates over the pages of a ListClusters operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListClusters method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListClusters operation. pageNum := 0 err := client.ListClustersPages(params, func(page *ListClustersOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListClustersPagesWithContext

func (c *ECS) ListClustersPagesWithContext(ctx aws.Context, input *ListClustersInput, fn func(*ListClustersOutput, bool) bool, opts ...request.Option) error

ListClustersPagesWithContext same as ListClustersPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListClustersRequest

func (c *ECS) ListClustersRequest(input *ListClustersInput) (req *request.Request, output *ListClustersOutput)

ListClustersRequest generates a "aws/request.Request" representing the client's request for the ListClusters operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListClusters for more information on using the ListClusters API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListClustersRequest method. req, resp := client.ListClustersRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListClusters

ListClustersWithContext

func (c *ECS) ListClustersWithContext(ctx aws.Context, input *ListClustersInput, opts ...request.Option) (*ListClustersOutput, error)

ListClustersWithContext is the same as ListClusters with the addition of the ability to pass a context and additional request options.

See ListClusters for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListContainerInstances

func (c *ECS) ListContainerInstances(input *ListContainerInstancesInput) (*ListContainerInstancesOutput, error)

ListContainerInstances API operation for Amazon EC2 Container Service.

Returns a list of container instances in a specified cluster. You can filter the results of a ListContainerInstances operation with cluster query language statements inside the filter parameter. For more information, see Cluster Query Language (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-query-language.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListContainerInstances for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListContainerInstances

Example

ECS ListContainerInstances shared00

To list your available container instances in a cluster

This example lists all of your available container instances in the specified cluster in your default region.

{ svc := ecs.New(session.New()) input := &ecs.ListContainerInstancesInput{ Cluster: aws.String("default"), } result, err := svc.ListContainerInstances(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListContainerInstancesPages

func (c *ECS) ListContainerInstancesPages(input *ListContainerInstancesInput, fn func(*ListContainerInstancesOutput, bool) bool) error

ListContainerInstancesPages iterates over the pages of a ListContainerInstances operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListContainerInstances method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListContainerInstances operation. pageNum := 0 err := client.ListContainerInstancesPages(params, func(page *ListContainerInstancesOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListContainerInstancesPagesWithContext

func (c *ECS) ListContainerInstancesPagesWithContext(ctx aws.Context, input *ListContainerInstancesInput, fn func(*ListContainerInstancesOutput, bool) bool, opts ...request.Option) error

ListContainerInstancesPagesWithContext same as ListContainerInstancesPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListContainerInstancesRequest

func (c *ECS) ListContainerInstancesRequest(input *ListContainerInstancesInput) (req *request.Request, output *ListContainerInstancesOutput)

ListContainerInstancesRequest generates a "aws/request.Request" representing the client's request for the ListContainerInstances operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListContainerInstances for more information on using the ListContainerInstances API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListContainerInstancesRequest method. req, resp := client.ListContainerInstancesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListContainerInstances

ListContainerInstancesWithContext

func (c *ECS) ListContainerInstancesWithContext(ctx aws.Context, input *ListContainerInstancesInput, opts ...request.Option) (*ListContainerInstancesOutput, error)

ListContainerInstancesWithContext is the same as ListContainerInstances with the addition of the ability to pass a context and additional request options.

See ListContainerInstances for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListServices

func (c *ECS) ListServices(input *ListServicesInput) (*ListServicesOutput, error)

ListServices API operation for Amazon EC2 Container Service.

Lists the services that are running in a specified cluster.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListServices for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListServices

Example

ECS ListServices shared00

To list the services in a cluster

This example lists the services running in the default cluster for an account.

{ svc := ecs.New(session.New()) input := &ecs.ListServicesInput{} result, err := svc.ListServices(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListServicesPages

func (c *ECS) ListServicesPages(input *ListServicesInput, fn func(*ListServicesOutput, bool) bool) error

ListServicesPages iterates over the pages of a ListServices operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListServices method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListServices operation. pageNum := 0 err := client.ListServicesPages(params, func(page *ListServicesOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListServicesPagesWithContext

func (c *ECS) ListServicesPagesWithContext(ctx aws.Context, input *ListServicesInput, fn func(*ListServicesOutput, bool) bool, opts ...request.Option) error

ListServicesPagesWithContext same as ListServicesPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListServicesRequest

func (c *ECS) ListServicesRequest(input *ListServicesInput) (req *request.Request, output *ListServicesOutput)

ListServicesRequest generates a "aws/request.Request" representing the client's request for the ListServices operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListServices for more information on using the ListServices API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListServicesRequest method. req, resp := client.ListServicesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListServices

ListServicesWithContext

func (c *ECS) ListServicesWithContext(ctx aws.Context, input *ListServicesInput, opts ...request.Option) (*ListServicesOutput, error)

ListServicesWithContext is the same as ListServices with the addition of the ability to pass a context and additional request options.

See ListServices for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTagsForResource

func (c *ECS) ListTagsForResource(input *ListTagsForResourceInput) (*ListTagsForResourceOutput, error)

ListTagsForResource API operation for Amazon EC2 Container Service.

List the tags for an Amazon ECS resource.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListTagsForResource for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTagsForResource

Example

ECS ListTagsForResource shared00

To list the tags for a cluster.

This example lists the tags for the 'dev' cluster.

{ svc := ecs.New(session.New()) input := &ecs.ListTagsForResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), } result, err := svc.ListTagsForResource(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListTagsForResourceRequest

func (c *ECS) ListTagsForResourceRequest(input *ListTagsForResourceInput) (req *request.Request, output *ListTagsForResourceOutput)

ListTagsForResourceRequest generates a "aws/request.Request" representing the client's request for the ListTagsForResource operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListTagsForResource for more information on using the ListTagsForResource API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListTagsForResourceRequest method. req, resp := client.ListTagsForResourceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTagsForResource

ListTagsForResourceWithContext

func (c *ECS) ListTagsForResourceWithContext(ctx aws.Context, input *ListTagsForResourceInput, opts ...request.Option) (*ListTagsForResourceOutput, error)

ListTagsForResourceWithContext is the same as ListTagsForResource with the addition of the ability to pass a context and additional request options.

See ListTagsForResource for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitionFamilies

func (c *ECS) ListTaskDefinitionFamilies(input *ListTaskDefinitionFamiliesInput) (*ListTaskDefinitionFamiliesOutput, error)

ListTaskDefinitionFamilies API operation for Amazon EC2 Container Service.

Returns a list of task definition families that are registered to your account (which may include task definition families that no longer have any ACTIVE task definition revisions).

You can filter out task definition families that do not contain any ACTIVE task definition revisions by setting the status parameter to ACTIVE. You can also filter the results with the familyPrefix parameter.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListTaskDefinitionFamilies for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTaskDefinitionFamilies

Examples

ECS ListTaskDefinitionFamilies shared00

To list your registered task definition families

This example lists all of your registered task definition families.

{ svc := ecs.New(session.New()) input := &ecs.ListTaskDefinitionFamiliesInput{} result, err := svc.ListTaskDefinitionFamilies(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS ListTaskDefinitionFamilies shared01

To filter your registered task definition families

This example lists the task definition revisions that start with "hpcc".

{ svc := ecs.New(session.New()) input := &ecs.ListTaskDefinitionFamiliesInput{ FamilyPrefix: aws.String("hpcc"), } result, err := svc.ListTaskDefinitionFamilies(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListTaskDefinitionFamiliesPages

func (c *ECS) ListTaskDefinitionFamiliesPages(input *ListTaskDefinitionFamiliesInput, fn func(*ListTaskDefinitionFamiliesOutput, bool) bool) error

ListTaskDefinitionFamiliesPages iterates over the pages of a ListTaskDefinitionFamilies operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListTaskDefinitionFamilies method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListTaskDefinitionFamilies operation. pageNum := 0 err := client.ListTaskDefinitionFamiliesPages(params, func(page *ListTaskDefinitionFamiliesOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitionFamiliesPagesWithContext

func (c *ECS) ListTaskDefinitionFamiliesPagesWithContext(ctx aws.Context, input *ListTaskDefinitionFamiliesInput, fn func(*ListTaskDefinitionFamiliesOutput, bool) bool, opts ...request.Option) error

ListTaskDefinitionFamiliesPagesWithContext same as ListTaskDefinitionFamiliesPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitionFamiliesRequest

func (c *ECS) ListTaskDefinitionFamiliesRequest(input *ListTaskDefinitionFamiliesInput) (req *request.Request, output *ListTaskDefinitionFamiliesOutput)

ListTaskDefinitionFamiliesRequest generates a "aws/request.Request" representing the client's request for the ListTaskDefinitionFamilies operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListTaskDefinitionFamilies for more information on using the ListTaskDefinitionFamilies API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListTaskDefinitionFamiliesRequest method. req, resp := client.ListTaskDefinitionFamiliesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTaskDefinitionFamilies

ListTaskDefinitionFamiliesWithContext

func (c *ECS) ListTaskDefinitionFamiliesWithContext(ctx aws.Context, input *ListTaskDefinitionFamiliesInput, opts ...request.Option) (*ListTaskDefinitionFamiliesOutput, error)

ListTaskDefinitionFamiliesWithContext is the same as ListTaskDefinitionFamilies with the addition of the ability to pass a context and additional request options.

See ListTaskDefinitionFamilies for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitions

func (c *ECS) ListTaskDefinitions(input *ListTaskDefinitionsInput) (*ListTaskDefinitionsOutput, error)

ListTaskDefinitions API operation for Amazon EC2 Container Service.

Returns a list of task definitions that are registered to your account. You can filter the results by family name with the familyPrefix parameter or by status with the status parameter.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListTaskDefinitions for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTaskDefinitions

Examples

ECS ListTaskDefinitions shared00

To list your registered task definitions

This example lists all of your registered task definitions.

{ svc := ecs.New(session.New()) input := &ecs.ListTaskDefinitionsInput{} result, err := svc.ListTaskDefinitions(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS ListTaskDefinitions shared01

To list the registered task definitions in a family

This example lists the task definition revisions of a specified family.

{ svc := ecs.New(session.New()) input := &ecs.ListTaskDefinitionsInput{ FamilyPrefix: aws.String("wordpress"), } result, err := svc.ListTaskDefinitions(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListTaskDefinitionsPages

func (c *ECS) ListTaskDefinitionsPages(input *ListTaskDefinitionsInput, fn func(*ListTaskDefinitionsOutput, bool) bool) error

ListTaskDefinitionsPages iterates over the pages of a ListTaskDefinitions operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListTaskDefinitions method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListTaskDefinitions operation. pageNum := 0 err := client.ListTaskDefinitionsPages(params, func(page *ListTaskDefinitionsOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitionsPagesWithContext

func (c *ECS) ListTaskDefinitionsPagesWithContext(ctx aws.Context, input *ListTaskDefinitionsInput, fn func(*ListTaskDefinitionsOutput, bool) bool, opts ...request.Option) error

ListTaskDefinitionsPagesWithContext same as ListTaskDefinitionsPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTaskDefinitionsRequest

func (c *ECS) ListTaskDefinitionsRequest(input *ListTaskDefinitionsInput) (req *request.Request, output *ListTaskDefinitionsOutput)

ListTaskDefinitionsRequest generates a "aws/request.Request" representing the client's request for the ListTaskDefinitions operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListTaskDefinitions for more information on using the ListTaskDefinitions API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListTaskDefinitionsRequest method. req, resp := client.ListTaskDefinitionsRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTaskDefinitions

ListTaskDefinitionsWithContext

func (c *ECS) ListTaskDefinitionsWithContext(ctx aws.Context, input *ListTaskDefinitionsInput, opts ...request.Option) (*ListTaskDefinitionsOutput, error)

ListTaskDefinitionsWithContext is the same as ListTaskDefinitions with the addition of the ability to pass a context and additional request options.

See ListTaskDefinitions for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTasks

func (c *ECS) ListTasks(input *ListTasksInput) (*ListTasksOutput, error)

ListTasks API operation for Amazon EC2 Container Service.

Returns a list of tasks for a specified cluster. You can filter the results by family name, by a particular container instance, or by the desired status of the task with the family, containerInstance, and desiredStatus parameters.

Recently stopped tasks might appear in the returned results. Currently, stopped tasks appear in the returned results for at least one hour.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation ListTasks for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeServiceNotFoundException "ServiceNotFoundException" The specified service could not be found. You can view your available services with ListServices. Amazon ECS services are cluster-specific and Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTasks

Examples

ECS ListTasks shared00

To list the tasks in a cluster

This example lists all of the tasks in a cluster.

{ svc := ecs.New(session.New()) input := &ecs.ListTasksInput{ Cluster: aws.String("default"), } result, err := svc.ListTasks(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS ListTasks shared01

To list the tasks on a particular container instance

This example lists the tasks of a specified container instance. Specifying a ``containerInstance`` value limits the results to tasks that belong to that container instance.

{ svc := ecs.New(session.New()) input := &ecs.ListTasksInput{ Cluster: aws.String("default"), ContainerInstance: aws.String("f6bbb147-5370-4ace-8c73-c7181ded911f"), } result, err := svc.ListTasks(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

ListTasksPages

func (c *ECS) ListTasksPages(input *ListTasksInput, fn func(*ListTasksOutput, bool) bool) error

ListTasksPages iterates over the pages of a ListTasks operation, calling the "fn" function with the response data for each page. To stop iterating, return false from the fn function.

See ListTasks method for more information on how to use this operation.

Note: This operation can generate multiple requests to a service.

// Example iterating over at most 3 pages of a ListTasks operation. pageNum := 0 err := client.ListTasksPages(params, func(page *ListTasksOutput, lastPage bool) bool { pageNum++ fmt.Println(page) return pageNum <= 3 })

See Also

For more information about using this API, see AWS API Documentation.

ListTasksPagesWithContext

func (c *ECS) ListTasksPagesWithContext(ctx aws.Context, input *ListTasksInput, fn func(*ListTasksOutput, bool) bool, opts ...request.Option) error

ListTasksPagesWithContext same as ListTasksPages except it takes a Context and allows setting request options on the pages.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

ListTasksRequest

func (c *ECS) ListTasksRequest(input *ListTasksInput) (req *request.Request, output *ListTasksOutput)

ListTasksRequest generates a "aws/request.Request" representing the client's request for the ListTasks operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See ListTasks for more information on using the ListTasks API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the ListTasksRequest method. req, resp := client.ListTasksRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/ListTasks

ListTasksWithContext

func (c *ECS) ListTasksWithContext(ctx aws.Context, input *ListTasksInput, opts ...request.Option) (*ListTasksOutput, error)

ListTasksWithContext is the same as ListTasks with the addition of the ability to pass a context and additional request options.

See ListTasks for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

PutAccountSetting

func (c *ECS) PutAccountSetting(input *PutAccountSettingInput) (*PutAccountSettingOutput, error)

PutAccountSetting API operation for Amazon EC2 Container Service.

Modifies the ARN and resource ID format of a resource type for a specified IAM user, IAM role, or the root user for an account. If the account setting for the root user is changed, it sets the default setting for all of the IAM users and roles for which no individual account setting has been set. The opt-in and opt-out account setting can be set for each Amazon ECS resource separately. The ARN and resource ID format of a resource will be defined by the opt-in status of the IAM user or role that created the resource. Enabling this setting is required to use new Amazon ECS features such as resource tagging. For more information, see Amazon Resource Names (ARNs) and IDs (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-resource-ids.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation PutAccountSetting for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAccountSetting

Examples

ECS PutAccountSetting shared00

To modify your account settings

This example modifies your account settings to opt in to the new ARN and resource ID format for Amazon ECS services. If you’re using this command as the root user, then changes apply to the entire AWS account, unless an IAM user or role explicitly overrides these settings for themselves.

{ svc := ecs.New(session.New()) input := &ecs.PutAccountSettingInput{ Name: aws.String("serviceLongArnFormat"), Value: aws.String("enabled"), } result, err := svc.PutAccountSetting(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS PutAccountSetting shared01

To modify the account settings for a specific IAM user or IAM role

This example modifies the account setting for a specific IAM user or IAM role to opt in to the new ARN and resource ID format for Amazon ECS container instances. If you’re using this command as the root user, then changes apply to the entire AWS account, unless an IAM user or role explicitly overrides these settings for themselves.

{ svc := ecs.New(session.New()) input := &ecs.PutAccountSettingInput{ Name: aws.String("containerInstanceLongArnFormat"), PrincipalArn: aws.String("arn:aws:iam::<aws_account_id>:user/principalName"), Value: aws.String("enabled"), } result, err := svc.PutAccountSetting(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

PutAccountSettingDefault

func (c *ECS) PutAccountSettingDefault(input *PutAccountSettingDefaultInput) (*PutAccountSettingDefaultOutput, error)

PutAccountSettingDefault API operation for Amazon EC2 Container Service.

Modifies the ARN and resource ID format of a resource type for all IAM users on an account for which no individual account setting has been set. Enabling this setting is required to use new Amazon ECS features such as resource tagging.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation PutAccountSettingDefault for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAccountSettingDefault

Example

ECS PutAccountSettingDefault shared00

To modify the default account settings for all IAM users or roles on an account

This example modifies the default account setting for the specified resource for all IAM users or roles on an account. These changes apply to the entire AWS account, unless an IAM user or role explicitly overrides these settings for themselves.

{ svc := ecs.New(session.New()) input := &ecs.PutAccountSettingDefaultInput{ Name: aws.String("serviceLongArnFormat"), Value: aws.String("enabled"), } result, err := svc.PutAccountSettingDefault(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

PutAccountSettingDefaultRequest

func (c *ECS) PutAccountSettingDefaultRequest(input *PutAccountSettingDefaultInput) (req *request.Request, output *PutAccountSettingDefaultOutput)

PutAccountSettingDefaultRequest generates a "aws/request.Request" representing the client's request for the PutAccountSettingDefault operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PutAccountSettingDefault for more information on using the PutAccountSettingDefault API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PutAccountSettingDefaultRequest method. req, resp := client.PutAccountSettingDefaultRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAccountSettingDefault

PutAccountSettingDefaultWithContext

func (c *ECS) PutAccountSettingDefaultWithContext(ctx aws.Context, input *PutAccountSettingDefaultInput, opts ...request.Option) (*PutAccountSettingDefaultOutput, error)

PutAccountSettingDefaultWithContext is the same as PutAccountSettingDefault with the addition of the ability to pass a context and additional request options.

See PutAccountSettingDefault for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

PutAccountSettingRequest

func (c *ECS) PutAccountSettingRequest(input *PutAccountSettingInput) (req *request.Request, output *PutAccountSettingOutput)

PutAccountSettingRequest generates a "aws/request.Request" representing the client's request for the PutAccountSetting operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PutAccountSetting for more information on using the PutAccountSetting API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PutAccountSettingRequest method. req, resp := client.PutAccountSettingRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAccountSetting

PutAccountSettingWithContext

func (c *ECS) PutAccountSettingWithContext(ctx aws.Context, input *PutAccountSettingInput, opts ...request.Option) (*PutAccountSettingOutput, error)

PutAccountSettingWithContext is the same as PutAccountSetting with the addition of the ability to pass a context and additional request options.

See PutAccountSetting for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

PutAttributes

func (c *ECS) PutAttributes(input *PutAttributesInput) (*PutAttributesOutput, error)

PutAttributes API operation for Amazon EC2 Container Service.

Create or update an attribute on an Amazon ECS resource. If the attribute does not exist, it is created. If the attribute exists, its value is replaced with the specified value. To delete an attribute, use DeleteAttributes. For more information, see Attributes (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html#attributes) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation PutAttributes for usage and error information.

Returned Error Codes:

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeTargetNotFoundException "TargetNotFoundException" The specified target could not be found. You can view your available container instances with ListContainerInstances. Amazon ECS container instances are cluster-specific and Region-specific.

  • ErrCodeAttributeLimitExceededException "AttributeLimitExceededException" You can apply up to 10 custom attributes per resource. You can view the attributes of a resource with ListAttributes. You can remove existing attributes on a resource with DeleteAttributes.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAttributes

PutAttributesRequest

func (c *ECS) PutAttributesRequest(input *PutAttributesInput) (req *request.Request, output *PutAttributesOutput)

PutAttributesRequest generates a "aws/request.Request" representing the client's request for the PutAttributes operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See PutAttributes for more information on using the PutAttributes API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the PutAttributesRequest method. req, resp := client.PutAttributesRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/PutAttributes

PutAttributesWithContext

func (c *ECS) PutAttributesWithContext(ctx aws.Context, input *PutAttributesInput, opts ...request.Option) (*PutAttributesOutput, error)

PutAttributesWithContext is the same as PutAttributes with the addition of the ability to pass a context and additional request options.

See PutAttributes for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

RegisterContainerInstance

func (c *ECS) RegisterContainerInstance(input *RegisterContainerInstanceInput) (*RegisterContainerInstanceOutput, error)

RegisterContainerInstance API operation for Amazon EC2 Container Service.

This action is only used by the Amazon ECS agent, and it is not intended for use outside of the agent.

Registers an EC2 instance into the specified cluster. This instance becomes available to place containers on.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation RegisterContainerInstance for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RegisterContainerInstance

RegisterContainerInstanceRequest

func (c *ECS) RegisterContainerInstanceRequest(input *RegisterContainerInstanceInput) (req *request.Request, output *RegisterContainerInstanceOutput)

RegisterContainerInstanceRequest generates a "aws/request.Request" representing the client's request for the RegisterContainerInstance operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See RegisterContainerInstance for more information on using the RegisterContainerInstance API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the RegisterContainerInstanceRequest method. req, resp := client.RegisterContainerInstanceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RegisterContainerInstance

RegisterContainerInstanceWithContext

func (c *ECS) RegisterContainerInstanceWithContext(ctx aws.Context, input *RegisterContainerInstanceInput, opts ...request.Option) (*RegisterContainerInstanceOutput, error)

RegisterContainerInstanceWithContext is the same as RegisterContainerInstance with the addition of the ability to pass a context and additional request options.

See RegisterContainerInstance for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

RegisterTaskDefinition

func (c *ECS) RegisterTaskDefinition(input *RegisterTaskDefinitionInput) (*RegisterTaskDefinitionOutput, error)

RegisterTaskDefinition API operation for Amazon EC2 Container Service.

Registers a new task definition from the supplied family and containerDefinitions. Optionally, you can add data volumes to your containers with the volumes parameter. For more information about task definition parameters and defaults, see Amazon ECS Task Definitions (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html) in the Amazon Elastic Container Service Developer Guide.

You can specify an IAM role for your task with the taskRoleArn parameter. When you specify an IAM role for a task, its containers can then use the latest versions of the AWS CLI or SDKs to make API requests to the AWS services that are specified in the IAM policy associated with the role. For more information, see IAM Roles for Tasks (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html) in the Amazon Elastic Container Service Developer Guide.

You can specify a Docker networking mode for the containers in your task definition with the networkMode parameter. The available network modes correspond to those described in Network settings (https://docs.docker.com/engine/reference/run/#/network-settings) in the Docker run reference. If you specify the awsvpc network mode, the task is allocated an elastic network interface, and you must specify a NetworkConfiguration when you create a service or run a task with the task definition. For more information, see Task Networking (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation RegisterTaskDefinition for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RegisterTaskDefinition

Example

ECS RegisterTaskDefinition shared00

To register a task definition

This example registers a task definition to the specified family.

{ svc := ecs.New(session.New()) input := &ecs.RegisterTaskDefinitionInput{ ContainerDefinitions: []*ecs.ContainerDefinition{ { Command: []*string{ aws.String("sleep"), aws.String("360"), }, Cpu: aws.Int64(10), Essential: aws.Bool(true), Image: aws.String("busybox"), Memory: aws.Int64(10), Name: aws.String("sleep"), }, }, Family: aws.String("sleep360"), TaskRoleArn: aws.String(""), } result, err := svc.RegisterTaskDefinition(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

RegisterTaskDefinitionRequest

func (c *ECS) RegisterTaskDefinitionRequest(input *RegisterTaskDefinitionInput) (req *request.Request, output *RegisterTaskDefinitionOutput)

RegisterTaskDefinitionRequest generates a "aws/request.Request" representing the client's request for the RegisterTaskDefinition operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See RegisterTaskDefinition for more information on using the RegisterTaskDefinition API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the RegisterTaskDefinitionRequest method. req, resp := client.RegisterTaskDefinitionRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RegisterTaskDefinition

RegisterTaskDefinitionWithContext

func (c *ECS) RegisterTaskDefinitionWithContext(ctx aws.Context, input *RegisterTaskDefinitionInput, opts ...request.Option) (*RegisterTaskDefinitionOutput, error)

RegisterTaskDefinitionWithContext is the same as RegisterTaskDefinition with the addition of the ability to pass a context and additional request options.

See RegisterTaskDefinition for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

RunTask

func (c *ECS) RunTask(input *RunTaskInput) (*RunTaskOutput, error)

RunTask API operation for Amazon EC2 Container Service.

Starts a new task using the specified task definition.

You can allow Amazon ECS to place tasks for you, or you can customize how Amazon ECS places tasks using placement constraints and placement strategies. For more information, see Scheduling Tasks (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduling_tasks.html) in the Amazon Elastic Container Service Developer Guide.

Alternatively, you can use StartTask to use your own scheduler or place tasks manually on specific container instances.

The Amazon ECS API follows an eventual consistency model, due to the distributed nature of the system supporting the API. This means that the result of an API command you run that affects your Amazon ECS resources might not be immediately visible to all subsequent commands you run. Keep this in mind when you carry out an API command that immediately follows a previous API command.

To manage eventual consistency, you can do the following:

  • Confirm the state of the resource before you run a command to modify it. Run the DescribeTasks command using an exponential backoff algorithm to ensure that you allow enough time for the previous command to propagate through the system. To do this, run the DescribeTasks command repeatedly, starting with a couple of seconds of wait time and increasing gradually up to five minutes of wait time.

  • Add wait time between subsequent commands, even if the DescribeTasks command returns an accurate response. Apply an exponential backoff algorithm starting with a couple of seconds of wait time, and increase gradually up to about five minutes of wait time.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation RunTask for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeUnsupportedFeatureException "UnsupportedFeatureException" The specified task is not supported in this Region.

  • ErrCodePlatformUnknownException "PlatformUnknownException" The specified platform version does not exist.

  • ErrCodePlatformTaskDefinitionIncompatibilityException "PlatformTaskDefinitionIncompatibilityException" The specified platform version does not satisfy the task definition's required capabilities.

  • ErrCodeAccessDeniedException "AccessDeniedException" You do not have authorization to perform the requested action.

  • ErrCodeBlockedException "BlockedException" Your AWS account has been blocked. For more information, contact AWS Support

(http://aws.amazon.com/contact-us/).

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RunTask

Example

ECS RunTask shared00

To run a task on your default cluster

This example runs the specified task definition on your default cluster.

{ svc := ecs.New(session.New()) input := &ecs.RunTaskInput{ Cluster: aws.String("default"), TaskDefinition: aws.String("sleep360:1"), } result, err := svc.RunTask(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) case ecs.ErrCodeBlockedException: fmt.Println(ecs.ErrCodeBlockedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

RunTaskRequest

func (c *ECS) RunTaskRequest(input *RunTaskInput) (req *request.Request, output *RunTaskOutput)

RunTaskRequest generates a "aws/request.Request" representing the client's request for the RunTask operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See RunTask for more information on using the RunTask API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the RunTaskRequest method. req, resp := client.RunTaskRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/RunTask

RunTaskWithContext

func (c *ECS) RunTaskWithContext(ctx aws.Context, input *RunTaskInput, opts ...request.Option) (*RunTaskOutput, error)

RunTaskWithContext is the same as RunTask with the addition of the ability to pass a context and additional request options.

See RunTask for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

StartTask

func (c *ECS) StartTask(input *StartTaskInput) (*StartTaskOutput, error)

StartTask API operation for Amazon EC2 Container Service.

Starts a new task from the specified task definition on the specified container instance or instances.

Alternatively, you can use RunTask to place tasks for you. For more information, see Scheduling Tasks (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduling_tasks.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation StartTask for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/StartTask

StartTaskRequest

func (c *ECS) StartTaskRequest(input *StartTaskInput) (req *request.Request, output *StartTaskOutput)

StartTaskRequest generates a "aws/request.Request" representing the client's request for the StartTask operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See StartTask for more information on using the StartTask API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the StartTaskRequest method. req, resp := client.StartTaskRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/StartTask

StartTaskWithContext

func (c *ECS) StartTaskWithContext(ctx aws.Context, input *StartTaskInput, opts ...request.Option) (*StartTaskOutput, error)

StartTaskWithContext is the same as StartTask with the addition of the ability to pass a context and additional request options.

See StartTask for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

StopTask

func (c *ECS) StopTask(input *StopTaskInput) (*StopTaskOutput, error)

StopTask API operation for Amazon EC2 Container Service.

Stops a running task. Any tags associated with the task will be deleted.

When StopTask is called on a task, the equivalent of docker stop is issued to the containers running in the task. This results in a SIGTERM value and a default 30-second timeout, after which the SIGKILL value is sent and the containers are forcibly stopped. If the container handles the SIGTERM value gracefully and exits within 30 seconds from receiving it, no SIGKILL value is sent.

The default 30-second timeout can be configured on the Amazon ECS container agent with the ECS_CONTAINER_STOP_TIMEOUT variable. For more information, see Amazon ECS Container Agent Configuration (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation StopTask for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/StopTask

StopTaskRequest

func (c *ECS) StopTaskRequest(input *StopTaskInput) (req *request.Request, output *StopTaskOutput)

StopTaskRequest generates a "aws/request.Request" representing the client's request for the StopTask operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See StopTask for more information on using the StopTask API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the StopTaskRequest method. req, resp := client.StopTaskRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/StopTask

StopTaskWithContext

func (c *ECS) StopTaskWithContext(ctx aws.Context, input *StopTaskInput, opts ...request.Option) (*StopTaskOutput, error)

StopTaskWithContext is the same as StopTask with the addition of the ability to pass a context and additional request options.

See StopTask for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

SubmitContainerStateChange

func (c *ECS) SubmitContainerStateChange(input *SubmitContainerStateChangeInput) (*SubmitContainerStateChangeOutput, error)

SubmitContainerStateChange API operation for Amazon EC2 Container Service.

This action is only used by the Amazon ECS agent, and it is not intended for use outside of the agent.

Sent to acknowledge that a container changed states.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation SubmitContainerStateChange for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeAccessDeniedException "AccessDeniedException" You do not have authorization to perform the requested action.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/SubmitContainerStateChange

SubmitContainerStateChangeRequest

func (c *ECS) SubmitContainerStateChangeRequest(input *SubmitContainerStateChangeInput) (req *request.Request, output *SubmitContainerStateChangeOutput)

SubmitContainerStateChangeRequest generates a "aws/request.Request" representing the client's request for the SubmitContainerStateChange operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See SubmitContainerStateChange for more information on using the SubmitContainerStateChange API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the SubmitContainerStateChangeRequest method. req, resp := client.SubmitContainerStateChangeRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/SubmitContainerStateChange

SubmitContainerStateChangeWithContext

func (c *ECS) SubmitContainerStateChangeWithContext(ctx aws.Context, input *SubmitContainerStateChangeInput, opts ...request.Option) (*SubmitContainerStateChangeOutput, error)

SubmitContainerStateChangeWithContext is the same as SubmitContainerStateChange with the addition of the ability to pass a context and additional request options.

See SubmitContainerStateChange for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

SubmitTaskStateChange

func (c *ECS) SubmitTaskStateChange(input *SubmitTaskStateChangeInput) (*SubmitTaskStateChangeOutput, error)

SubmitTaskStateChange API operation for Amazon EC2 Container Service.

This action is only used by the Amazon ECS agent, and it is not intended for use outside of the agent.

Sent to acknowledge that a task changed states.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation SubmitTaskStateChange for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeAccessDeniedException "AccessDeniedException" You do not have authorization to perform the requested action.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/SubmitTaskStateChange

SubmitTaskStateChangeRequest

func (c *ECS) SubmitTaskStateChangeRequest(input *SubmitTaskStateChangeInput) (req *request.Request, output *SubmitTaskStateChangeOutput)

SubmitTaskStateChangeRequest generates a "aws/request.Request" representing the client's request for the SubmitTaskStateChange operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See SubmitTaskStateChange for more information on using the SubmitTaskStateChange API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the SubmitTaskStateChangeRequest method. req, resp := client.SubmitTaskStateChangeRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/SubmitTaskStateChange

SubmitTaskStateChangeWithContext

func (c *ECS) SubmitTaskStateChangeWithContext(ctx aws.Context, input *SubmitTaskStateChangeInput, opts ...request.Option) (*SubmitTaskStateChangeOutput, error)

SubmitTaskStateChangeWithContext is the same as SubmitTaskStateChange with the addition of the ability to pass a context and additional request options.

See SubmitTaskStateChange for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

TagResource

func (c *ECS) TagResource(input *TagResourceInput) (*TagResourceOutput, error)

TagResource API operation for Amazon EC2 Container Service.

Associates the specified tags to a resource with the specified resourceArn. If existing tags on a resource are not specified in the request parameters, they are not changed. When a resource is deleted, the tags associated with that resource are deleted as well.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation TagResource for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeResourceNotFoundException "ResourceNotFoundException" The specified resource could not be found.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/TagResource

Example

ECS TagResource shared00

To tag a cluster.

This example tags the 'dev' cluster with key 'team' and value 'dev'.

{ svc := ecs.New(session.New()) input := &ecs.TagResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), Tags: []*ecs.Tag{ { Key: aws.String("team"), Value: aws.String("dev"), }, }, } result, err := svc.TagResource(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeResourceNotFoundException: fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

TagResourceRequest

func (c *ECS) TagResourceRequest(input *TagResourceInput) (req *request.Request, output *TagResourceOutput)

TagResourceRequest generates a "aws/request.Request" representing the client's request for the TagResource operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See TagResource for more information on using the TagResource API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the TagResourceRequest method. req, resp := client.TagResourceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/TagResource

TagResourceWithContext

func (c *ECS) TagResourceWithContext(ctx aws.Context, input *TagResourceInput, opts ...request.Option) (*TagResourceOutput, error)

TagResourceWithContext is the same as TagResource with the addition of the ability to pass a context and additional request options.

See TagResource for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

UntagResource

func (c *ECS) UntagResource(input *UntagResourceInput) (*UntagResourceOutput, error)

UntagResource API operation for Amazon EC2 Container Service.

Deletes specified tags from a resource.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation UntagResource for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeResourceNotFoundException "ResourceNotFoundException" The specified resource could not be found.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UntagResource

Example

ECS UntagResource shared00

To untag a cluster.

This example deletes the 'team' tag from the 'dev' cluster.

{ svc := ecs.New(session.New()) input := &ecs.UntagResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), TagKeys: []*string{ aws.String("team"), }, } result, err := svc.UntagResource(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeResourceNotFoundException: fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

UntagResourceRequest

func (c *ECS) UntagResourceRequest(input *UntagResourceInput) (req *request.Request, output *UntagResourceOutput)

UntagResourceRequest generates a "aws/request.Request" representing the client's request for the UntagResource operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See UntagResource for more information on using the UntagResource API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the UntagResourceRequest method. req, resp := client.UntagResourceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UntagResource

UntagResourceWithContext

func (c *ECS) UntagResourceWithContext(ctx aws.Context, input *UntagResourceInput, opts ...request.Option) (*UntagResourceOutput, error)

UntagResourceWithContext is the same as UntagResource with the addition of the ability to pass a context and additional request options.

See UntagResource for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

UpdateContainerAgent

func (c *ECS) UpdateContainerAgent(input *UpdateContainerAgentInput) (*UpdateContainerAgentOutput, error)

UpdateContainerAgent API operation for Amazon EC2 Container Service.

Updates the Amazon ECS container agent on a specified container instance. Updating the Amazon ECS container agent does not interrupt running tasks or services on the container instance. The process for updating the agent differs depending on whether your container instance was launched with the Amazon ECS-optimized AMI or another operating system.

UpdateContainerAgent requires the Amazon ECS-optimized AMI or Amazon Linux with the ecs-init service installed and running. For help updating the Amazon ECS container agent on other operating systems, see Manually Updating the Amazon ECS Container Agent (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-update.html#manually_update_agent) in the Amazon Elastic Container Service Developer Guide.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation UpdateContainerAgent for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeUpdateInProgressException "UpdateInProgressException" There is already a current Amazon ECS container agent update in progress on the specified container instance. If the container agent becomes disconnected while it is in a transitional stage, such as PENDING or STAGING, the update process can get stuck in that state. However, when the agent reconnects, it resumes where it stopped previously.

  • ErrCodeNoUpdateAvailableException "NoUpdateAvailableException" There is no update available for this Amazon ECS container agent. This could be because the agent is already running the latest version, or it is so old that there is no update path to the current version.

  • ErrCodeMissingVersionException "MissingVersionException" Amazon ECS is unable to determine the current version of the Amazon ECS container agent on the container instance and does not have enough information to proceed with an update. This could be because the agent running on the container instance is an older or custom version that does not use our version information.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateContainerAgent

UpdateContainerAgentRequest

func (c *ECS) UpdateContainerAgentRequest(input *UpdateContainerAgentInput) (req *request.Request, output *UpdateContainerAgentOutput)

UpdateContainerAgentRequest generates a "aws/request.Request" representing the client's request for the UpdateContainerAgent operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See UpdateContainerAgent for more information on using the UpdateContainerAgent API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the UpdateContainerAgentRequest method. req, resp := client.UpdateContainerAgentRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateContainerAgent

UpdateContainerAgentWithContext

func (c *ECS) UpdateContainerAgentWithContext(ctx aws.Context, input *UpdateContainerAgentInput, opts ...request.Option) (*UpdateContainerAgentOutput, error)

UpdateContainerAgentWithContext is the same as UpdateContainerAgent with the addition of the ability to pass a context and additional request options.

See UpdateContainerAgent for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

UpdateContainerInstancesState

func (c *ECS) UpdateContainerInstancesState(input *UpdateContainerInstancesStateInput) (*UpdateContainerInstancesStateOutput, error)

UpdateContainerInstancesState API operation for Amazon EC2 Container Service.

Modifies the status of an Amazon ECS container instance.

You can change the status of a container instance to DRAINING to manually remove an instance from a cluster, for example to perform system updates, update the Docker daemon, or scale down the cluster size.

When you set a container instance to DRAINING, Amazon ECS prevents new tasks from being scheduled for placement on the container instance and replacement service tasks are started on other container instances in the cluster if the resources are available. Service tasks on the container instance that are in the PENDING state are stopped immediately.

Service tasks on the container instance that are in the RUNNING state are stopped and replaced according to the service's deployment configuration parameters, minimumHealthyPercent and maximumPercent. You can change the deployment configuration of your service using UpdateService.

  • If minimumHealthyPercent is below 100%, the scheduler can ignore desiredCount temporarily during task replacement. For example, desiredCount is four tasks, a minimum of 50% allows the scheduler to stop two existing tasks before starting two new tasks. If the minimum is 100%, the service scheduler can't remove existing tasks until the replacement tasks are considered healthy. Tasks for services that do not use a load balancer are considered healthy if they are in the RUNNING state. Tasks for services that use a load balancer are considered healthy if they are in the RUNNING state and the container instance they are hosted on is reported as healthy by the load balancer.

  • The maximumPercent parameter represents an upper limit on the number of running tasks during task replacement, which enables you to define the replacement batch size. For example, if desiredCount is four tasks, a maximum of 200% starts four new tasks before stopping the four tasks to be drained, provided that the cluster resources required to do this are available. If the maximum is 100%, then replacement tasks can't start until the draining tasks have stopped.

Any PENDING or RUNNING tasks that do not belong to a service are not affected. You must wait for them to finish or stop them manually.

A container instance has completed draining when it has no more RUNNING tasks. You can verify this using ListTasks.

When you set a container instance to ACTIVE, the Amazon ECS scheduler can begin scheduling tasks on the instance again.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation UpdateContainerInstancesState for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateContainerInstancesState

UpdateContainerInstancesStateRequest

func (c *ECS) UpdateContainerInstancesStateRequest(input *UpdateContainerInstancesStateInput) (req *request.Request, output *UpdateContainerInstancesStateOutput)

UpdateContainerInstancesStateRequest generates a "aws/request.Request" representing the client's request for the UpdateContainerInstancesState operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See UpdateContainerInstancesState for more information on using the UpdateContainerInstancesState API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the UpdateContainerInstancesStateRequest method. req, resp := client.UpdateContainerInstancesStateRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateContainerInstancesState

UpdateContainerInstancesStateWithContext

func (c *ECS) UpdateContainerInstancesStateWithContext(ctx aws.Context, input *UpdateContainerInstancesStateInput, opts ...request.Option) (*UpdateContainerInstancesStateOutput, error)

UpdateContainerInstancesStateWithContext is the same as UpdateContainerInstancesState with the addition of the ability to pass a context and additional request options.

See UpdateContainerInstancesState for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

UpdateService

func (c *ECS) UpdateService(input *UpdateServiceInput) (*UpdateServiceOutput, error)

UpdateService API operation for Amazon EC2 Container Service.

Modifies the parameters of a service.

For services using the rolling update (ECS) deployment controller, the desired count, deployment configuration, network configuration, or task definition used can be updated.

For services using the blue/green (CODE_DEPLOY) deployment controller, only the desired count, deployment configuration, and health check grace period can be updated using this API. If the network configuration, platform version, or task definition need to be updated, a new AWS CodeDeploy deployment should be created. For more information, see CreateDeployment (https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html) in the AWS CodeDeploy API Reference.

You can add to or subtract from the number of instantiations of a task definition in a service by specifying the cluster that the service is running in and a new desiredCount parameter.

If you have updated the Docker image of your application, you can create a new task definition with that image and deploy it to your service. The service scheduler uses the minimum healthy percent and maximum percent parameters (in the service's deployment configuration) to determine the deployment strategy.

If your updated Docker image uses the same tag as what is in the existing task definition for your service (for example, my_image:latest), you do not need to create a new revision of your task definition. You can update the service using the forceNewDeployment option. The new tasks launched by the deployment pull the current image/tag combination from your repository when they start.

You can also update the deployment configuration of a service. When a deployment is triggered by updating the task definition of a service, the service scheduler uses the deployment configuration parameters, minimumHealthyPercent and maximumPercent, to determine the deployment strategy.

  • If minimumHealthyPercent is below 100%, the scheduler can ignore desiredCount temporarily during a deployment. For example, if desiredCount is four tasks, a minimum of 50% allows the scheduler to stop two existing tasks before starting two new tasks. Tasks for services that do not use a load balancer are considered healthy if they are in the RUNNING state. Tasks for services that use a load balancer are considered healthy if they are in the RUNNING state and the container instance they are hosted on is reported as healthy by the load balancer.

  • The maximumPercent parameter represents an upper limit on the number of running tasks during a deployment, which enables you to define the deployment batch size. For example, if desiredCount is four tasks, a maximum of 200% starts four new tasks before stopping the four older tasks (provided that the cluster resources required to do this are available).

When UpdateService stops a task during a deployment, the equivalent of docker stop is issued to the containers running in the task. This results in a SIGTERM and a 30-second timeout, after which SIGKILL is sent and the containers are forcibly stopped. If the container handles the SIGTERM gracefully and exits within 30 seconds from receiving it, no SIGKILL is sent.

When the service scheduler launches new tasks, it determines task placement in your cluster with the following logic:

  • Determine which of the container instances in your cluster can support your service's task definition (for example, they have the required CPU, memory, ports, and container instance attributes).

  • By default, the service scheduler attempts to balance tasks across Availability Zones in this manner (although you can choose a different placement strategy):

Sort the valid container instances by the fewest number of running tasks

for this service in the same Availability Zone as the instance. For example, if zone A has one running service task and zones B and C each have zero, valid container instances in either zone B or C are considered optimal for placement.

Place the new service task on a valid container instance in an optimal Availability

Zone (based on the previous steps), favoring container instances with the fewest number of running tasks for this service.

When the service scheduler stops running tasks, it attempts to maintain balance across the Availability Zones in your cluster using the following logic:

  • Sort the container instances by the largest number of running tasks for this service in the same Availability Zone as the instance. For example, if zone A has one running service task and zones B and C each have two, container instances in either zone B or C are considered optimal for termination.

  • Stop the task on a container instance in an optimal Availability Zone

(based on the previous steps), favoring container instances with the largest number of running tasks for this service.

Returns awserr.Error for service API and SDK errors. Use runtime type assertions with awserr.Error's Code and Message methods to get detailed information about the error.

See the AWS API reference guide for Amazon EC2 Container Service's API operation UpdateService for usage and error information.

Returned Error Codes:

  • ErrCodeServerException "ServerException" These errors are usually caused by a server issue.

  • ErrCodeClientException "ClientException" These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an identifier that is not valid.

  • ErrCodeInvalidParameterException "InvalidParameterException" The specified parameter is invalid. Review the available parameters for the API request.

  • ErrCodeClusterNotFoundException "ClusterNotFoundException" The specified cluster could not be found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region-specific.

  • ErrCodeServiceNotFoundException "ServiceNotFoundException" The specified service could not be found. You can view your available services with ListServices. Amazon ECS services are cluster-specific and Region-specific.

  • ErrCodeServiceNotActiveException "ServiceNotActiveException" The specified service is not active. You can't update a service that is inactive. If you have previously deleted a service, you can re-create it with CreateService.

  • ErrCodePlatformUnknownException "PlatformUnknownException" The specified platform version does not exist.

  • ErrCodePlatformTaskDefinitionIncompatibilityException "PlatformTaskDefinitionIncompatibilityException" The specified platform version does not satisfy the task definition's required capabilities.

  • ErrCodeAccessDeniedException "AccessDeniedException" You do not have authorization to perform the requested action.

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateService

Examples

ECS UpdateService shared00

To change the task definition used in a service

This example updates the my-http-service service to use the amazon-ecs-sample task definition.

{ svc := ecs.New(session.New()) input := &ecs.UpdateServiceInput{ Service: aws.String("my-http-service"), TaskDefinition: aws.String("amazon-ecs-sample"), } result, err := svc.UpdateService(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotActiveException: fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }
ECS UpdateService shared01

To change the number of tasks in a service

This example updates the desired count of the my-http-service service to 10.

{ svc := ecs.New(session.New()) input := &ecs.UpdateServiceInput{ DesiredCount: aws.Int64(10), Service: aws.String("my-http-service"), } result, err := svc.UpdateService(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeClientException: fmt.Println(ecs.ErrCodeClientException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotActiveException: fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { fmt.Println(err.Error()) } return } fmt.Println(result) }

UpdateServiceRequest

func (c *ECS) UpdateServiceRequest(input *UpdateServiceInput) (req *request.Request, output *UpdateServiceOutput)

UpdateServiceRequest generates a "aws/request.Request" representing the client's request for the UpdateService operation. The "output" return value will be populated with the request's response once the request completes successfully.

Use "Send" method on the returned Request to send the API call to the service. the "output" return value is not valid until after Send returns without error.

See UpdateService for more information on using the UpdateService API call, and error handling.

This method is useful when you want to inject custom logic or configuration into the SDK's request lifecycle. Such as custom headers, or retry logic.

// Example sending a request using the UpdateServiceRequest method. req, resp := client.UpdateServiceRequest(params) err := req.Send() if err == nil { // resp is now filled fmt.Println(resp) }

See also, https://docs.aws.amazon.com/goto/WebAPI/ecs-2014-11-13/UpdateService

UpdateServiceWithContext

func (c *ECS) UpdateServiceWithContext(ctx aws.Context, input *UpdateServiceInput, opts ...request.Option) (*UpdateServiceOutput, error)

UpdateServiceWithContext is the same as UpdateService with the addition of the ability to pass a context and additional request options.

See UpdateService for details on how to use this API operation.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

See Also

For more information about using this API, see AWS API Documentation.

WaitUntilServicesInactive

func (c *ECS) WaitUntilServicesInactive(input *DescribeServicesInput) error

WaitUntilServicesInactive uses the Amazon ECS API operation DescribeServices to wait for a condition to be met before returning. If the condition is not met within the max attempt window, an error will be returned.

WaitUntilServicesInactiveWithContext

func (c *ECS) WaitUntilServicesInactiveWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error

WaitUntilServicesInactiveWithContext is an extended version of WaitUntilServicesInactive. With the support for passing in a context and options to configure the Waiter and the underlying request options.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

WaitUntilServicesStable

func (c *ECS) WaitUntilServicesStable(input *DescribeServicesInput) error

WaitUntilServicesStable uses the Amazon ECS API operation DescribeServices to wait for a condition to be met before returning. If the condition is not met within the max attempt window, an error will be returned.

WaitUntilServicesStableWithContext

func (c *ECS) WaitUntilServicesStableWithContext(ctx aws.Context, input *DescribeServicesInput, opts ...request.WaiterOption) error

WaitUntilServicesStableWithContext is an extended version of WaitUntilServicesStable. With the support for passing in a context and options to configure the Waiter and the underlying request options.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

WaitUntilTasksRunning

func (c *ECS) WaitUntilTasksRunning(input *DescribeTasksInput) error

WaitUntilTasksRunning uses the Amazon ECS API operation DescribeTasks to wait for a condition to be met before returning. If the condition is not met within the max attempt window, an error will be returned.

WaitUntilTasksRunningWithContext

func (c *ECS) WaitUntilTasksRunningWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error

WaitUntilTasksRunningWithContext is an extended version of WaitUntilTasksRunning. With the support for passing in a context and options to configure the Waiter and the underlying request options.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

WaitUntilTasksStopped

func (c *ECS) WaitUntilTasksStopped(input *DescribeTasksInput) error

WaitUntilTasksStopped uses the Amazon ECS API operation DescribeTasks to wait for a condition to be met before returning. If the condition is not met within the max attempt window, an error will be returned.

WaitUntilTasksStoppedWithContext

func (c *ECS) WaitUntilTasksStoppedWithContext(ctx aws.Context, input *DescribeTasksInput, opts ...request.WaiterOption) error

WaitUntilTasksStoppedWithContext is an extended version of WaitUntilTasksStopped. With the support for passing in a context and options to configure the Waiter and the underlying request options.

The context must be non-nil and will be used for request cancellation. If the context is nil a panic will occur. In the future the SDK may create sub-contexts for http.Requests. See https://golang.org/pkg/context/ for more information on using Contexts.

On this page: