macOS - Installing Terraform with Autocompletion
A short tutorial for macOS on Installing Terraform with Zsh autocompletion.
Install
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
hashicorp/tap/terraform
.terraform -version
Terraform v1.2.5
on darwin_arm64
Enable tab completion
touch ~/.zshrc
terraform -install-autocomplete
Quick test
mkdir learn-terraform-docker-container
cd learn-terraform-docker-container
Create a main.tf with the following configuration.
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 2.13.0"
}
}
}
provider "docker" {}
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "tutorial"
ports {
internal = 80
external = 8000
}
}
terraform init
terraform apply
apply
. When Terraform asks you to confirm type yes
and press ENTER
.Verify the existence of the NGINX container by visiting localhost:8000 in your web browser or running docker ps
to see the container.

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
445d5e111111 e7913s34dehk "nginx -g 'daemon of…" 20 seconds ago Up 30 seconds 0.0.0.0:8000->80/tcp tutorial
terraform destroy
terraform destroy
.