Chaos Engineering
Building a Basic FIS experiment
Demo Create FIS Experiment using CF
In this tutorial, you’ll deploy an AWS Fault Injection Simulator (FIS) experiment with a CloudFormation template—the same experiment you could create in the AWS Management Console. This approach enables repeatable, version-controlled chaos engineering deployments.
Prerequisites
- AWS account with administrative permissions (or FIS, EC2, CloudFormation privileges)
- AWS CLI configured locally
- Basic familiarity with CloudFormation and Auto Scaling groups
Step 1: Clone the Repository
- Navigate to the GitHub repo shown above.
- Download or clone the repository to your local system:
git clone https://github.com/kodekloudhub/FaultInjectionSimulator-KodeKloud.git cd FaultInjectionSimulator-KodeKloud
- Locate the CloudFormation template (
fis-experiment-template.json
).
Step 2: Review the CloudFormation Template
Below is the core resource definition that creates an FIS experiment template to terminate 50% of instances in an Auto Scaling group:
{
"Resources": {
"FisWorkshopTemplate": {
"Type": "AWS::FIS::ExperimentTemplate",
"Properties": {
"Description": "Terminate half of the instances in the auto scaling group",
"Tags": { "Name": "FisWorkshop-Exp1-CloudFormation" },
"Actions": {
"FisWorkshopAsg-TerminateInstances": {
"ActionId": "aws:ec2:terminate-instances",
"Description": "Terminate instances",
"Parameters": {},
"Targets": { "Instances": "FisWorkshopAsg-50Percent" }
}
}
}
}
}
}
Template Section | Purpose | Details |
---|---|---|
Description | Explains the experiment intent | Terminate 50% of instances |
Tags | Metadata for easy identification | Name=FisWorkshop-Exp1-CloudFormation |
Actions | Defines chaos actions | aws:ec2:terminate-instances targeting a resource selector |
Targets | Selects the EC2 instances to terminate | FisWorkshopAsg-50Percent selects half of the instances by tag filter |
IAM Role & Logs | (Not shown) Creates an IAM execution role and CloudWatch Logs group | Required for FIS permissions and audit trails |
Note
This template does not declare any parameters—everything is preconfigured.
Step 3: Deploy the CloudFormation Stack
- Open the AWS CloudFormation console.
- Choose Create stack → With new resources (standard).
- Upload the JSON template (
fis-experiment-template.json
).
- Provide a stack name (e.g.,
fis-experiment-stack
) and click Next through the remaining screens. - Review and click Create stack.
Once the stack reaches CREATE_COMPLETE, confirm that the FisWorkshopTemplate
resource exists:
Step 4: Inspect the Experiment in the FIS Console
- In CloudFormation, click the FisWorkshopTemplate resource.
- Select View in Console to open the AWS FIS console.
- Review the Actions and Targets.
- Click Generate preview to simulate which instances would be affected.
Warning
If your Auto Scaling group has fewer than 2 instances, the preview will fail because you cannot select 50% of one instance.
Step 5: Scale the Auto Scaling Group
- Open the EC2 Auto Scaling console.
- Select your Auto Scaling group and click Edit.
- Increase the Desired and Minimum capacity from 1 to 2.
- Save and wait for the second instance to reach the running state.
Step 6: Generate Preview and Run the Experiment
- Return to the FIS console and click Generate preview again. You’ll see one of the two instances selected.
- Click Start experiment to terminate the instance.
- Observe that the Auto Scaling group immediately replaces the terminated instance—maintaining your application’s capacity without disruption.
Links and References
- AWS Fault Injection Simulator Documentation
- AWS CloudFormation User Guide
- EC2 Auto Scaling Documentation
- Chaos Engineering on AWS
Watch Video
Watch video content