From f01f2a84b653e1b80f78cbdafbece663824be376 Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:59:06 +0530 Subject: [PATCH] tf modules docs --- content/docs/overview/terraform.md | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/content/docs/overview/terraform.md b/content/docs/overview/terraform.md index b340678..ca976ae 100644 --- a/content/docs/overview/terraform.md +++ b/content/docs/overview/terraform.md @@ -68,6 +68,55 @@ As some examples, you can do all of the following with Terraform: - Create [private networks](../networking/private-networks.md) - Manage [virtual machine instances](../compute/create-an-instance.md) + +## Configuring Modules + +Terraform modules allow you to group resources and reuse configurations efficiently. Below are examples of how to configure modules with the Civo provider. + +### Example Module Usage + +To use a module with the Civo provider, create a module directory and define your infrastructure in it. + +**Module Definition** (`modules/civo-instance/main.tf`) + +``` +variable "region" {} +variable "instance_size" {} +provider "civo" { + region = var.region +} +resource "civo_instance" "example" { + hostname = "example-instance" + size = var.instance_size + region = var.region +} +``` +**Root Module** (`main.tf`) +``` +module "civo_instance" { + source = "./modules/civo-instance" + region = "LON1" + instance_size = "g3.small" +} +``` + +This approach helps in managing infrastructure more efficiently by keeping configurations modular and reusable. +**Please note since this is a non-hashicorp maintained provider, every module should have its own provider block.** +Reference: [Terraform Modules](https://developer.hashicorp.com/terraform/language/providers/requirements) + +## Argument Reference + +### Optional + +`api_endpoint` (String) The Base URL to use for CIVO API. + +`region` (String) This sets the default region for all resources. If no default region is set, you will need to specify individually in every resource. + + +`credentials_file` (string) Specify a location for a file containing your Civo credentials token. + +`token` (String) (Deprecated) For legacy reasons, the user can still specify the token as an input, but in order to avoid storing that in Terraform state, we have deprecated this and will remove it in future versions—don't use it. + ## Upgrading the Terraform provider If you see that your Terraform provider version is behind the [latest Civo provider release](https://registry.terraform.io/providers/civo/civo/latest), you can upgrade your project as follows: