Skip to content

tf modules docs #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions content/docs/overview/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down