HOWTO Terraform
HashiCorp Terraform is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle. Terraform can manage low-level components like compute, storage, and networking resources, as well as high-level components like DNS entries and SaaS features.
Install Terraform on IGEL OS
- Use IGEL KB: IGEL App Creator Portal with the Terraform Recipe
Use Terraform to Build Docker Container for Debian Bookworm
Steps:
- Create
main.tf - Run
terraform - Run
dockerto start container. Docker recipe
Save the following as main.tf
terraform {
required_version = ">= 1.5.0"
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 3.0"
}
}
}
provider "docker" {}
# Pull Debian Bookworm image
resource "docker_image" "debian_bookworm" {
name = "debian:bookworm"
keep_locally = true
}
# Create a container
resource "docker_container" "bookworm" {
name = "debian-bookworm"
image = docker_image.debian_bookworm.image_id
# Keep it running (Debian exits immediately otherwise)
command = ["sleep", "infinity"]
# Install packages on startup (simple)
# Add to docker_container:
#command = ["bash", "-lc", "apt-get update && apt-get install -y curl ca-certificates && sleep infinity"]
# Optional: set a hostname
hostname = "bookworm"
# Optional: environment variables
env = [
"DEBIAN_FRONTEND=noninteractive"
]
# Optional: port mapping example (uncomment if you run a service)
# ports {
# internal = 8080
# external = 8080
# }
# Optional: mount a host directory into the container
# volumes {
# host_path = "${path.module}/data"
# container_path = "/data"
# read_only = false
# }
}
output "container_name" {
value = docker_container.bookworm.name
}
output "container_id" {
value = docker_container.bookworm.id
}
Save the following as run-terraform.sh
#!/bin/bash
# set -x
# trap read debug
terraform init
terraform apply
Save the following as run-docker.sh
#!/bin/bash
# set -x
# trap read debug
# run script as root
docker exec -it debian-bookworm bash
Use Terraform to setup Azure Application Gateway as Reverse Proxy for IGEL UMS
Steps:
- Create
main.tf - Run
terraform
IGEL KB: Configure the UMS to Integrate Reverse Proxy with SSL Offloading
IGEL KB: Azure Application Gateway Example Configuration as Reverse Proxy in IGEL UMS with SSL Offloading
NOTE: Code under development