Documentation
...
├── .gitignore
├── env.template
├── Conf
│ └── config.tf.template
├── 030HelloSshPublicKey
│ ├── main.tf
│ ├── providers.tf
│ ├── Readme.md
│ └── variables.tf
├── 040...
...
└── Modules
├── HostMetaDat
...
└── SshKnownHosts
...export TF_VAR_hcloud_token=add_your_provider_token
export TF_VAR_dns_secret=add_your_ds_server_secret-
env.templateis to be copied to e.g. anenvfile. -
Required credentials to be filled in.
-
Prior to executing e.g. terraform
inittheenvfile has to be sourced:. ../env # Sourcing environment echo $TF_VAR_hcloud_token # For testing purpose only z0Tgf... terraform init ...
-
In contrast to
env.templatetheenvfile is being listed in.gitignoredue to sensible content.
# variables.tf
variable "hcloud_token" { # See env file
nullable = false
sensitive = true
}# env file
TF_VAR_hcloud_token="z0Tgf ... "# providers.tf
...
provider "hcloud" { token = var.hcloud_token }output "authorizedKeys" {
description = "List of authorized users' public ssh keys"
type = map(string)
value = {
goik = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKY24AeEibQGSMPtstaN4REByLCM3kzjM//apEZ9WyUB goik@hdm-stuttgart.de"
xy001 = "KEY_OF_USER_xy001 xy001@hdm-stuttgart.de"
xy002 = ...
}
}
output "loginUserName" {
description = "Login user's name with admin privileges"
type = string
value = "devops"
}-
Problems:
-
Multiple users and local Terraform state.
-
Disjoint working environments, i.e. company and home office.
-
-
Solution: Move Terraform state to shared backend.
