This project automates the creation of a hardened, ready-to-deploy Kali Linux Amazon Machine Image (AMI) — your "golden image" for red team operations or secure penetration testing in AWS. Using Packer for image builds, Ansible for configuration, and Terraform for deployment, it delivers a repeatable, infrastructure-as-code workflow to spin up production-ready Kali instances with zero manual steps.
Whether you're launching a lab environment or scaling offensive security operations in the cloud, this repo gives you a powerful, fully-automated pipeline from bare base to battle-tested box.
This guide explains how to use Packer and Terraform to create an Amazon Machine Image (AMI) and launch an EC2 instance on AWS.
- Terraform installed
- Packer installed
- AWS credentials configured (via environment variables or AWS CLI)
Use the following command to create an AMI based on the Packer configuration file:
packer init kali.pkr.hcl
packer build kali.pkr.hcl
Note the AMI ID generated by Packer.
Replace variables.tf with the AMI ID generated by your Packer.
Run the following commands to initialize Terraform and create the Kali Linux EC2 instance:
terraform init
terraform apply
Confirm the changes when prompted.
After Terraform completes provisioning, access the EC2 instance using SSH with the private key corresponding to the SSH key pair used in the Packer configuration:
ssh -i /path/to/your/ssh/private/kali-key kali@INSTANCE_IP
Replace /path/to/your/ssh/private/key.pem with the path to your private key and INSTANCE_IP with the actual public IP or DNS name of the EC2 instance.