Working with Terraform

Figure 1056. What's it all about? Slide presentation

Quote:

Terraform is an infrastructure as code tool that lets you build, change, and version cloud and on-prem resources safely and efficiently.



Figure 1058. Creating databases Slide presentation
Declarative schema Physical result
CREATE SCHEMA ...
  CREATE TABLE ...

  CREATE VIEW ...

...
  • Database implementation using files,or (raw) devices.

  • Creating Index / search trees.


Figure 1059. Creating cloud resources Slide presentation
Declarative schema Physical result
resource "hcloud_server" "wwwServer" {
  name         = "hello"
  image        =  "debian-13"
  server_type  =  "cx23"
}
Creating IPs, networks, servers, message queues, ...

Figure 1060. Your course documentation: Code structure Slide presentation
...
├── env.template
├── 030HelloSshPublicKey
│   ├── main.tf
│   ├── providers.tf
│   ├── Readme.md
│   └── variables.tf
└── Modules
    ├── HostMetaData
        ...
    └── SshKnownHosts
         ...

Figure 1061. The env.template file Slide presentation
export TF_VAR_login_user=devops
export TF_VAR_ssh_login_public_key=add_your_provider_token
export TF_VAR_hcloud_token=add_your_provider_token
export TF_VAR_dns_secret=add_your_ds_server_secret

To be copied, edited and used by Terraform.


Figure 1062. Getting started: The Hetzner API token Slide presentation
  • Access you cloud project by the Hetzner GUI interface.

  • Go to Security --> API Tokens --> Generate API token

  • Provide a name and hit Generate API token.

  • Copy the generated token's value and store it in a secure location e.g. a password manager.

    Caution

    The Hetzner GUI blocks subsequent read access after creation.

    In case of loss: Delete the existing and generate a new one.