@@ -28,27 +28,28 @@ This guide explains how to set up and use the Hetzner Cloud provider with the To
2828For enhanced security, store your Hetzner Cloud API token using secure file storage
2929instead of environment variables:
3030
31- ### Option 1: Secure Storage (Recommended)
31+ ### Provider Configuration Setup
3232
3333``` bash
34- # Create secure storage directory
35- mkdir -p ~ /.config/hetzner
36- chmod 700 ~ /.config/hetzner
34+ # Copy provider configuration template
35+ cp infrastructure/config/templates/providers/hetzner.env.tpl infrastructure/config/providers/hetzner.env
3736
38- # Store the Hetzner Cloud API token (replace YOUR_TOKEN_HERE with actual token)
39- echo " YOUR_TOKEN_HERE " > ~ /.config/hetzner/cloud_api_token
40- chmod 600 ~ /.config/hetzner/cloud_api_token
37+ # Edit the configuration file to add your Hetzner Cloud API token
38+ # Replace REPLACE_WITH_YOUR_HETZNER_API_TOKEN with your actual 64-character token
39+ # HETZNER_API_TOKEN=your_64_character_token_here
4140
42- # Verify storage
43- ls -la ~ /.config/hetzner/
44- # Should show: -rw------- 1 user user 65 date time cloud_api_token
41+ # Verify configuration
42+ grep HETZNER_API_TOKEN infrastructure/config/providers/hetzner.env
4543```
4644
47- ### Test Token Storage
45+ ### Test Token Configuration
4846
4947``` bash
50- # Test that token can be loaded from storage
51- CLOUD_TOKEN=$( cat ~ /.config/hetzner/cloud_api_token)
48+ # Source the provider configuration
49+ source infrastructure/config/providers/hetzner.env
50+
51+ # Test that token is loaded correctly
52+ CLOUD_TOKEN=" $HETZNER_API_TOKEN "
5253echo " Token length: ${# CLOUD_TOKEN} characters"
5354# Should show: Token length: 64 characters
5455
@@ -63,12 +64,12 @@ curl -H "Authorization: Bearer $CLOUD_TOKEN" \
6364If you prefer environment variables, you can still use the traditional approach:
6465
6566``` bash
66- export HETZNER_TOKEN =your_64_character_token_here
67+ export HETZNER_API_TOKEN =your_64_character_token_here
6768```
6869
69- > ** Note** : The infrastructure scripts will automatically detect tokens from secure
70- > storage first, then fall back to environment variables. Secure storage is
71- > recommended for production use .
70+ > ** Note** : The infrastructure scripts automatically load the Cloud API token
71+ > from ` infrastructure/config/providers/hetzner.env ` . You no longer need to set the
72+ > ` HETZNER_API_TOKEN ` environment variable if using provider configuration .
7273
7374## Step 3: Configure Provider
7475
@@ -88,7 +89,7 @@ export HETZNER_TOKEN=your_64_character_token_here
8889
8990 ``` bash
9091 # Required: Your Hetzner API token
91- HETZNER_TOKEN =your_64_character_token_here
92+ HETZNER_API_TOKEN =your_64_character_token_here
9293
9394 # Optional: Customize server settings
9495 HETZNER_SERVER_TYPE=cx31 # 2 vCPU, 8GB RAM, 80GB SSD
@@ -181,13 +182,13 @@ Hetzner Cloud service limitation makes manual volume attachment the only reliabl
181182
182183 ``` bash
183184 # Create a 20GB volume for persistent data
184- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud volume create \
185+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud volume create \
185186 --name torrust-data \
186187 --size 20 \
187188 --location fsn1
188189
189190 # Attach volume to server
190- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud volume attach \
191+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud volume attach \
191192 torrust-data torrust-tracker-prod
192193 ```
193194
@@ -406,7 +407,7 @@ by Hetzner. Use `hcloud server-type list` for current availability.
406407 export PATH=$PATH :$( go env GOPATH) /bin
407408
408409 # List current server types
409- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud server-type list
410+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud server-type list
410411 ```
411412
4124132 . Update your configuration with a valid server type:
@@ -428,7 +429,7 @@ by Hetzner. Use `hcloud server-type list` for current availability.
4284292 . Verify token has Read & Write permissions
4294303 . Check token is correctly set in both:
430431 - ` infrastructure/config/providers/hetzner.env `
431- - Environment variable: ` export HETZNER_TOKEN =your_token_here `
432+ - Environment variable: ` export HETZNER_API_TOKEN =your_token_here `
432433
433434#### 3. Provider Configuration Variable Collision
434435
@@ -448,7 +449,7 @@ in provider scripts.
4484491 . Check current locations:
449450
450451 ``` bash
451- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud location list
452+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud location list
452453 ```
453454
4544552 . Try different locations:
@@ -688,10 +689,10 @@ This limitation validates our architectural decision to make volume setup manual
688689
689690` ` ` bash
690691# Check current server types and availability
691- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud server-type list
692+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud server-type list
692693
693694# Check available locations
694- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud location list
695+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud location list
695696
696697# Validate configuration without applying
697698make infra-plan ENVIRONMENT=production-hetzner PROVIDER=hetzner
@@ -703,8 +704,8 @@ make infra-status ENVIRONMENT=production-hetzner PROVIDER=hetzner
703704make vm-ssh ENVIRONMENT=production-hetzner
704705
705706# Check server details (after deployment)
706- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud server list
707- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud server describe torrust-tracker-prod
707+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud server list
708+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud server describe torrust-tracker-prod
708709` ` `
709710
710711# ## Real-Time Information Commands
@@ -713,13 +714,13 @@ Always verify current Hetzner Cloud offerings before deployment:
713714
714715` ` ` bash
715716# Get current server types with pricing
716- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud server-type list
717+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud server-type list
717718
718719# Get current datacenter locations
719- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud location list
720+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud location list
720721
721722# Check image availability
722- HCLOUD_TOKEN=" $HETZNER_TOKEN " hcloud image list --type=system | grep ubuntu
723+ HCLOUD_TOKEN=" $HETZNER_API_TOKEN " hcloud image list --type=system | grep ubuntu
723724` ` `
724725
725726# # Docker Compose Commands on Deployed Server
0 commit comments