Using Amazon ECS dual-stack endpoints - Amazon Elastic Container Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using Amazon ECS dual-stack endpoints

Amazon ECS dual-stack endpoints support requests to Amazon ECS over Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6). For a list of all Amazon ECS endpoints, see Amazon ECS endpoints and quotas in the Amazon Web Services General Reference.

When using the REST API, you directly access an Amazon ECS endpoint by using the endpoint name (URI). Amazon ECS supports only regional dual-stack endpoint names, which means that you must specify the region as part of the name.

Use the following naming convention for the dual-stack endpoint names: ecs.region.api.aws.

When using the Amazon Command Line Interface (Amazon CLI) and Amazon SDKs, you can use a parameter or a flag to change to a dual-stack endpoint. You can also specify the dual-stack endpoint directly as an override of the Amazon ECS endpoint in the config file.

The following sections describe how to use dual-stack endpoints from the Amazon CLI, the Amazon SDKs, and the REST API.

Using dual-stack endpoints from the Amazon CLI

This section provides examples of Amazon CLI commands used to make requests to a dual-stack endpoint. For more information about installing the Amazon CLI or updating to the latest version, see Installing or updating to the latest version of the Amazon CLI in the Amazon Command Line Interface User Guide for Version 2.

To use a dual-stack endpoint, you can set the configuration value use_dualstack_endpoint to true in the config file for the Amazon CLI to direct all Amazon ECS requests made by the ecs Amazon CLI command to the dual-stack endpoint for the specified region. You can specify the region in the config file or in a command by using the --region option. For more information about configuration files for the Amazon CLI, see Configuration and credential file settings in the Amazon CLI in the Amazon Command Line Interface User Guide for Version 2.

You can also use a command to update configuration. The following command updates use_dualstack_endpoint to true in the default profile.

$ aws configure set default.ecs.use_dualstack_endpoint true

If you want to use a dual-stack endpoint for specific Amazon CLI commands, you can use either of the following methods:

  • You can use the dual-stack endpoint per command by setting the --endpoint-url parameter to https://ecs.aws-region.api.aws or http://ecs.aws-region.api.aws for any ecs command.

    The following example command lists all available clusters and uses the dual-stack endpoint for the request.

    $ aws ecs list-clusters --endpoint-url https://ecs.aws-region.api.aws
  • You can set up separate profiles in your Amazon Config file. For example, create one profile that sets use_dualstack_endpoint to true and a profile that does not set use_dualstack_endpoint. When you run a command, specify which profile you want to use, depending upon whether or not you want to use the dual-stack endpoint.

Using dual-stack endpoints from the Amazon SDKs

This section provides examples of how to access a dual-stack endpoint by using the Amazon SDKs.

Amazon SDK for Java 2.x

The following example shows how to specify a dual-stack endpoint for the us-east-1 Region using the Amazon SDK for Java 2.x.

Region region = Region.US_EAST_1 EcsClient client = EcsClient.builder().region(region).dualstackEnabled(true).build();
Amazon SDK for Go

The following example shows how to specify a dual-stack endpoint for the us-east-1 Region using the Amazon SDK for Go.

sess := session.Must(session.NewSession()) svc := ecs.New(sess, &aws.Config{ Region: aws.String(endpoints.UsEast1RegionID), Endpoint: aws.String("https://ecs.us-east-1.api.aws") })

For more information, see Dual-stack and FIPS endpoints in the Amazon SDKs and Tools Reference Guide.

Using dual-stack endpoints from the REST API

When using the REST API, you can directly access a dual-stack endpoint by specifying it in your request. The following example uses the dual-stack endpoint to list all Amazon ECS clusters in the us-east-1 Region.

POST / HTTP/1.1 Host: ecs.us-east-1.api.aws Accept-Encoding: identity Content-Length: 2 X-Amz-Target: AmazonEC2ContainerServiceV20141113.ListClusters X-Amz-Date: 20150429T170621Z Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS {}