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.

The image shows a GitHub repository page for "FaultInjectionSimulator-KodeKloud," containing files and a README for setting up an AWS Fault Injection Simulator experiment.

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

  1. Navigate to the GitHub repo shown above.
  2. Download or clone the repository to your local system:
    git clone https://github.com/kodekloudhub/FaultInjectionSimulator-KodeKloud.git
    cd FaultInjectionSimulator-KodeKloud
    
  3. 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 SectionPurposeDetails
DescriptionExplains the experiment intentTerminate 50% of instances
TagsMetadata for easy identificationName=FisWorkshop-Exp1-CloudFormation
ActionsDefines chaos actionsaws:ec2:terminate-instances targeting a resource selector
TargetsSelects the EC2 instances to terminateFisWorkshopAsg-50Percent selects half of the instances by tag filter
IAM Role & Logs(Not shown) Creates an IAM execution role and CloudWatch Logs groupRequired for FIS permissions and audit trails

Note

This template does not declare any parameters—everything is preconfigured.

Step 3: Deploy the CloudFormation Stack

  1. Open the AWS CloudFormation console.
  2. Choose Create stackWith new resources (standard).
  3. Upload the JSON template (fis-experiment-template.json).

The image shows an AWS CloudFormation interface where a user is prompted to specify stack details, including providing a stack name. There are no parameters defined in the template.

  1. Provide a stack name (e.g., fis-experiment-stack) and click Next through the remaining screens.
  2. Review and click Create stack.

Once the stack reaches CREATE_COMPLETE, confirm that the FisWorkshopTemplate resource exists:

The image shows an AWS CloudFormation console with a stack named "asg" that has a status of "CREATE_COMPLETE." It displays details of a resource with a logical ID "FisWorkshopTemplate" and type "AWS::FIS::ExperimentTemplate."

Step 4: Inspect the Experiment in the FIS Console

  1. In CloudFormation, click the FisWorkshopTemplate resource.
  2. Select View in Console to open the AWS FIS console.

The image shows an AWS Fault Injection Simulator (FIS) interface with details of an experiment template designed to terminate half of the instances in an auto-scaling group. It includes information such as the experiment template ID, ARN, creation time, and actions involved.

  1. Review the Actions and Targets.
  2. 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

  1. Open the EC2 Auto Scaling console.
  2. Select your Auto Scaling group and click Edit.
  3. Increase the Desired and Minimum capacity from 1 to 2.
  4. Save and wait for the second instance to reach the running state.

The image shows an AWS EC2 console with one running instance of type t3.micro. The instance has passed its status checks and is located in the ap-northeast-1 region.

Step 6: Generate Preview and Run the Experiment

  1. Return to the FIS console and click Generate preview again. You’ll see one of the two instances selected.
  2. Click Start experiment to terminate the instance.
  3. Observe that the Auto Scaling group immediately replaces the terminated instance—maintaining your application’s capacity without disruption.

Watch Video

Watch video content

Previous
Demo FIS experiment CloudWatch Dashboard