A CLI tool to simulate EC2 Spot Instances interruptions using AWS Fault Injection Simulator (FIS).
Since October 2021, You can trigger the interruption of an Amazon EC2 Spot Instance using AWS Fault Injection Simulator. When using Spot Instances, you need to be prepared to be interrupted. With FIS, you can test the resiliency of your workload and validate that your application is reacting to the interruption notices that EC2 sends before terminating your instances. You can target individual Spot Instances or a subset of instances in clusters managed by services that tag your instances such as Auto Scaling group, EC2 Fleet and EMR.
- Use AWS CloudShell or your favorite terminal, clone this repository.
git clone https://github.com/aws-samples/ec2-spot-interrupter-cli.git
- Change current directory to the downloaded repository folder.
- Run the install script:
sudo bash install.sh
To use this tool, you will need AWS credentials configured. Take a look at the AWS CLI configuration documentation for details on the various ways to configure credentials.
Populate the following environment variables with your AWS API credentials.
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
Set the AWS_REGION environment variable if it's not configured.
export AWS_REGION="..."
esi interrupt
-tk, --tag-key | Filter instances tag key [required]
-tv, --tag-value | Filter instances tag value [required]
[-dbi, --duration-before-interruption] | Number of minutes represents the duration after which the Spot instances are interrupted, must be between 2 and 15. Default is 2.
[-c, --count] | Number of instances to interrupt, between 1 and 1000. Default is 1.
[--confirm] | Flag to auto confirm interruption.
[-ir, --iam-role] | ARN of IAM role for FIS.
[--help] | Show help message.
- Interrupt 10 Spot instances filtering by instance tags, with parameters --tag-key and --tag-value
esi interrupt --duration-before-interruption 2 --count 10 --tag-key fis --tag-value yes
- Using a terminal, change current directory to the downloaded repository folder.
- Run the uninstall script:
sudo bash uninstall.sh
- Delete the repository folder.
Tip: You may have to manually remove the installation files if it persist.
sudo rm -rf /usr/local/bin/esi
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.