Using the Amazon ECS command line interface - Amazon Elastic Container Service

Using the Amazon ECS command line interface

Amazon ECS has released AWS Copilot, a command line interface (CLI) tool that simplifies building, releasing, and operating production-ready containerized applications on Amazon ECS from a local development environment. For more information, see Using the AWS Copilot command line interface.

The Amazon Elastic Container Service (Amazon ECS) command line interface (CLI) provides high-level commands to simplify creating, updating, and monitoring clusters and tasks from a local development environment. The Amazon ECS CLI supports Docker Compose files, a popular open-source specification for defining and running multi-container applications. Use the ECS CLI as part of your everyday development and testing cycle as an alternative to the AWS Management Console.

The latest version of the Amazon ECS CLI only supports the major versions of Docker Compose file syntax versions 1, 2, and 3. The version specified in the compose file must be the string "1", "1.0", "2", "2.0", "3", or "3.0". Docker Compose minor versions are not supported.

The source code for the Amazon ECS CLI is available on GitHub. This tool is no longer being actively developed.

Installing the Amazon ECS CLI

Amazon ECS has released AWS Copilot, a command line interface (CLI) tool that simplifies building, releasing, and operating production-ready containerized applications on Amazon ECS from a local development environment. For more information, see Using the AWS Copilot command line interface.

The following steps demonstrate how to install the Amazon ECS CLI on your macOS, Linux, or Windows system.

To install the Amazon ECS CLI
  1. Download the Amazon ECS CLI binary.

    macOS
    sudo curl -Lo /usr/local/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-darwin-amd64-latest
    Linux
    sudo curl -Lo /usr/local/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
    Windows

    Open Windows PowerShell and enter the following commands.

    Note

    If you encounter permission issues, ensure that you have administrator access on Windows and you are running PowerShell as an administrator.

    New-Item -Path 'C:\Program Files\Amazon\ECSCLI' -ItemType Directory Invoke-WebRequest -OutFile 'C:\Program Files\Amazon\ECSCLI\ecs-cli.exe' https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-windows-amd64-latest.exe
  2. Verify the Amazon ECS CLI using PGP signatures. The Amazon ECS CLI executables are cryptographically signed using PGP signatures. The PGP signatures can be used to verify the validity of the Amazon ECS CLI executable. Use the following steps to verify the signatures using the GnuPG tool.

    1. Download and install GnuPG. For more information, see the GnuPG website.

      macOS

      We recommend using Homebrew. Install Homebrew using the instructions from their website. For more information, see Homebrew. After Homebrew is installed, use the following command from your macOS terminal.

      brew install gnupg
      Linux

      Install gpg using the package manager on your flavor of Linux.

      Windows

      Download the Windows simple installer from the GnuPG website and install as an Administrator. After you install GnuPG, close and reopen the Administrator PowerShell.

      For more information, see GnuPG Download.

    2. Verify the GnuPG path is added to your environment path.

      macOS
      echo $PATH

      If you do not see the GnuPG path in the output, run the following command to add it to the path.

      PATH=$PATH:<path to GnuPG executable files>
      Linux
      echo $PATH

      If you do not see the GnuPG path in the output, run the following command to add it to the path.

      export PATH=$PATH:<path to GnuPG executable files>
      Windows
      Write-Output $Env:PATH

      If you do not see the GnuPG path in the output, run the following command to add it to the path.

      $Env:PATH += ";<path to GnuPG executable files>"
    3. Create a local plain text file.

      macOS

      On the terminal, enter:

      touch <public_key_filename.txt>

      Open the file with TextEdit.

      Linux

      Create a text file in a text editor such as gedit. Save as public_key_filename.txt

      Windows

      Create a text file in a text editor such as Notepad. Save as public_key_filename.txt

    4. Add the following contents of the Amazon ECS PGP public key and save the file.

      -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2 mQINBFq1SasBEADliGcT1NVJ1ydfN8DqebYYe9ne3dt6jqKFmKowLmm6LLGJe7HU jGtqhCWRDkN+qPpHqdArRgDZAtn2pXY5fEipHgar4CP8QgRnRMO2fl74lmavr4Vg 7K/KH8VHlq2uRw32/B94XLEgRbGTMdWFdKuxoPCttBQaMj3LGn6Pe+6xVWRkChQu BoQAhjBQ+bEm0kNy0LjNgjNlnL3UMAG56t8E3LANIgGgEnpNsB1UwfWluPoGZoTx N+6pHBJrKIL/1v/ETU4FXpYw2zvhWNahxeNRnoYj3uycHkeliCrw4kj0+skizBgO 2K7oVX8Oc3j5+ZilhL/qDLXmUCb2az5cMM1mOoF8EKX5HaNuq1KfwJxqXE6NNIcO lFTrT7QwD5fM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x5EVVHQ1sYRN8Ny4Fdr2tMAmj2O+X+J qX2yy/UX5nSPU492e2CdZ1UhoU0SRFY3bxKHKB7SDbVeav+K5g== =Gi5D -----END PGP PUBLIC KEY BLOCK-----

      The details of the Amazon ECS PGP public key for reference:

      Key ID: BCE9D9A42D51784F
      Type: RSA
      Size: 4096/4096
      Expires: Never
      User ID: Amazon ECS
      Key fingerprint: F34C 3DDA E729 26B0 79BE AEC6 BCE9 D9A4 2D51 784F

      You may close the text editor.

    5. Import the file with the Amazon ECS PGP public key with the following command in the terminal.

      gpg --import <public_key_filename.txt>
    6. Download the Amazon ECS CLI signatures. The signatures are ASCII detached PGP signatures stored in files with the extension .asc. The signatures file has the same name as its corresponding executable, with .asc appended.

      macOS
      curl -Lo ecs-cli.asc https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-darwin-amd64-latest.asc
      Linux
      curl -Lo ecs-cli.asc https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest.asc
      Windows
      Invoke-WebRequest -OutFile ecs-cli.asc https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-windows-amd64-latest.exe.asc
    7. Verify the signature.

      macOS and Linux
      gpg --verify ecs-cli.asc /usr/local/bin/ecs-cli
      Windows
      gpg --verify ecs-cli.asc 'C:\Program Files\Amazon\ECSCLI\ecs-cli.exe'

      Expected output:

      gpg: Signature made Tue Apr  3 13:29:30 2018 PDT
      gpg:                using RSA key DE3CBD61ADAF8B8E
      gpg: Good signature from "Amazon ECS <ecs-security@amazon.com>" [unknown]
      gpg: WARNING: This key is not certified with a trusted signature!
      gpg:          There is no indication that the signature belongs to the owner.
      Primary key fingerprint: F34C 3DDA E729 26B0 79BE  AEC6 BCE9 D9A4 2D51 784F
           Subkey fingerprint: EB3D F841 E2C9 212A 2BD4  2232 DE3C BD61 ADAF 8B8E
      Important

      The warning in the output is expected and is not problematic. It occurs because there is not a chain of trust between your personal PGP key (if you have one) and the Amazon ECS PGP key. For more information, see Web of trust.

  3. Apply execute permissions to the binary.

    macOS and Linux
    sudo chmod +x /usr/local/bin/ecs-cli
    Windows

    Edit the environment variables and add C:\Program Files\Amazon\ECSCLI to the PATH variable field, separated from existing entries by using a semicolon. For example:

    setx path "%path%;C:\Program Files\Amazon\ECSCLI"

    Restart PowerShell so the changes go into effect.

    Note

    After the PATH variable is set, the Amazon ECS CLI can be used from either Windows PowerShell or the command prompt.

  4. Verify that the CLI is working properly.

    ecs-cli --version

    Proceed to Configuring the Amazon ECS CLI.

    Important

    You must configure the Amazon ECS CLI with your AWS credentials, an AWS Region, and an Amazon ECS cluster name before you can use it. For more information, see Configuring the Amazon ECS CLI.

