EC2 stop by tag
Stop EC2 instances selected by tag for a configurable duration so you can test how the workload running on those instances behaves when a tagged subset disappears.
EC2 stop by tag is an AWS chaos fault that resolves EC2 instances by tag, stops a configurable percentage of them for a configurable duration, and then starts them again. The fault is useful when you want to act on a logical group of instances (an environment, a service, a role) without pinning to specific instance IDs.
Use this fault to test how a workload behaves when a tagged subset of its capacity disappears: replicas served by other instances pick up the load, an auto-scaling group provisions replacements, or a tier behind a load balancer is taken out of rotation.
Use cases
Run this fault when you want to answer concrete questions like:
Replica failover for a tagged tier: When a percentage of instances tagged for a specific service are stopped, do remaining replicas absorb the traffic without dropping requests?
Load balancer health checks: Does the target group detach stopped instances quickly and reattach them cleanly when they return?
Auto-scaling group response: Do ASGs provision replacements within the expected window?
Managed node group resilience (EKS): When tagged worker nodes are stopped, are pods rescheduled across the cluster and does capacity recover?
Blast-radius validation: Confirm that targeting by tag plus
INSTANCE_AFFECTED_PERCENTAGEkeeps the impact within the planned blast radius.
Prerequisites
Kubernetes version: 1.21 or later for the chaos infrastructure cluster.
Target instances exist and are reachable: At least one instance in
REGIONcarries the tag inEC2_INSTANCE_TAGand is in therunningstate at the start of the experiment.AWS credentials available: Either an AWS credentials file uploaded as a File Secret in Harness Secret Manager (see Authentication below) or an IAM role for service accounts (IRSA) bound to the chaos infrastructure service account.
IAM permissions granted: The credentials or role include the permissions listed below.
ASG awareness (only when targeting nodes in a managed node group): If targets are EKS managed node group instances, set
MANAGED_NODEGROUP=enableso the fault waits for replacement nodes instead of attempting to start the originals.
Supported environments
Amazon EC2 (standalone instances)
Supported
Amazon EKS managed worker nodes
Supported (set MANAGED_NODEGROUP=enable)
Amazon EKS self-managed worker nodes
Supported
AWS regions
Supported in every commercial region; pass the region in REGION
Linux instances
Supported
Windows instances
Supported
Spot instances
Supported (the start call may fail if capacity is unavailable; see Limitations)
Instances behind ALB, NLB, or CLB
Supported
Permissions required
The IAM principal that the chaos pod uses needs the following AWS actions.
ec2:StopInstancesandec2:StartInstancesdrive the fault.ec2:DescribeInstancesis used to resolveEC2_INSTANCE_TAGto a list of instance IDs and to confirm state transitions.ec2:DescribeInstanceStatusconfirms each instance reachesstoppedandrunningstates.autoscaling:DescribeAutoScalingInstancesis only required whenMANAGED_NODEGROUP=enable.
Go to common policy for all AWS faults to use a single superset IAM policy across every AWS fault.
Authentication
The fault supports three credential delivery models. Pick one based on how your chaos infrastructure is deployed.
Harness Secret Manager file secret
Chaos infrastructure runs outside EKS, or you want explicit static credentials
Upload the AWS credentials file as a File Secret in Harness Secret Manager and reference its identifier via AWS_AUTHENTICATION_SECRET
IAM Roles for Service Accounts (IRSA)
Chaos infrastructure runs in EKS and uses an OIDC-bound service account
No tunable changes; the chaos pod inherits the role automatically. Go to AWS IAM integration to set it up
Assume role
The fault needs to act in a different account or with elevated permissions
Set ASSUME_ROLE_ARN to the role ARN; the chaos pod assumes the role on top of its base credentials
When using the Harness Secret Manager method, the File Secret should contain an AWS credentials file in the standard ~/.aws/credentials format:
Upload this file as a File Secret in Harness Secret Manager (Project Setup → Secrets → New File Secret), and pass the secret identifier in AWS_AUTHENTICATION_SECRET.
Fault tunables
Configure the following fault parameters when you add EC2 stop by tag to an experiment in Chaos Studio. Defaults are shown for reference.
Required parameters
EC2_INSTANCE_TAG
Tag selector in key:value format (for example app:frontend).
(required)
REGION
AWS region that hosts the target instances (for example us-east-1).
(required)
INSTANCE_AFFECTED_PERCENTAGE
Percentage of matching instances to stop. 0 targets exactly one instance.
0
Chaos parameters
TOTAL_CHAOS_DURATION
Duration of the fault in seconds.
60
CHAOS_INTERVAL
Delay in seconds between successive stop iterations.
60
SEQUENCE
Order in which selected instances are stopped: parallel stops them at once; serial stops them one at a time.
parallel
MANAGED_NODEGROUP
Set to enable when targets are EKS managed node group instances; the fault then waits for replacement nodes from the ASG.
disable
RAMP_TIME
Wait period in seconds before and after the fault. Go to ramp time to read how it is applied.
0
Authentication
ASSUME_ROLE_ARN
ARN of an IAM role to assume on top of the base credentials.
""
AWS_AUTHENTICATION_SECRET
Identifier of the File Secret in Harness Secret Manager that contains the AWS credentials file. Not required when using IRSA.
""
Tunables that apply to every fault are documented in common tunables for all faults. AWS-specific shared tunables are documented in common AWS fault tunables.
DRAIN MANAGED NODE GROUP INSTANCES BEFORE THE FAULT
If targets are part of a managed node group, drain and cordon them before running the fault so that workload pods are not scheduled onto instances about to disappear.
Fault execution in brief
Resolves the tag in EC2_INSTANCE_TAG to a list of instance IDs in REGION, calls StopInstances on the chosen percentage (INSTANCE_AFFECTED_PERCENTAGE), waits for TOTAL_CHAOS_DURATION seconds, then calls StartInstances to bring them back (unless MANAGED_NODEGROUP=enable).
Expected behavior during fault execution
Each selected instance transitions from
runningtostoppingtostoppedwithin seconds of the stop call.Instances behind a load balancer are marked unhealthy and removed from rotation according to target-group health-check settings.
Workloads on stopped instances become unreachable; replicas elsewhere should absorb the traffic if the workload is horizontally scaled.
For EKS worker nodes, pods enter
TerminatingthenPending; the scheduler places them on other nodes if capacity allows.When
MANAGED_NODEGROUP=enable, the ASG launches replacement nodes and the fault waits for them to join the cluster before reporting success.
Signals to watch
Attach resilience probes to assert each layer:
Application availability: Use an HTTP probe to detect downtime and measure recovery time.
Target group health: Use a Prometheus probe on
aws_applicationelb_healthy_host_countto confirm the load balancer detected the outage.EC2 instance state: Use a command probe running
aws ec2 describe-instances --filters "Name=tag:<key>,Values=<value>"to assert the expected state.CloudWatch metrics: Use a Prometheus probe on
aws_ec2_status_check_failedto confirm instances went down and came back.
Verify the fault execution effect
While the experiment is running, confirm the tagged instances are stopped and then restored:
List instances by tag.
The expected fraction of instances should report
stoppingorstoppedduring the fault, thenrunningafter recovery.Check load balancer target health (if applicable).
For EKS managed node groups, confirm replacements joined.
Recovery and cleanup
End of duration: The chaos pod issues
StartInstancesfor affected instances (unlessMANAGED_NODEGROUP=enable) and polls until each reachesrunning.Abort the experiment: Stopping the experiment from Chaos Studio triggers the same start call.
Manual recovery: If the fault exits with an error before issuing the start call, start affected instances manually with
aws ec2 start-instances --instance-ids <ids>.
Limitations
Tag must resolve to at least one instance: If
EC2_INSTANCE_TAGmatches nothing inREGION, the fault fails fast with no impact.Spot instance start failures: Start calls may fail with
InsufficientInstanceCapacity; recover via your autoscaling configuration.Stop protection: Instances with
disableApiStopenabled will reject the stop call.Instance store data loss: EC2 instance-store volumes are destroyed when an instance stops.
Cross-region targeting: One experiment targets one region.
Troubleshooting
Related faults
EC2 stop by ID: Stop EC2 instances selected by instance ID instead of by tag.
EC2 process kill: Kill a specific process inside an EC2 instance without stopping the host.
SSM chaos by tag: Inject CPU, memory, or IO stress inside tagged EC2 instances via AWS Systems Manager.
Common AWS fault tunables: Shared environment variables for AWS faults.
Last updated
Was this helpful?