Leon Steenkamp

Building small satellites on the tip of Africa. My other ride is a CubeSat.


My first Terraform project

I think I stumbled accross Terraform while looking at HashiCorp Vagrant a while ago, but never realised what you can use it for until I came across this article while looking for Ansible information. This was also around the time I started looking into using the AWS CLI to manage an EC2 instance.

The Terraform website has more information on what Terraform is and what you can use it for. What it enabled me to do was define my EC2 instance in code rather than manually clicking through the setup process for the EC2 instance. When the instance is up I can use Ansible to further configure it. Using Terraform you can quickly stand up and tear down instances with little manual work.

The Ansible playbook upgrades the Ubuntu distribution and then install Tailscale. If a Tailscale auth key is provided, then the service is started after installation.

My Terraform project finds the most recent Ubuntu AMI to use. A local key pair is specified to access the running instance. An AWS security group is created to limit inbound access to only the SSH port from a specified IP. If Tailscale is started from Ansible it would be possible to remove the SSH inbound rule and access the machine at its Tailscale IP.

The Terraform and Ansible project can be found in this GitHub repository - https://github.com/leonsteenkamp/tf-ec2-ubuntu-ts