This repository automates the process of building a base Docker AMI on EC2 (Ubuntu 18.4).
Terraform is used to create the sandbox instance on EC2; then Ansible is used to install Docker and create the AMI.
-
On the host machine, install:
-
Run
./setup.sh
, which initializes the Terraform project and installs Python dependencies. -
Create a
terraform.tfvars
file in the root directory, and provide values for the three required variables:vpc_id = "vpc-XXX" subnet_id = "subnet-XXX" public_key_path = "/path/to/key.pub"
-
Run
./build.sh
. This will create the instance, install Docker, create the AMI, and log the AMI id to the terminal in the last Ansible step. -
After the AMI has been created,
terraform destroy
is run to remove the EC2 resources - typeyes
to confirm.