ECS invalid container image
Swap the container image of an ECS service to an invalid value for a configurable duration so you can test how ECS, your deployment guardrails, and your alerting respond to a failed image pull.
ECS invalid container image is an AWS chaos fault that registers a new revision of the target service's task definition with an invalid container image (IMAGE, default nginx with a deliberately wrong tag in practice), updates the service to that revision for a configurable duration, then re-registers the original revision and restores the service. The new tasks fail to start with CannotPullContainerError and the service deployment stalls until the fault ends.
Use this fault to test how a deployment behaves when the build pipeline produces a broken image, when an image-tag or registry permission changes break image pulls, and to verify that deployment circuit breakers, alerting, and rollback playbooks all work as expected.
Use cases
Run this fault when you want to answer concrete questions like:
Deployment circuit breaker: When new tasks cannot start, does the ECS deployment circuit breaker (
deploymentCircuitBreaker.enable=true) roll back automatically, and within what window?Failure alerting: Do alarms on
RunningTaskCount,PendingTaskCount, or service events fire and reach the on-call within the SLA?Customer impact during stalled deployment: Does the existing healthy task continue to serve traffic while the bad deployment is stuck, or does the load balancer mark the service unhealthy because of the stuck pending tasks?
Registry permissions: Does a regression in registry IAM (for example a missing
ecr:GetDownloadUrlForLayerpermission) produce the same symptoms, and is the runbook to detect that ready?Rollback procedure: Is your manual rollback runbook still accurate when applied under time pressure during a broken deployment?
Prerequisites
Kubernetes version: 1.21 or later for the chaos infrastructure cluster. Go to What's supported to confirm distribution support.
Target ECS service:
SERVICE_NAMEexists inCLUSTER_NAMEwithinREGIONand has at least one running task at the start of the experiment.Service can register new task definition revisions: The task execution role on the service has permission to pull from your default registry (the fault re-uses the existing role and only swaps the image).
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
Supported
Amazon ECS on Fargate launch type
Supported
Services with deployment circuit breaker enabled
Supported (the deployment rolls back automatically; restore is a no-op)
Services with maximumPercent=100
Supported (the existing tasks stay until they are forcibly replaced)
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.
ecs:DescribeServicesandecs:DescribeTaskDefinitionare used to read the original task definition.ecs:RegisterTaskDefinitionandecs:DeregisterTaskDefinitionare used to publish the chaos revision and clean up afterwards.ecs:UpdateServiceis used to point the service at the chaos revision and back.iam:PassRoleis required to re-register the task definition with the same task execution role.
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 invalid container image to an experiment in Chaos Studio. Defaults are shown for reference.
Required parameters
CLUSTER_NAME
Name of the target ECS cluster.
(required)
SERVICE_NAME
Name of the target ECS service.
(required)
REGION
AWS region that hosts the ECS cluster (for example us-east-1).
(required)
Chaos parameters
IMAGE
Image to inject in the chaos task definition revision. The default value is treated as an obviously invalid reference. Override only if you need to test with a specific bad image (for example a non-existent ECR tag).
nginx
TASK_REPLICA_AFFECTED_PERC
Percentage of task replicas to affect through the deployment (used to compute maximumPercent for the chaos deployment).
100
TOTAL_CHAOS_DURATION
Duration of the fault in seconds. The service runs on the chaos revision for this period before the original revision is restored.
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
Reads the current task definition for SERVICE_NAME, registers a new revision with the container image swapped to IMAGE, calls UpdateService to point the service at the chaos revision, waits for TOTAL_CHAOS_DURATION seconds, then calls UpdateService again with the original revision and deregisters the chaos revision.
Expected behavior during fault execution
A new task definition revision is registered with the invalid image.
The service deployment starts launching tasks on the new revision; those tasks transition to
STOPPEDwith a stopped reason ofCannotPullContainerError(or registry-specific error if the image is private without permissions).Depending on
deploymentCircuitBreaker.enableon the service, the deployment either stays inIN_PROGRESSindefinitely or rolls back automatically.Existing healthy tasks (on the original revision) continue to serve traffic while ECS retries the new revision, up to the
maximumPercentcap.CloudWatch service events report repeated task start failures.
Signals to watch
Attach resilience probes to assert each layer:
Application availability: Use an HTTP probe against the service endpoint to confirm existing healthy tasks continue to serve traffic during the bad deployment.
Deployment status: Use a command probe that runs
aws ecs describe-services --query "services[].deployments"and asserts the deployment circuit breaker triggers a rollback (or asserts that the deployment is stuck, depending on the expected behaviour).Failed tasks: Use a Prometheus probe on
aws_ecs_pending_task_countto detect the buildup of failed task attempts.Service events: Inspect
aws ecs describe-services --query "services[].events"for repeated(service ...) was unable to place a taskmessages.
Verify the fault execution effect
While the experiment is running, confirm tasks fail to start and the service eventually returns to the original revision:
Inspect deployment list.
During the fault you should see two deployments: the new (PRIMARY) deployment on the chaos revision with
pendingCount > 0andfailedTasks > 0, and the existing deployment on the original revision serving traffic.Inspect stopped tasks for failure reason.
The reason should mention
CannotPullContainerErrororImagePullBackOff-like message.After recovery, confirm the original revision is active.
The active task definition ARN should match the pre-fault revision.
Recovery and cleanup
End of duration: The chaos pod calls
UpdateServicewith the original task definition revision and waits for at least one task on that revision to reachRUNNING. The chaos revision is then deregistered.Abort the experiment: Stopping the experiment from Chaos Studio also triggers the restore-and-deregister cleanup.
Manual recovery: If the fault exits before cleanup runs, list task definition revisions with
aws ecs list-task-definitions --family-prefix <family>and either roll the service back manually or deregister the chaos revision.Workload recovery: No data loss is expected because the original revision keeps running on at least the minimum healthy percent of tasks; new tasks resume on recovery.
Limitations
Service must have a task definition: Standalone tasks (no service) cannot be targeted by this fault.
Requires task execution role permission: The fault re-registers the task definition with the same task execution role; if that role is restricted such that it cannot publish a new revision (rare), registration will fail.
Single service per experiment: Use multiple experiments to target multiple services with different bad images.
maximumPercent constraints: If the service has
maximumPercent=100, ECS will not start new tasks until existing tasks are stopped; the bad deployment may not surface until the minimum healthy percent allows it.Cross-region targeting: A single experiment targets one region (the value of
REGION).
Troubleshooting
Related faults
ECS update container resource limit: Modify container resource limits in a new revision.
ECS update container timeout: Modify container start/stop timeouts in a new revision.
ECS update task role: Swap the task role to test permission failures.
Common AWS fault tunables: Shared environment variables for AWS faults.
Last updated
Was this helpful?