← Back to Resources

Cloud Provisioning with Claude Code (Hetzner Cloud)

Overview

This example demonstrates using Claude Code to automate Hetzner Cloud infrastructure using the hcloud CLI tool.

⚠️ Critical Security Requirement

Setup hcloud BEFORE Using Claude Code

You must configure hcloud yourself first. This ensures Claude can only access resources within a dedicated project, making it easy to revoke access when done.

Required Setup Steps:

  1. Create a dedicated Hetzner Cloud project for this work
  2. Generate an API token scoped to only that project
  3. Configure hcloud CLI with the token: hcloud context create my-project
  4. Verify it works: hcloud server list

Why this matters: Claude will use whatever hcloud context is active. By creating a dedicated project, you limit what Claude can access. Delete the project when done to revoke all access.

What You Can Automate

Download CLAUDE.md

Add this file to your cloud automation project to guide Claude Code through Hetzner Cloud tasks.

Download cloud-provisioning.md

Sample Prompts

Try these prompts with Claude Code when using this CLAUDE.md:

Discover Available Options

Show me what server types are available and their pricing. I want something small for testing.

Create Basic Server

Create a small Debian server in Nuremberg, name it 'demo-server', and add a firewall allowing only SSH from my IP

Network Configuration

Create a firewall called 'web-firewall' that allows SSH (22), HTTP (80), and HTTPS (443) from anywhere, and apply it to my server 'demo-server'

Resource Management

List all my servers with their IPs, types, and monthly costs. Then show me how to create labels for better organization.

Cleanup

Find all servers with label 'project:test' and show me the delete commands. Confirm the list before executing.

Tools & Documentation

hcloud CLI Manual

Complete command reference for the hcloud CLI tool.

CLI Manual →

hcloud CLI GitHub

Official Hetzner Cloud command-line interface repository.

GitHub →

Hetzner Cloud Console

Web interface for managing your Hetzner Cloud resources.

Console →

API Documentation

Hetzner Cloud API reference documentation.

API Docs →

Pricing Calculator

Calculate costs for your Hetzner Cloud infrastructure.

Pricing →

Safety Guidelines

  • 🎯 DEDICATED PROJECT - Create separate Hetzner project for testing
  • 💰 START SMALL - Use CX11 or CX22 instances (€4-6/mo)
  • 🏷️ TAG EVERYTHING - Use labels for easy identification
  • 🧹 CLEANUP PROMPTLY - Delete resources when done to avoid charges
  • 📸 SNAPSHOT FIRST - Take snapshots before major changes
  • 💡 DELETE vs STOP - Stopped instances still cost money!