> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aviatrix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure the Aviatrix Cloud Terraform Provider

> Set up the aviatrixsystems/avxcloud Terraform provider and initialize Terraform for use with Aviatrix PaaS.

This guide covers Terraform provider configuration for Aviatrix Cloud: creating
your first Terraform files and initializing the provider.

The `avxcloud` Terraform provider for Aviatrix Cloud is available on the
[AviatrixSystems Terraform Namespace](https://registry.terraform.io/namespaces/AviatrixSystems).

## Prerequisites

Before you use the provider, confirm the following:

* You have an active
  [**Aviatrix Cloud account**](/docs/cloud/platform-administration/overview/subscription-plan-options)
  with a Fabric.
* You have an
  [**API access key**](/docs/cloud/platform-administration/terraform/terraform-overview#create-api-access-keys-from-the-aviatrix-cloud-console)
  for your Aviatrix Cloud account.
* Your workstation can reach `https://api.cloud.aviatrix.com` and the
  [Terraform Registry](https://registry.terraform.io/).
* [Terraform](https://developer.hashicorp.com/terraform/install) 1.0 or later is
  installed.

## Step 1: Create Configuration Files

You can create a single .tf file to manage your entire Terraform configuration,
or you can create multiple .tf files to manage your resources in a more modular
way. Splitting the configuration across files keeps your project readable as it
grows.

In a new working directory, create the following files:

```text theme={null}
aviatrix-cloud-terraform/
├── providers.tf      # Terraform settings and aviatrixsystems/avxcloud provider
├── variables.tf      # Input variables for resource parameters
├── main.tf           # Terraform code to manage resources
├── outputs.tf        # Optional values to print after apply
└── terraform.tfvars  # Confidential input variables
```

<Note>
  Consider tracking your Terraform configuration files (except
  `terraform.tfvars`) in a version control system. Do not store confidential
  input variables in your `.tf` files.
</Note>

## Step 2: Supply Credentials

In `variables.tf`, define the API access key as a sensitive variable:

```hcl theme={null}
variable "api_access_key" {
  description = "API access key for your Aviatrix Cloud account."
  type        = string
  sensitive   = true # This ensures the value is not stored in the Terraform state file.
}
```

In `terraform.tfvars`, declare the API access key for the provider:

```hcl theme={null}
api_access_key = "your-api-access-key"
```

<Info>
  You can also set input variables with environment variables (for example,
  `TF_VAR_*`), command-line flags, and other assignment methods described in the
  HashiCorp Terraform documentation on [Use
  Variables](https://developer.hashicorp.com/terraform/language/values/variables#assigning-values-to-root-module-variables).
</Info>

<Warning>
  Treat the API access key like a password. Do not commit credentials in
  `terraform.tfvars` or any other file in version control. For shared or CI/CD
  pipelines, supply the key from a secrets manager.
</Warning>

## Step 3: Configure the Provider

In `providers.tf`, add a `terraform` block to declare the provider source and a
`provider "avxcloud"` block to pass your API access key:

```hcl theme={null}
terraform {
  required_version = ">= 1.0"

  required_providers {
    avxcloud = {
      source  = "aviatrixsystems/avxcloud"
      version = "~> 0.1.0"
    }
  }
}

provider "avxcloud" {
  api_access_key = var.api_access_key
}
```

<Note>
  The example uses `~> 0.1.0` as a version constraint. Check the
  [Terraform Registry](https://registry.terraform.io/providers/AviatrixSystems/avxcloud/latest)
  for the current version before pinning or upgrading.
</Note>

## Step 4: Initialize Terraform

Open a terminal window and navigate to your working directory.

Run the `terraform init` command to download the `aviatrixsystems/avxcloud`
provider from the public registry.

```bash theme={null}
terraform init
```

A success message displays: **Terraform has been successfully initialized!**

## Troubleshooting

| Symptom | Resolution |
| - | - |
| `terraform init` cannot find or download the provider | Confirm the `source` is `aviatrixsystems/avxcloud` and that your workstation can reach the public Terraform Registry. |
| Authentication fails or the API access key is rejected | Confirm `api_access_key` is set and current. API access keys can expire — regenerate the key in the Aviatrix Cloud console and update your `terraform.tfvars` or environment variable. |
| Cannot reach `https://api.cloud.aviatrix.com` | Check connectivity, proxy, and firewall rules from the machine running Terraform. |
| TLS or certificate errors | Do not disable TLS. `insecure_tls = true` should never be needed against the Aviatrix Cloud endpoint. Contact Aviatrix support to resolve the certificate issue. |

For provider errors, TLS problems, or other production issues you cannot
resolve, contact Aviatrix support.

## Next Steps

Continue to
[Onboard Cloud Accounts to Aviatrix Cloud with Terraform](/docs/cloud/platform-administration/terraform/terraform-cloud-account)
to onboard your first cloud account.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.