ECS container volume detach
Detach the data volume attached to a percentage of running ECS tasks for a configurable duration so you can test how the workload behaves when its storage disappears.
ECS container volume detach is an AWS chaos fault that detaches the data EBS volume attached to a percentage of running ECS tasks (filtered by compatibility through REQUIRED_COMPATIBILITIES) for a configurable duration, then reattaches the volume when the fault ends. While the volume is detached the application loses access to its mounted data; reads and writes against the detached path fail.
Use this fault to test how a workload behaves when its mounted storage briefly disappears: whether the application surfaces a clear error, whether stateful services (databases, queues) recover cleanly when the volume returns, and whether your monitoring detects the storage outage quickly.
Use cases
Run this fault when you want to answer concrete questions like:
Stateful workload resilience: When the data volume disappears, does the application fail fast with a clear error or hang waiting on IO?
Recovery after reattach: When the volume returns, does the application reattach to the mount cleanly, or does it require a restart?
Replication failover: For stateful services with replicas, does a healthy replica take over when its peer loses storage?
Storage monitoring: Does CloudWatch (or your monitoring) detect the volume outage within the alarm SLA?
Backup readiness: Is the runbook to restore from snapshot accurate and timed correctly when a volume becomes unreachable in production?
Prerequisites
Kubernetes version: 1.21 or later for the chaos infrastructure cluster. Go to What's supported to confirm distribution support.
Target ECS service:
CLUSTER_NAMEexists inREGION. IfSERVICE_NAMEis set, the fault selects from that service's running tasks.Tasks use an attachable volume: The task definition mounts an EBS volume (Fargate task volume support) or the EC2 launch type uses an EBS-backed bind mount that can be detached at the EC2 level.
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.
Supported environments
Amazon ECS on EC2 launch type with EBS-backed volumes
Supported
Amazon ECS on Fargate launch type with EBS volume attachments
Supported
Tasks without attached EBS volumes
Not supported (nothing to detach)
AWS regions
Supported in every commercial region; pass the region in REGION
Permissions required
The IAM principal that the chaos pod uses (the credentials mounted from the Harness Secret Manager file secret, the IRSA role on the chaos service account, or the role assumed via ASSUME_ROLE_ARN) needs the following AWS actions.
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 contents of the File Secret should be the 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 when configuring the fault.
Go to AWS named profile for chaos to switch between profiles inside a single credentials file.
Fault tunables
Configure the following fault parameters when you add ECS container volume detach to an experiment in Chaos Studio. Defaults are shown for reference.
Required parameters
CLUSTER_NAME
Name of the target ECS cluster.
(required)
REGION
AWS region that hosts the ECS cluster (for example us-east-1).
(required)
Targeting parameters
SERVICE_NAME
Name of the target ECS service. When set, the fault selects TASK_REPLICA_AFFECTED_PERC of the service's running tasks.
""
REQUIRED_COMPATIBILITIES
Comma-separated list of compatibilities (fargate, ec2) that a task must support to be considered.
fargate,ec2
TASK_REPLICA_AFFECTED_PERC
Percentage of qualifying tasks to detach volumes from.
100
Chaos parameters
TOTAL_CHAOS_DURATION
Duration of the fault in seconds. The volume stays detached for this period.
30
CHAOS_INTERVAL
Delay in seconds between successive iterations when running for more than one cycle.
30
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. Leave empty to use the base credentials directly.
""
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.
Fault execution in brief
Resolves the running tasks for SERVICE_NAME filtered by REQUIRED_COMPATIBILITIES, picks TASK_REPLICA_AFFECTED_PERC of them, and calls DetachVolume on the EBS volume attached to each selected task. After TOTAL_CHAOS_DURATION seconds, the chaos pod calls AttachVolume to restore each volume to its original device.
Expected behavior during fault execution
The target volumes transition from
in-usetodetachingtoavailable.Reads and writes against the mount point inside the affected containers return IO errors.
Stateful applications that depend on the volume (databases, queues) may exit, restart, or enter a degraded mode.
ECS may attempt to restart the task if the application exits; without the volume, restarts may fail.
CloudWatch EBS volume metrics show the detach.
Signals to watch
Attach resilience probes to assert each layer:
Volume state: Use a command probe that runs
aws ec2 describe-volumes --volume-ids <id>and asserts onState.Application errors: Use a Prometheus probe on application-level IO error counters.
Task lifecycle: Use a command probe that runs
aws ecs describe-tasksand asserts onlastStatusanddesiredStatus.Replication health: For replicated stateful workloads, use a Prometheus probe on replication-lag metrics.
Verify the fault execution effect
While the experiment is running, confirm the volume is detached and then reattached:
Inspect volume state.
During the fault
Stateshould beavailable(detached). After recovery it should bein-useagain.Inspect task state.
The task may be restarted; the resulting state depends on the application.
Check application logs.
ECS task logs in CloudWatch should show IO errors during the chaos window and recovery messages after the volume returns.
Recovery and cleanup
End of duration: The chaos pod calls
AttachVolumefor every detached volume.Abort the experiment: Stopping the experiment from Chaos Studio also triggers the reattach.
Manual recovery: If the fault exits before reattach, run
aws ec2 attach-volume --volume-id <vol-id> --instance-id <i> --device <device>with the values recorded in the chaos pod logs.Workload recovery: Depending on the application, you may need to remount the filesystem or restart the task.
Limitations
Volume must be attachable: Only EBS volumes that support detach/attach are affected; instance-store and ephemeral storage are not detached by this fault.
Multi-attach behaviour: If the volume uses Multi-Attach, detaching from one instance leaves the volume available on the other; the fault still records the original attachment for reattach.
AZ constraints on reattach: EBS volumes can only attach to instances in the same AZ; this fault preserves the original instance, so AZ constraints are honoured automatically.
Cross-region targeting: A single experiment targets one region (the value of
REGION).
Troubleshooting
Related faults
EBS loss by ID: Detach a specific EBS volume outside an ECS context.
EBS loss by tag: Detach EBS volumes selected by tag.
ECS container IO stress: Stress filesystem IO instead of detaching the volume.
Common AWS fault tunables: Shared environment variables for AWS faults.
Last updated
Was this helpful?