> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Experiment 1 Chaos Engineering on ASG

> This article describes designing and executing a chaos engineering experiment using AWS Fault Injection Simulator on an Auto Scaling Group to test application resilience.

In this chapter, we’ll design and execute our first AWS Fault Injection Simulator (FIS) experiment against an Auto Scaling Group (ASG). The goal is to validate that terminating a single EC2 instance does not degrade application availability because the ASG will replace it automatically.

## Components of the FIS Experiment

| Component  | Description                                                                                                                                                  |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Given      | We have an application running on EC2 instances spread across multiple Availability Zones, all managed by an Auto Scaling Group.                             |
| Hypothesis | If we terminate one EC2 instance, the Auto Scaling Group will launch a new instance, and the application will continue serving traffic without interruption. |

<Callout icon="lightbulb" color="#1CB2FE">
  We use [AWS Fault Injection Simulator](https://docs.aws.amazon.com/fis/latest/userguide/what-is-fis.html) to safely inject failures and test application resilience. Make sure your IAM role has the required permissions to execute FIS experiments.
</Callout>

## Experiment Steps

1. **Create FIS Experiment Template**\
   Define the target resources (the ASG) and select the `aws:ec2:terminate-instances` action.
2. **Specify Targets and Actions**
   * Target: EC2 instances belonging to your ASG
   * Action: Terminate one randomly selected instance
3. **Set Stop Conditions**\
   Monitor CloudWatch alarms (e.g., high error rates or latency). If any alarm triggers, FIS will automatically stop the experiment.
4. **Run and Observe**\
   Execute the FIS experiment and watch the ASG replace the terminated instance.
5. **Validate Outcome**\
   Confirm that the new EC2 instance passes health checks and that no user-facing errors occur.

<Callout icon="triangle-alert" color="#FF6B6B">
  Always run chaos experiments in a staging or non-production environment first. Verify that your CloudWatch alarms and Auto Scaling health checks are correctly configured to avoid unintended downtime.
</Callout>

## References

* [AWS Fault Injection Simulator User Guide](https://docs.aws.amazon.com/fis/latest/userguide/)
* [Amazon EC2 Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html)
* [Defining FIS Experiment Templates](https://docs.aws.amazon.com/fis/latest/userguide/experimentation-templates.html)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/chaos-engineering/module/d49a2b6d-60a1-4603-965d-7e8292688875/lesson/27610f4a-e273-4507-9382-c41aa18c06e9" />
</CardGroup>
