Terraform Packer template for creating a golden Kali Linux Amazon Machine Image (AMI) in AWS
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.