Hetzner Cloud Provider
This repository contains the source code that implements the Hetzner cloud provider for the Yolo CLI.
yolo hetzner --context production --region fsn1 init yolo-sh/api
Usage
To begin, create your first environment using the command:
yolo hetzner init <repository>
Once initialized, you may want to connect it using the command:
yolo hetzner edit <repository>
If you don't plan to use this environment again, you could remove it using the command:
yolo hetzner remove <repository>
<repository> may be relative to your personal GitHub account (eg: cli) or fully qualified (eg: my-organization/api).
Usage:
yolo hetzner [command]
Examples:
yolo hetzner init yolo-sh/api --instance-type cx11
yolo hetzner edit yolo-sh/api
yolo hetzner remove yolo-sh/api
Available Commands:
close-port Close a port in an environment
edit Connect your editor to an environment
init Initialize a new environment
open-port Open a port in an environment
remove Remove an environment
uninstall Uninstall Yolo from your Hetzner account
Flags:
--context string the configuration context to use to access your Hetzner account
-h, --help help for hetzner
--region string the region to use to access your Hetzner account
Use "yolo hetzner [command] --help" for more information about a command.
Authentication
In order to access your Hetzner account, the Yolo CLI will first look for credentials in the following environment variables:
-
HCLOUD_TOKEN
-
HCLOUD_REGION
Otherwise, the configuration files created by the Hetzner CLI (via hcloud context create
) will be used.
–context
If you have configured the Hetzner CLI with multiple configuration contexts, you could tell Yolo which one to use via the --context
flag:
yolo hetzner --context production init yolo-sh/api
By default, Yolo will use the active context.
–region
If you want to overwrite the region resolved by the Yolo CLI, you could use the --region
flag:
yolo hetzner --region fsn1 init yolo-sh/api
yolo hetzner --context production --region fsn1 init yolo-sh/api
Permissions
Your API token needs to have Read & Write
permissions. (See the next sections to learn more about the actions that will be done on your behalf).
Authorized instance types
To be used with Yolo, the chosen instance must be a cloud instance.
Examples
cx11, cpx31, cx51...
Infrastructure lifecycle
The schema above describe all the components that may be created in your Hetzner account. The next sections will describe their lifetime according to your use of the Yolo CLI.
Init
The first time Yolo is used in a region
yolo hetzner init yolo-sh/api --instance-type cx11
When running the init
command for the first time in a region, the following components will be created:
-
A
network
namedyolo-network
with an IPv4 CIDR block equals to10.0.0.0/16
to isolate your infrastructure. -
A
subnet
with an IPv4 CIDR block equals to10.0.0.0/24
that will contain your environments’ instances.
On each init
When running the init
command, the following components will be created:
-
A
firewall
namedyolo-${ENV_NAME}-firewall
to let your environment acceptsSSH
connections on port2200
. -
An
SSH key
namedyolo-${ENV_NAME}-ssh-key
to let you access your environment viaSSH
. -
A
server
namedyolo-${ENV_NAME}-server
with a type equals to the one passed via the--instance-type
flag orcx11
by default.
Edit
yolo hetzner edit yolo-sh/api
When running the edit
command, nothing will be done to your infrastructure.
Open port
yolo hetzner open-port yolo-sh/api 8080
When running the open-port
command, an inbound
rule will be added to the firewall
of the environment.
This rule will allow all TCP
trafic from any IP address
to the specified port.
Close port
yolo hetzner close-port yolo-sh/api 8080
When running the close-port
command, the inbound
rule added by the open-port
command will be removed.
Remove
yolo hetzner remove yolo-sh/api
When running the remove
command, all the components associated with the environment will be removed.
In other words:
-
The
server
. -
The
SSH key
. -
The
firewall
.
Uninstall
yolo hetzner uninstall
When running the uninstall
command, all the shared components will be removed.
In other words:
-
The
network
. -
The
subnet
.
Infrastructure costs
The cost of running an environment on Hetzner is equal to the cost of the server
used.
License
Yolo is available as open source under the terms of the MIT License.