learn-terraform

Course outlines for learning terraform.

View the Project on GitHub robertdebock/learn-terraform

Templates solution

  1. Create ssh_config.tf:
resource "local_file" "ssh_config" {
  content  = templatefile("./templates/ssh_config.tpl",
  {
    ip       = azurerm_public_ip.publicip.ip_address,
    username = var.admin_username
  } )
  filename = "./ssh_config"
}
  1. Add templates/ssh_config.tpl:
Host ${ip}
  User ${username}
  1. Apply the code:
export TF_VAR_admin_password="Password1234!"
export TF_VAR_admin_username="my_username"
terraform init
terraform plan
terraform apply