AWSChaos allows you to simulate AWS infrastructure failures by manipulating EC2 instances and EBS volumes through the AWS API.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt
Use this file to discover all available pages before exploring further.
Actions
AWSChaos supports the following actions:- ec2-stop: Stop an EC2 instance
- ec2-restart: Restart an EC2 instance
- detach-volume: Detach an EBS volume from an EC2 instance
Spec Fields
The AWS chaos action to perform.Options:
ec2-stop, ec2-restart, detach-volumeDefault: ec2-stopAWS region where the resources are located (e.g.,
us-west-2, eu-central-1).EC2 instance ID to target (e.g.,
i-0123456789abcdef0).EBS volume ID to detach. Required when action is
detach-volume.Example: vol-0123456789abcdef0Device name of the volume attachment. Required when action is
detach-volume.Example: /dev/sdfDuration of the chaos action. For
ec2-stop, the instance remains stopped for this duration. Not applicable to ec2-restart (oneshot action).Name of the Kubernetes secret containing AWS credentials. If not specified, uses the default AWS credential chain (IAM roles, environment variables, etc.).
Remote cluster name where the chaos will be deployed.
AWS Credentials Setup
You need to provide AWS credentials to Chaos Mesh. There are two approaches:Option 1: Kubernetes Secret (Recommended)
Create a Kubernetes secret with AWS credentials:Option 2: IAM Roles for Service Accounts (IRSA)
If running on EKS, you can use IAM Roles for Service Accounts:- Create an IAM role with the necessary EC2 permissions
- Associate the role with the Chaos Controller Manager service account
- Don’t specify
secretNamein the AWSChaos spec
Required IAM Permissions
The AWS credentials need the following permissions:Examples
Stop EC2 Instance
Restart EC2 Instance
ec2-restart is a oneshot action and doesn’t use duration.
Detach EBS Volume
Implementation Details
AWSChaos uses the AWS SDK to:- Authenticate using provided credentials or IAM roles
- Call AWS APIs to manipulate resources:
ec2-stop: CallsStopInstancesAPI, thenStartInstancesafter durationec2-restart: CallsRebootInstancesAPI (oneshot)detach-volume: CallsDetachVolumeAPI, thenAttachVolumeafter duration
api/v1alpha1/awschaos_types.go:43-109
Oneshot Behavior
Theec2-restart action is marked as a oneshot action, meaning:
- It executes once immediately
- No recovery action is performed
- The
durationfield is ignored - The experiment completes after the restart command is sent
api/v1alpha1/awschaos_types.go:28
Important Notes
- Ensure your AWS credentials have appropriate permissions
- Be cautious when targeting production instances
- The EC2 instance must be in a state that allows the requested operation
- For
detach-volume, ensure the volume is not the root volume unless the instance is stopped - Test in non-production environments first