Docs Home
Start your 30 day free trial.
START FOR FREE

Installing Gremlin on Amazon ECS

Gremlin supports Amazon Elastic Container Service (ECS) using our container agent. This document will walk you through deploying the Gremlin container to your ECS deployment.

The agent only works on EC2-backed ECS. For Fargate-backed ECS, please use Failure Flags.

To get the most from this installation guide, you should also be familiar with installing Gremlin as a container. You can reference Installing Gremlin in a Docker Container for help.

‍

Step 1: Create the task definition

This task definition runs the Gremlin agent as a daemon container on each EC2 instance in your cluster. ECS reads your team ID, certificate and private key from AWS Secrets Manager and passes them to the agent as environment variables.

‍

Store your Gremlin credentials in Secrets Manager

  1. In the Gremlin web app, open Team Settings and select Details. Copy your Team ID.
  2. On the Certificates line, click Download (see Download a certificate pair). Unzip the file. The certificate is named <team-name>-client.pub_cert.pem and the private key is <team-name>-client.priv_key.pem.
  3. Create a Secrets Manager secret with three keys: team_id, team_certificate and team_private_key. The certificate and key values must hold the full PEM text, including the BEGIN and END lines and the line breaks between them. The commands below build the secret from your files and keep the line breaks intact. They require the AWS CLI and jq 1.6 or later. Set GREMLIN_TEAM_NAME to the name of your Gremlin team.

Copy the ARN value from the command's output. It ends with a six-character suffix that AWS adds to the secret name, such as gremlin/ecs-agent-AbCdEf. You'll need the full ARN in the next step.

‍

Fill in the task definition

Copy the JSON task definition below into a text editor. Replace each placeholder, including its leading $, using the table that follows it.

Placeholder Description
$YOUR_IDENTIFIER A suffix for the task definition family name, which becomes gremlin-<value>. Use letters, numbers, hyphens and underscores, for example prod-cluster. You'll select this family in Step 2.
$YOUR_TASK_EXECUTION_ROLE The ARN of the IAM task execution role ECS uses to pull the image, read your secret and send logs to CloudWatch. Attach the AmazonECSTaskExecutionRolePolicy managed policy, plus secretsmanager:GetSecretValue on your Gremlin secret (example below). If you encrypted the secret with a customer managed KMS key, also allow kms:Decrypt on that key.
$YOUR_AGENT_VERSION The tag of the gremlin/gremlin image on Docker Hub. Use latest, or a specific version from the Linux agent release notes to keep every host on the same release.
$YOUR_ADDITIONAL_TAGS Extra tags for targeting experiments, as comma-separated key=value pairs, for example env=prod,team=payments. Keep platform=ecs; you'll use it to find these agents in the web app. If you don't need extra tags, delete ,$YOUR_ADDITIONAL_TAGS so the value reads platform=ecs.
$YOUR_SECRET_ARN The full ARN from the previous section, for example arn:aws:secretsmanager:us-east-1:123456789012:secret:gremlin/ecs-agent-AbCdEf. Replace it in all three secrets entries. Leave the :team_id::, :team_certificate:: and :team_private_key:: endings in place, since they tell ECS which key to read.
$YOUR_LOG_GROUP_NAME The name of the CloudWatch Logs log group for the agent's logs, for example /ecs/gremlin. Create the log group before you deploy; this task definition doesn't create it.
$YOUR_REGION The AWS Region of that log group, for example us-east-1.
$YOUR_CLUSTER A prefix for the agent's log stream names. Use your cluster name so you can tell agents in different clusters apart. ECS names each stream <prefix>/gremlin/<task-id>.
$YOUR_CPU_ARCHITECTURE X86_64 or ARM64, to match the instance types in your cluster.

To let the execution role read your secret, add this inline policy to it:

To use a team secret instead of a certificate, store a team_secret key in the secret. Then replace the two certificate entries in secrets with one entry named GREMLIN_TEAM_SECRET whose valueFrom ends in :team_secret::.

  1. Review the memoryReservation value against your instance sizes.
  2. In the AWS Management Console, navigate to Task Definitions and choose Create new task definition with JSON.
  3. Paste your edited task definition into the JSON field, then click Create.

‍

Step 2: Create the daemon service definition

  1. In the AWS Management Console, navigate to Clusters in ECS.
  2. Select the cluster you want to deploy Gremlin to.
  3. On the Services tab, click Create.

On the Configure Services page, set the parameters as follows:

  1. Select the Launch Type compute option.
  2. Select the EC2 launch type.
  3. Select the Service application type.
  4. Set Task Definition → Family to the family you created in Step 1 (gremlin-<your identifier>).
  5. Set Task Definition → Revision to “latest”.
  6. Set Service Type to DAEMON.
  7. Click Create to create the service.

‍

Verifying the installation

To verify that Gremlin is properly installed and running:

  1. In the AWS management Console, navigate to Clusters.
  2. Select the cluster you just deployed Gremlin into.
  3. On the Services tab, you should now see the Gremlin service.
  4. Verify that Desired tasks matches the number of ECS hosts in your cluster
  5. Verify that Running tasks matches the number of Desired tasks. Note that it can take several minutes for the ECS scheduler to launch Gremlin to full capacity.
  6. Once the Gremlin service is running at full capacity, navigate to https://app.gremlin.com/configurations/agents. You can search via the tag platform=ecs to verify that the Gremlin control plane can see the freshly launched ECS daemons.
  7. Navigate to https://app.gremlin.com/attacks/new and click Containers.
  8. Verify that you are seeing the application containers and tags currently running on your ECS cluster.

Once your ECS agents show as Active, run your first experiment against them. See How to run an experiment.

‍

Additional ECS configuration options

There are some advanced options that change how Gremlin interacts with ECS:

  • networkMode: This option determines which network space we would like to affect. For example, setting it to awsvpc means the task can only affect the awsvpc interface. Some other options are: host, bridge, or none. By default, this value is set to host. For more information, please consult the AWS guide on network mode.
  • pidMode: This parameter allows you to configure the container to share their process ID with either the host or other containers in the task. It may prove useful when performing process killer attacks to set this parameter to host. By default, this value is set to host. For more information, please consult the AWS guide on PID mode.
On this page
Back to top
RELATED PAGES