### Example Usage of hm_os Data Source Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/os.md This example demonstrates how to use the hm_os data source to select an operating system by name and version, and then use its ID to provision a server. It also shows the usage of the hm_configurator data source for server configuration. ```terraform data "hm_configurator" "example-configurator" { location = "us-2" } # Select OS with name = "ubuntu" and version = "22.04" data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } # Usage example of selected OS resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } } ``` -------------------------------- ### Provision Server with Selected Software and OS Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/software.md This example demonstrates how to provision a server using the IDs obtained from the hm_software and hm_presets data sources. Ensure the software and OS are compatible before provisioning. ```terraform resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_software.example-software.os[0].id software_id = data.hm_software.example-software.id preset_id = data.hm_presets.example-preset.id } ``` -------------------------------- ### Create Server with Software Installation Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Deploys a server with specific software pre-installed. Requires defining both 'hm_software' and 'hm_presets' data sources. ```terraform data "hm_software" "example-software" { name = "Docker" os { family = "linux" name = "ubuntu" version = "22.04" } } resource "hm_server" "server-with-software" { name = "Example server with software" preset_id = data.hm_presets.example-preset.id os_id = data.hm_software.example-software.os[0].id software_id = data.hm_software.example-software.id } ``` -------------------------------- ### Create MySQL Database Cluster and Instances Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_user.md This example demonstrates how to select a database preset and then create a MySQL cluster and its instances. Ensure the preset filters are correctly defined for your needs. ```terraform # Select any preset from location = "us-2", 8 Gb disk space with price between 10$ and 50$ for MySQL data "hm_database_preset" "example-db-preset" { location = "us-2" type = "mysql" disk = 8 * 1024 price_filter { from = 100 to = 500 } } # Create example cluster of MySQL resource "hm_database_cluster" "example-mysql-8" { name = "example_mysql_8" type = "mysql" preset_id = data.hm_database_preset.example-db-preset.id } # Create example instance in previously created cluster resource "hm_database_instance" "example-mysql-8-instance" { cluster_id = hm_database_cluster.example-mysql-8.id name = "example" } # Create other example instance in previously created cluster resource "hm_database_instance" "example-mysql-8-other-instance" { cluster_id = hm_database_cluster.example-mysql-8.id name = "otherexample" } # Create some other example instance in previously created cluster resource "hm_database_instance" "example-mysql-8-some-other-instance" { cluster_id = hm_database_cluster.example-mysql-8.id name = "someotherexample" } ``` -------------------------------- ### Create an example VPC network Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/vpc.md Defines a new VPC network with a specified name, description, IPv4 subnet, and location. ```terraform resource "hm_vpc" "example-vpc" { name = "Example VPC" description = "Some example VPC" subnet_v4 = "192.168.0.0/24" location = "us-2" } ``` -------------------------------- ### Create Firewall and Add Rule Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/firewall_rule.md Example demonstrates creating a firewall and then adding an ingress rule to allow TCP traffic on port 80 from any source. ```terraform resource "hm_firewall" "example-firewall" { name = "example-firewall" description = "Some example firewall" } resource "hm_firewall_rule" "example-firewall-rules" { firewall_id = resource.hm_firewall.example-firewall.id description = "Some example firewall rule" direction = "ingress" port = 80 protocol = "tcp" cidr = "0.0.0.0/0" } ``` -------------------------------- ### Import a floating IP Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/floating_ip.md This example shows the command to import an existing floating IP resource into your Terraform state. Replace the example ID with the actual identifier of the floating IP. ```shell terraform import hm_server.example 968769c4-06ac-4b37-8e21-1fc8ff6c5a9b ``` -------------------------------- ### Create a MySQL Database Instance Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_instance.md This example demonstrates how to select a database preset and then create a MySQL database instance within a cluster. Ensure the preset is configured with the desired location, type, disk size, and price range. ```terraform data "hm_database_preset" "example-db-preset" { location = "us-2" type = "mysql" disk = 8 * 1024 price_filter { from = 10 to = 50 } } # Create example cluster of MySQL resource "hm_database_cluster" "example-mysql-8" { name = "example_mysql_8" type = "mysql" preset_id = data.hm_database_preset.example-db-preset.id } # Create example instance in previously created cluster resource "hm_database_instance" "example-mysql-8-instance" { cluster_id = hm_database_cluster.example-mysql-8.id name = "example" } ``` -------------------------------- ### Provision a Server Using a Selected Preset Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/presets.md This example demonstrates how to use the ID of a selected preset (obtained from the `hm_presets` data source) when creating a new server resource. ```terraform resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id } ``` -------------------------------- ### Create a server using a selected configurator Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/configurator.md This example demonstrates how to create a server using the ID obtained from the hm_configurator data source. It also shows how to specify OS details and server configuration parameters like disk, CPU, and RAM. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } # Select any configurator with location = "us-2" data "hm_configurator" "example-configurator" { location = "us-2" } # Usage example of selected configuration resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } } ``` -------------------------------- ### Create a server using a selected project Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/projects.md This example demonstrates how to create a server resource (`hm_server`) and associate it with a project selected via the `hm_projects` data source. Ensure that the `hm_os` and `hm_presets` data sources are also configured correctly. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } # Select project with name = "Example" data "hm_projects" "example-project" { name = "Example" } # Usage example of selected project resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id project_id = data.hm_projects.example-project.id } ``` -------------------------------- ### Create and Use an SSH Key Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/ssh_key.md This example demonstrates how to create a new SSH key resource and then use its ID to associate it with a new server. Ensure the public key file exists at the specified path. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } # Create new SSH key resource "hm_ssh_key" "example-key" { name = "Example" body = file("~/.ssh/some-key.pub") } # Usage example of created SSH key resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id ssh_keys_ids = [hm_ssh_key.example-key.id] } ``` -------------------------------- ### Create and Use hm_project Resource Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/project.md This example demonstrates how to create a new project using the `hm_project` resource and then use its ID to associate a server with it. Ensure `hm_os` and `hm_presets` data sources are configured. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } # Create new Project resource "hm_project" "example-project" { name = "Example" description = "Some example project" } # Usage example of created Project resource "hm_server" "example-project" { name = "Example project" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id project_id = resource.hm_project.example-project.id } ``` -------------------------------- ### Select Database Preset and Create Cluster Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_cluster.md This example demonstrates how to select a database preset based on location, type, disk space, and price, and then use that preset to create a MySQL database cluster with custom configuration parameters. ```terraform data "hm_database_preset" "example-db-preset" { location = "us-2" type = "mysql" disk = 8 * 1024 price_filter { from = 10 to = 50 } } # Create example cluster of MySQL type with auto_increment_increment parameter override resource "hm_database_cluster" "example-mysql-8" { name = "example_mysql_8" type = "mysql" config_parameters = { auto_increment_increment = 3 } preset_id = data.hm_database_preset.example-db-preset.id } ``` -------------------------------- ### Create Database User with All Cluster Privileges Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_user.md This example shows how to create a database user with broad privileges across all instances in a cluster. Ensure the login and password meet security requirements. ```terraform # Create user with access across all cluster instances resource "hm_database_user" "example-mysql-8-user" { cluster_id = hm_database_cluster.example-mysql-8.id login = "admin" password = "examplepassword1" privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "ALTER", "REFERENCES", "CREATE", "DROP", "INDEX"] } ``` -------------------------------- ### Create a floating IP with DDoS Guard Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/floating_ip.md This example demonstrates creating a floating IP with the DDoS Guard feature enabled. Ensure the availability zone is correctly specified. ```terraform resource "hm_floating_ip" "example-floating-ip" { availability_zone = "us-3" ddos_guard = true comment = "Some floating IP with DDoS Guard" } ``` -------------------------------- ### Import hm_project Resource Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/project.md This example shows how to import an existing project into Terraform state using its numeric identifier from the Hostman URL. ```shell # Project can be imported by specifying the numeric identifier from URL terraform import hm_project.example 42 ``` -------------------------------- ### Configure Auto Backup Schedule for Main Disk Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server_disk_backup_schedule.md Example of setting up an automatic backup schedule for the main disk of a server. Ensure the server and its disks are defined before configuring the backup schedule. ```terraform resource "hm_server_disk_backup_schedule" "main-disk-example" { source_server_id = hm_server.example-server.id source_server_disk_id = hm_server.example-server.disks[0].id copy_count = 10 creation_start_at = "2023-02-02T00:00:00.000Z" interval = "month" } ``` -------------------------------- ### Configure Auto Backup Schedule for Additional Disk Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server_disk_backup_schedule.md Example of setting up an automatic backup schedule for an additional disk attached to a server. This configuration requires the server and the specific additional disk to be pre-defined. ```terraform resource "hm_server_disk_backup_schedule" "additional-disk-example" { source_server_id = hm_server.example-server.id source_server_disk_id = hm_server_disk.example-additional-disk.id copy_count = 10 creation_start_at = "2023-02-02T00:00:00.000Z" interval = "month" } ``` -------------------------------- ### Create Database User with Specific Instance Privileges Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_user.md This example demonstrates creating a database user with specific privileges limited to a single cluster instance. The `instance` block must reference a valid `instance_id`. ```terraform # Create user with privileges to one cluster instance resource "hm_database_user" "example-mysql-8-user" { cluster_id = hm_database_cluster.example-mysql-8.id login = "otheruser" password = "examplepassword1" instance { instance_id = hm_database_instance.example-mysql-8-instance.id privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] } } ``` -------------------------------- ### Create Database User with Multiple Instance Privileges Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/database_user.md This example shows how to create a database user with privileges granted to multiple specific cluster instances. Each `instance` block defines the `instance_id` and its associated `privileges`. ```terraform # Create other user with privileges to multiple cluster instances resource "hm_database_user" "example-mysql-8-user" { cluster_id = hm_database_cluster.example-mysql-8.id login = "someotheruser" password = "examplepassword1" instance { instance_id = hm_database_instance.example-mysql-8-instance.id privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] } instance { instance_id = hm_database_instance.example-mysql-8-other-instance.id privileges = ["SELECT", "INSERT", "UPDATE", "DELETE"] } } ``` -------------------------------- ### Use selected SSH key in server creation Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/ssh_keys.md This example demonstrates how to use the ID of a selected SSH key (obtained from the `hm_ssh_keys` data source) when creating a new server resource. It also shows the selection of OS and preset data sources. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } # Select SSH key with name = "Example" data "hm_ssh_keys" "example-key" { name = "Example" } # Usage example of selected SSH key resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id ssh_keys_ids = [data.hm_ssh_keys.example-key.id] } ``` -------------------------------- ### hm_os — Operating System Lookup Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Filters available OS images by family, name, and version. Returns the OS ID and minimum hardware requirements needed to install it. ```APIDOC ## hm_os — Operating System Lookup Filters available OS images by family, name, and version. Returns the OS ID and minimum hardware requirements needed to install it. ### Example ```terraform data "hm_os" "debian" { family = "linux" name = "debian" version = "11" } output "os_id" { value = data.hm_os.debian.id } output "os_codename" { value = data.hm_os.debian.version_codename } # requirements: cpu_min, ram_min, disk_min, bandwidth_min ``` ``` -------------------------------- ### Create a Kubernetes Node Group Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/k8s_node_group.md This example demonstrates how to create a Kubernetes node group within an existing cluster. It first defines a preset for master nodes and then a cluster, followed by a preset for worker nodes and finally the node group itself, specifying the cluster, preset, and node count. ```terraform data "hm_k8s_preset" "example-k8s-preset-master" { cpu = 4 type = "master" } # Create example cluster with selected preset resource "hm_k8s_cluster" "example-k8s-cluster" { name = "example-cluster" description = "some example cluster" high_availability = false version = "v1.22.17" network_driver = "flannel" ingress = true preset_id = data.hm_k8s_preset.example-k8s-preset-master.id } # Select any preset for nodes in group with 2 CPUs data "hm_k8s_preset" "example-k8s-preset-worker" { cpu = 2 type = "worker" } # Create example node group preset in previously created cluster and selected preset with 2 nodes resource "hm_k8s_node_group" "example-k8s-node-group" { cluster_id = resource.hm_k8s_cluster.example-k8s-cluster.id name = "example-k8s-node-group" preset_id = data.hm_k8s_preset.example-k8s-preset-worker.id node_count = 2 } ``` -------------------------------- ### Create Server with Disk Backup Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server_disk_backup.md Demonstrates how to create a server and then back up its main disk and an additional disk. Ensure the server and disk resources are defined before creating backups. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } resource "hm_server" "example-server" { name = "Example server with preset" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id } resource "hm_server_disk" "example-additional-disk" { source_server_id = hm_server.example-server.id size = 1024 * 10 } ### Backup from main server disk resource "hm_server_disk_backup" "example" { source_server_id = hm_server.example-server.id source_server_disk_id = hm_server.example-server.disks[0].id comment = "example with main disk" } ### Backup from additional disk resource resource "hm_server_disk_backup" "example-with-additional-disk" { source_server_id = hm_server_disk.example-disk.source_server_id source_server_disk_id = hm_server_disk.example-additional-disk.id comment = "example with additional disk" } ``` -------------------------------- ### Select Software with Name and OS Compatibility Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/software.md Use this snippet to select software by its name and specify compatible operating system details like name and version. The retrieved software ID and OS ID can be used for server provisioning. ```terraform data "hm_software" "example-software" { name = "Docker" os { name = "ubuntu" version = "22.04" } } ``` -------------------------------- ### hm_software — Pre-installed Software Lookup Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Looks up available server software (e.g., Docker, WordPress) compatible with a given OS. Returns the software ID and the associated OS ID for passing to `hm_server`. ```APIDOC ## hm_software — Pre-installed Software Lookup Looks up available server software (e.g., Docker, WordPress) compatible with a given OS. Returns the software ID and the associated OS ID for passing to `hm_server`. ### Example ```terraform data "hm_software" "docker" { name = "Docker" os { family = "linux" name = "ubuntu" version = "22.04" } } resource "hm_server" "docker_host" { name = "docker-server" preset_id = data.hm_presets.medium.id os_id = data.hm_software.docker.os[0].id software_id = data.hm_software.docker.id } ``` ``` -------------------------------- ### Lookup Pre-installed Software with hm_software Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Looks up available server software compatible with a given OS. Returns the software ID and the associated OS ID for passing to hm_server. ```terraform data "hm_software" "docker" { name = "Docker" os { family = "linux" name = "ubuntu" version = "22.04" } } resource "hm_server" "docker_host" { name = "docker-server" preset_id = data.hm_presets.medium.id os_id = data.hm_software.docker.os[0].id software_id = data.hm_software.docker.id } ``` -------------------------------- ### hm_firewall_rule Resource Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/firewall_rule.md Resource for describing needed firewall rule and provides actual information about its status. This example shows how to add a rule to an existing firewall that allows TCP traffic on port 80 from any source. ```APIDOC ## hm_firewall_rule (Resource) ### Description Resource for describing needed firewall rule and provides actual information about its status. ### Schema #### Required - `direction` (String) Rule direction - `firewall_id` (String) ID of target firewall - `protocol` (String) Rule protocol #### Optional - `cidr` (String) Rule CIDR - `description` (String) Description for firewall - `port` (Number) Port when rule protocol is TCP or UDP #### Read-Only - `id` (String) The ID of this resource. ``` -------------------------------- ### Create Server with Preset Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Provisions a server using a predefined 'preset_id', simplifying configuration. The 'hm_presets' data source must be defined. ```terraform data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } resource "hm_server" "example-server-with-preset" { name = "Example server with preset" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id } ``` -------------------------------- ### Import Server Disk Backup Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server_disk_backup.md Shows how to import an existing server disk backup resource into Terraform state. The import format requires the server ID, server disk ID, and the backup ID, separated by slashes. ```shell # Server disk backup can be imported by specifying the numeric identifier in format SERVER-ID/SERVER-DISK-ID/SERVER-DISK-BACKUP-ID (all parameters from URL) terraform import hm_server_disk_backup.example 42/13/5 ``` -------------------------------- ### hm_server Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates and manages a virtual server (VDS/VPS) with support for custom configurations, software pre-installation, cloning, VPC attachment, and SSH keys. ```APIDOC ## `hm_server` — Virtual Server (VDS/VPS) Creates and manages a virtual server. Supports custom configurations (CPU/RAM/disk via a configurator), fixed presets, software pre-installation, cloning from an existing server, VPC attachment, floating IP, SSH keys, and cloud-init scripts. ```terraform # Look up a hardware configurator for the us-2 region data "hm_configurator" "cfg" { location = "us-2" } # Look up Ubuntu 22.04 data "hm_os" "ubuntu" { name = "ubuntu" version = "22.04" } # Look up an SSH key stored in the account data "hm_ssh_keys" "mykey" { name = "my-laptop" } # Create a VPC for private networking resource "hm_vpc" "net" { name = "prod-network" subnet_v4 = "10.0.0.0/24" location = "us-2" } # Provision the server resource "hm_server" "web" { name = "web-01" os_id = data.hm_os.ubuntu.id ssh_keys_ids = [data.hm_ssh_keys.mykey.id] availability_zone = "us-3" configuration { configurator_id = data.hm_configurator.cfg.id cpu = 2 ram = 2048 # MB disk = 1024 * 40 # 40 GB } local_network { id = hm_vpc.net.id ip = "10.0.0.10" } } # Outputs output "server_ip" { value = hm_server.web.main_ipv4 } output "server_status" { value = hm_server.web.status } # Import an existing server by numeric ID # terraform import hm_server.web 42 ``` ``` -------------------------------- ### Create a basic floating IP Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/floating_ip.md Use this snippet to create a standard floating IP address in a specified availability zone. A comment can be added for identification. ```terraform resource "hm_floating_ip" "example-floating-ip" { availability_zone = "us-3" comment = "Some floating IP" } ``` -------------------------------- ### Create Server Disk Backup Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a manual backup of the primary or an additional server disk. ```terraform resource "hm_server_disk_backup" "snap" { disk_id = hm_server_disk.extra.id comment = "pre-deploy snapshot" } ``` -------------------------------- ### Provision a Virtual Server with Hostman Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates and manages a virtual server with custom configurations, OS, SSH keys, and VPC attachment. Uses data sources to look up hardware configurators, OS images, and SSH keys. ```terraform # Look up a hardware configurator for the us-2 region data "hm_configurator" "cfg" { location = "us-2" } # Look up Ubuntu 22.04 data "hm_os" "ubuntu" { name = "ubuntu" version = "22.04" } # Look up an SSH key stored in the account data "hm_ssh_keys" "mykey" { name = "my-laptop" } # Create a VPC for private networking resource "hm_vpc" "net" { name = "prod-network" subnet_v4 = "10.0.0.0/24" location = "us-2" } # Provision the server resource "hm_server" "web" { name = "web-01" os_id = data.hm_os.ubuntu.id ssh_keys_ids = [data.hm_ssh_keys.mykey.id] availability_zone = "us-3" configuration { configurator_id = data.hm_configurator.cfg.id cpu = 2 ram = 2048 # MB disk = 1024 * 40 # 40 GB } local_network { id = hm_vpc.net.id ip = "10.0.0.10" } } # Outputs output "server_ip" { value = hm_server.web.main_ipv4 } output "server_status" { value = hm_server.web.status } # Import an existing server by numeric ID # terraform import hm_server.web 42 ``` -------------------------------- ### Confirm Terraform Apply Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/README.md When prompted after running `terraform apply`, type 'yes' to confirm and proceed with resource creation. ```text yes ``` -------------------------------- ### Configure Hostman Provider and Create a Server Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/README.md This Terraform configuration sets up the Hostman provider and defines a virtual machine with specific CPU, RAM, disk, and OS configurations. Ensure the HM_TOKEN environment variable is set. ```terraform terraform { required_providers { hm = { source = "hostman-cloud/hostman" } } required_version = ">= 0.13" } data "hm_configurator" "configurator" { location = "us-2" } data "hm_os" "os" { name = "ubuntu" version = "22.04" } resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.os.id configuration { configurator_id = data.hm_configurator.configurator.id disk = 1024 * 25 cpu = 1 ram = 1024 } } ``` -------------------------------- ### hm_server_disk_backup Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a manual backup of the primary or an additional server disk. ```APIDOC ### `hm_server_disk_backup` — Server Disk Backup Creates a manual backup of the primary or an additional server disk. ```terraform resource "hm_server_disk_backup" "snap" { disk_id = hm_server_disk.extra.id comment = "pre-deploy snapshot" } ``` ``` -------------------------------- ### Create Server with Project Association Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Creates a server and associates it with a specific project. Requires a pre-defined 'hm_projects' data source. ```terraform data "hm_projects" "example-project" { name = "Example" } resource "hm_server" "example-server" { name = "Example server with project" os_id = data.hm_os.example-os.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } project_id = data.hm_projects.example-project.id } ``` -------------------------------- ### Create Server with Configurator Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Defines a server with specific hardware configurations using a configurator. Ensure the 'hm_configurator' and 'hm_os' data sources are defined. ```terraform data "hm_configurator" "example-configurator" { location = "us-2" } data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } } ``` -------------------------------- ### Create a load balancer with a VPC network Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/vpc.md Sets up a load balancer, configuring its algorithm, health checks, and SSL settings, then associates it with a VPC network and assigns a specific IP address. ```terraform resource "hm_lb" "example-lb" { name = "example-lb" algo = "roundrobin" is_sticky = false is_use_proxy = false is_ssl = false is_keepalive = false health_check { proto = "http" port = 80 path = "/lala" inter = 10 timeout = 5 fall = 3 rise = 2 } ips = [] preset_id = data.hm_lb_preset.example-lb-preset.id project_id = resource.hm_project.example-project.id local_network { id = hm_vpc.example-vpc.id ip = "192.168.0.20" } } ``` -------------------------------- ### Create a floating IP bound to a server Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/floating_ip.md This snippet shows how to create a floating IP and immediately bind it to an existing server resource. It requires defining the server first, including its OS and configuration details. ```terraform data "hm_configurator" "example-configurator" { location = "us-2" } data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } resource "hm_server" "example-server" { name = "Example server" os_id = data.hm_os.example-os.id availability_zone = "us-3" configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } } resource "hm_floating_ip" "example-floating-ip" { availability_zone = "us-3" comment = "Some floating IP" resource { type = "server" id = hm_server.example-server.id } } ``` -------------------------------- ### hm_project Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a named project for organizing cloud resources. Resources like servers, databases, and S3 buckets can be assigned to a project via their `project_id` argument. ```APIDOC ### `hm_project` — Project (Resource Grouping) Creates a named project for organizing cloud resources. Resources such as servers, databases, and S3 buckets can be assigned to a project via their `project_id` argument. ```terraform resource "hm_project" "prod" { name = "Production" description = "All production workloads" } resource "hm_server" "app" { name = "app-server" os_id = data.hm_os.ubuntu.id preset_id = data.hm_presets.small.id project_id = hm_project.prod.id } output "project_id" { value = hm_project.prod.id } output "project_is_default" { value = hm_project.prod.is_default } # terraform import hm_project.prod 42 ``` ``` -------------------------------- ### Create Additional Disk for Server Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server_disk.md Use this snippet to create an additional disk for an existing server. Ensure the server resource is defined and available. The size is specified in MB. ```terraform data "hm_os" "example-os" { name = "ubuntu" version = "22.04" } data "hm_presets" "example-preset" { price_filter { from = 30 to = 40 } } resource "hm_server" "example-server" { name = "Example server with preset" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id } # Create additional disk for server with 10 Gb size resource "hm_server_disk" "example" { source_server_id = hm_server.example-server.id size = 1024 * 10 } ``` -------------------------------- ### Create Hostman Project Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a named project for organizing cloud resources. Resources can be assigned to a project via their `project_id` argument. ```terraform resource "hm_project" "prod" { name = "Production" description = "All production workloads" } resource "hm_server" "app" { name = "app-server" os_id = data.hm_os.ubuntu.id preset_id = data.hm_presets.small.id project_id = hm_project.prod.id } output "project_id" { value = hm_project.prod.id } output "project_is_default" { value = hm_project.prod.is_default } # terraform import hm_project.prod 42 ``` -------------------------------- ### Create a server with a VPC network Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/vpc.md Provisions a server and attaches it to an existing VPC network using its ID. Optionally assigns a specific IP address within the VPC subnet. ```terraform resource "hm_server" "example-server-with-local-network" { name = "Example server with local network" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id local_network { id = hm_vpc.example-vpc.id } } ``` ```terraform resource "hm_server" "example-server-with-local-network-and-address" { name = "Example server with local network and address" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id local_network { id = hm_vpc.example-vpc.id ip = "192.168.0.15" } } ``` -------------------------------- ### Clone Existing Server Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Creates a new server by cloning an existing one, using its 'source_server_id'. Configuration details can be overridden. ```terraform resource "hm_server" "cloned-server-example" { name = "Example of cloned server" source_server_id = hm_server.example-server.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 5 * 4 cpu = 1 ram = 1024 } } ``` -------------------------------- ### Select Load Balancer Preset by RPS and Price Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/lb_preset.md Use this data source to select a load balancer preset that meets specific performance and cost requirements. It filters presets based on maximum requests per second and a defined price range. ```terraform data "hm_lb_preset" "example-lb-preset" { requests_per_second = "10K" price_filter { from = 10 to = 20 } } ``` -------------------------------- ### Create Server with VPC Network and Specific IP Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/server.md Assigns a server to a VPC network and specifies a static IP address within that network. Ensure the 'hm_vpc' resource is defined. ```terraform # With VPC network and specified ID IP resource "hm_server" "example-server-with-local-network-and-address" { name = "Example server with local network and address" os_id = data.hm_os.example-os.id preset_id = data.hm_presets.example-preset.id local_network { id = hm_vpc.example-vpc.id ip = "192.168.0.15" } } ``` -------------------------------- ### Create a Kubernetes Cluster Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/k8s_cluster.md Use this snippet to create a new Kubernetes cluster. It requires selecting a preset for the master node and defining cluster-level configurations like name, version, and network driver. Ensure a suitable preset is available before applying. ```terraform # Select any preset for master node with 4 CPUs data "hm_k8s_preset" "example-k8s-preset-master" { cpu = 4 type = "master" } # Create example cluster with selected preset resource "hm_k8s_cluster" "example-k8s-cluster" { name = "example-cluster" description = "some example cluster" high_availability = false version = "v1.22.17" network_driver = "flannel" ingress = true preset_id = data.hm_k8s_preset.example-k8s-preset-master.id } ``` -------------------------------- ### Create an S3 Bucket Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a public or private S3-compatible object storage bucket. Requires specifying a preset for location and disk size. Outputs access credentials and hostname. ```terraform data "hm_s3_preset" "preset" { location = "us-2" disk = 10 * 1024 # 10 GB price_filter { from = 5 to = 15 } } resource "hm_s3_bucket" "assets" { name = "my-assets-bucket" type = "public" # or "private" preset_id = data.hm_s3_preset.preset.id } output "s3_hostname" { value = hm_s3_bucket.assets.hostname } output "s3_access_key" { value = hm_s3_bucket.assets.access_key sensitive = true } output "s3_secret_key" { value = hm_s3_bucket.assets.secret_key sensitive = true } ``` -------------------------------- ### Configure Terraform Provider Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/README.md Add this block to your main.tf file to specify the Hostman provider and its source. The provider only supports Terraform versions 0.13 and above. ```hcl terraform { required_providers { hm = { source = "hostman-cloud/hostman" } } required_version = ">= 0.13" } ``` -------------------------------- ### Create Load Balancer Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/lb.md Define a new load balancer using the `hm_lb` resource. Configure essential parameters like name, algorithm, sticky sessions, proxy protocol, SSL, keep-alive, health checks, and associate it with a preset and project. ```terraform resource "hm_lb" "example-lb" { name = "example-lb" algo = "roundrobin" is_sticky = false is_use_proxy = false is_ssl = false is_keepalive = false health_check { proto = "http" port = 80 path = "/lala" inter = 10 timeout = 5 fall = 3 rise = 2 } ips = [] preset_id = data.hm_lb_preset.example-lb-preset.id project_id = resource.hm_project.example-project.id } ``` -------------------------------- ### Provision Load Balancer Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Sets up a managed load balancer with specified balancing algorithm, health checks, and session stickiness. ```terraform data "hm_lb_preset" "lb_preset" { requests_per_second = "10K" price_filter { from = 10 to = 20 } } resource "hm_lb" "app_lb" { name = "app-loadbalancer" preset_id = data.hm_lb_preset.lb_preset.id algo = "roundrobin" # roundrobin | leastconn is_sticky = true is_ssl = true is_keepalive = true is_use_proxy = false ips = [hm_server.web.main_ipv4] health_check { proto = "http" port = 80 path = "/healthz" inter = 10 timeout = 5 fall = 3 rise = 2 } } output "lb_ip" { value = hm_lb.app_lb.ip } output "lb_status" { value = hm_lb.app_lb.status } ``` -------------------------------- ### Create a Private S3 Bucket Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/s3_bucket.md Defines a private S3 bucket using a preset. Ensure the preset is defined with location, disk space, and price constraints. ```terraform data "hm_s3_preset" "example-s3-preset" { location = "us-2" disk = 10 * 1024 price_filter { from = 5 to = 10 } } # Example private S3 bucket resource "hm_s3_bucket" "example-s3-bucket" { name = "example-s3-bucket" type = "private" preset_id = data.hm_s3_preset.example-s3-preset.id } ``` -------------------------------- ### hm_s3_bucket Source: https://context7.com/hostman-cloud/terraform-provider-hostman/llms.txt Creates a private or public S3-compatible object storage bucket. Returns access credentials and the S3 hostname. ```APIDOC ## hm_s3_bucket — Object Storage Bucket Creates a private or public S3-compatible object storage bucket. Returns access credentials (`access_key`, `secret_key`) and the S3 `hostname` for use with any S3-compatible client. ### Resource `hm_s3_bucket` ### Arguments * `name` (string) - Required - The name of the S3 bucket. * `type` (string) - Required - The type of the bucket, either `"public"` or `"private"`. * `preset_id` (string) - Required - The ID of the S3 preset to use for the bucket. ### Attributes * `hostname` (string) - The hostname of the S3 bucket. * `access_key` (string, sensitive) - The access key for the S3 bucket. * `secret_key` (string, sensitive) - The secret key for the S3 bucket. ``` -------------------------------- ### Importing hm_floating_ip Resource Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/floating_ip.md Instructions on how to import an existing hm_floating_ip resource into your Terraform state. ```APIDOC ## Import Import is supported using the following syntax: ```shell # Floating IP can be imported by specifying the identifier (from URL) terraform import hm_server.example 968769c4-06ac-4b37-8e21-1fc8ff6c5a9b ``` ``` -------------------------------- ### hm_project Resource Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/resources/project.md Resource for describing project. This resource allows you to create and manage projects within Hostman. It includes fields for the project's name and description. ```APIDOC ## hm_project (Resource) ### Description Resource for describing project. ### Schema #### Required - `name` (String) Name for project #### Optional - `description` (String) Description for project #### Read-Only - `id` (String) The ID of this resource. - `is_default` (Boolean) Logical value indicating that new resources will be created under this project ### Import Import is supported using the following syntax: ```shell # Project can be imported by specifying the numeric identifier from URL terraform import hm_project.example 42 ``` ``` -------------------------------- ### Select project by name Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/projects.md Use the `hm_projects` data source to select a project by its name. This is useful when you need to reference a specific project in your infrastructure configuration. ```terraform data "hm_projects" "example-project" { name = "Example" } ``` -------------------------------- ### Select image with name and version Source: https://github.com/hostman-cloud/terraform-provider-hostman/blob/main/docs/data-sources/image.md Use the hm_image data source to select an image by its name and version. The 'id' attribute of the selected image can then be used to provision a server. ```terraform data "hm_configurator" "example-configurator" { location = "us-2" } # Select image with name = "ubuntu" and version = "22.04" data "hm_image" "example-image" { name = "Ubuntu 22.04" } # Usage example of selected OS resource "hm_server" "example-server" { name = "Example server" image_id = data.hm_image.example-image.id configuration { configurator_id = data.hm_configurator.example-configurator.id disk = 1024 * 10 cpu = 1 ram = 1024 } } ```