Terraform/OpenTofu
Terraform
Infrastructure automation to provision and manage resources in any cloud or data center.
Home: https://www.terraform.io/
Releases: https://github.com/hashicorp/terraform/releases
Final version with Mozilla Public License: 1.5.7
The newer versions are released under Business Source License.
OpenTofu
The open source infrastructure as code tool
Home: https://opentofu.org/
Releases: https://github.com/opentofu/opentofu/releases
Basic Terraform commands - Cheat sheet
Command | Description |
---|---|
terraform init | Initialize the Terraform directory and download the required provider plugins |
terraform fmt -recursive | Ensure all Terraform code in the current directory and subdirectories is formatted properly |
terraform validate | Validate the syntax of the Terraform configuration files and check for errors |
terraform plan | Show the execution plan, the resources that will be created, updated, or destroyed |
terraform apply | Apply the changes required to reach the desired state of the infrastructure |
terraform destroy | Destroy the Terraform-managed infrastructure |
terraform show | Display the current state of the Terraform-managed infrastructure |
terraform state list | List all resources in the Terraform state |
terraform apply -replace "id" | Force replacement of a resource |
Azure VM module
The modules in the terraform/modules
folder are implementing a Virtual Machine with the associated network setup and storage.
This VM can be used to test/host the Docker services of this repo.
Usage:
- Login to Azure account (without browser access on device):
az login --use-device-code
- See the file
terraform/Makefile
for availablemake
commands for deploying/connection/deleting the VM.
Requirements
Name | Version |
---|---|
terraform | >= 1.5 |
azurerm | ~> 4.0 |
Modules
Name | Source | Version |
---|---|---|
base | ./modules/base | n/a |
storage | ./modules/storage | n/a |
vm | ./modules/vm | n/a |
Inputs
Name | Description | Type | Default | Required |
---|---|---|---|---|
admin_source_address | Allow connections (SSH, …) only from this IP | string | n/a | yes |
admin_user | Name of the administrative user on the VM | string | "azureuser" | no |
git_credentials | Git credentials for accessing the infrastructure repository. Will be written to ~/.git-credentials | string | n/a | yes |
location | Location of the resources | string | "westeurope" | no |
repo_directory | Name of the infrastructure repository directory | string | "infra" | no |
repo_url | URL of the infrastructure repository | string | n/a | yes |
resourcegroup | Name of Resource Group | string | "HomeInfra" | no |
storage_disk_size_gb | Size of the permanent disk in GB | number | 10 | no |
subscription_id | Azure subscription ID (format: ‘00000000-xxxx-xxxx-xxxx-xxxxxxxxxxxx’) | string | n/a | yes |
vm_domain_name_label | DNS name of the VM. The FQDN will be: <vm_domain_name_label>..cloudapp.azure.com | string | n/a | yes |
vm_name | Name, hostname of the VM | string | n/a | yes |
vm_size | Size of the VM | string | "Standard_D2s_v5" | no |
vm_ubuntu_server_offer | Offer of the VM | string | "0001-com-ubuntu-server-jammy" | no |
vm_ubuntu_server_sku | SKU of the VM | string | "22_04-lts-gen2" | no |
Outputs
Name | Description |
---|---|
vm_fqdn | n/a |
vm_id | n/a |
vm_public_ip_address | n/a |
vm_public_key_fingerprint_sha256 | n/a |
vm_tls_private_key | n/a |