Skip to main content

ECS instance stop

ECS instance stop induces stress on an AWS ECS cluster. It derives the instance under chaos from the ECS cluster.

  • It causes EC2 instance to stop and get deleted from the ECS cluster for a specific duration.
  • This experiment induces chaos within a container and depends on an EC2 instance. Typically, these are prefixed with "ECS container" and involve direct interaction with the EC2 instances hosting the ECS containers.

ECS Instance Stop

Use cases

EC2 instance stop breaks the agent that manages the task container on ECS cluster, thereby impacting its delivery. Killing the EC2 instance disrupts the performance of the task container.


  • Kubernetes >= 1.17
  • The ECS container instance should be in a healthy state.
  • Adequate AWS access to stop and start an EC2 instance.
  • Create a Kubernetes secret that has the AWS access configuration(key) in the CHAOS_NAMESPACE. Below is a sample secret file:
apiVersion: v1
kind: Secret
name: cloud-secret
type: Opaque
cloud_config.yml: |-
# Add the cloud AWS credentials respectively
aws_access_key_id = XXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXX

HCE recommends that you use the same secret name, that is, cloud-secret. Otherwise, you will need to update the AWS_SHARED_CREDENTIALS_FILE environment variable in the fault template with the new secret name and you won't be able to use the default health check probes.

Below is an example AWS policy to execute the fault.

"Version": "2012-10-17",
"Statement": [
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [

"Resource": "*"
"Effect": "Allow",
"Action": [
"Resource": "*"
"Effect": "Allow",
"Action": [
"Resource": "*"

Mandatory tunables

Tunable Description Notes
CLUSTER_NAME Name of the target ECS cluster For example, cluster-1
REGION The region name of the target ECS cluster For example, us-east-1

Optional tunables

Tunable Description Notes
TOTAL_CHAOS_DURATION Duration that you specify, through which chaos is injected into the target resource (in seconds). Default: 30s. For more information, go to duration of the chaos.
CHAOS_INTERVAL The interval (in sec) between successive instance termination. Default: 30s. For more information, go to chaos interval.
AWS_SHARED_CREDENTIALS_FILE Provide the path for aws secret credentials Defaults to /tmp/cloud_config.yml
EC2_INSTANCE_ID Provide the target instance ID from ECS cluster If not provided will select randomly
SEQUENCE It defines sequence of chaos execution for multiple instance Default value: parallel. Supports serial and parallel. For more information, go to sequence of chaos execution. Defaults to parallel. Supports serial sequence as well.
RAMP_TIME Period to wait before and after injecting chaos (in seconds). For example, 30 s. For more information, go to ramp time.

ECS instance stop

ECS cluster instance that is to be stopped for a chaos duration. Tune it by using EC2_INSTANCE_ID environment variable. If not provided, it is selected at random.

The following YAML snippet illustrates the use of this environment variable:

# stops the agent of an ECS cluster
kind: ChaosEngine
name: engine-nginx
engineState: "active"
annotationCheck: "false"
chaosServiceAccount: litmus-admin
- name: ecs-instance-stop
# provide the name of ECS cluster
value: 'demo'
value: 'us-east-2'
VALUE: '60'