Configuring the Amazon ECS CLI

Amazon ECS has released AWS Copilot, a command line interface (CLI) tool that simplifies building, releasing, and operating production-ready containerized applications on Amazon ECS from a local development environment. For more information, see Using the AWS Copilot command line interface.

The Amazon ECS CLI requires some basic configuration information before you can use it, such as your AWS credentials, the AWS Region in which to create your cluster, and the name of the Amazon ECS cluster to use. Configuration information is stored in the ~/.ecs directory on macOS and Linux systems and in C:\Users\<username>\AppData\local\ecs on Windows systems.

To configure the Amazon ECS CLI
  1. Set up a CLI profile with the following command, substituting profile_name with your desired profile name, $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY environment variables with your AWS credentials.

    ecs-cli configure profile --profile-name profile_name --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY
  2. Complete the configuration with the following command, substituting launch_type with the task launch type you want to use by default, region_name with your desired AWS Region, cluster_name with the name of an existing Amazon ECS cluster or a new cluster to use, and configuration_name for the name you'd like to give this configuration.

    ecs-cli configure --cluster cluster_name --default-launch-type launch_type --region region_name --config-name configuration_name

Using profiles

The Amazon ECS CLI supports the configuring of multiple sets of AWS credentials as named profiles using the ecs-cli configure profile command. A default profile can be set by using the ecs-cli configure profile default command. These profiles can then be referenced when you run Amazon ECS CLI commands that require credentials using the --ecs-profile flag otherwise the default profile is used.

Using cluster configurations

A cluster configuration is a set of fields that describes an Amazon ECS cluster including the name of the cluster and the region. A default cluster configuration can be set by using the ecs-cli configure default command. The Amazon ECS CLI supports the configuring of multiple named cluster configurations using the --config-name option.

Understanding the order of precedence

There are multiple methods for passing both the credentials and the region in an Amazon ECS CLI command. The following is the order of precedence for each of these.

The order of precedence for credentials is:

  1. Amazon ECS CLI profile flags:

    1. Amazon ECS profile (--ecs-profile)

    2. AWS profile (--aws-profile)

  2. Environment variables:

    1. ECS_PROFILE

    2. AWS_PROFILE

    3. AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN

  3. ECS config‐attempts to fetch credentials from the default ECS profile.

  4. Default AWS profile — Attempts to use credentials (aws_access_key_id, aws_secret_access_key) or assume_role (role_arn, source_profile) from the AWS profile name.

    1. AWS_DEFAULT_PROFILE environment variable (defaults to default).

  5. EC2 instance role

The order of precedence for Region is:

  1. Amazon ECS CLI flags:

    1. Region flag (--region)

    2. Cluster config flag (--cluster-config)

  2. ECS config‐attempts to fetch the Region from the default ECS profile.

  3. Environment variables—Attempts to fetch the region from the following environment variables:

    1. AWS_REGION

    2. AWS_DEFAULT_REGION

  4. AWS profile ‐ attempts to use the region from the AWS profile name:

    1. AWS_PROFILE environment variable

    2. AWS_DEFAULT_PROFILE environment variable (defaults to default)