CloudNexus Terraform Provider v2.4.1 Stable

Provision and manage CloudNexus cloud infrastructure using Terraform. Deploy VPS instances, databases, CDN edge networks, and Kubernetes clusters declaratively.

ℹ️
Note: This provider requires Terraform >= 1.3.0 and CloudNexus API v2. Minimum permissions: cloudnexus:admin or cloudnexus:developer role.

Installation

Add the CloudNexus provider to your Terraform configuration:

terraform.tf
# Terraform 0.13+
terraform {
  required_providers {
    cloudnexus = {
      source  = "cloudnexus/cloudnexus"
      version = ">= 2.4.0"
    }
  }
}

Initialize your Terraform working directory:

bash
terraform init

Authentication

The provider authenticates using API keys generated from the CloudNexus Dashboard. You can configure credentials via environment variables or inline configuration.

Environment Variables (Recommended)

bash
export CLOUDNEXUS_API_KEY="cnk_prod_xxxxxxxxxxxxxxxxxxxx"
export CLOUDNEXUS_API_SECRET="cns_sec_xxxxxxxxxxxxxxxxxxxx"
export CLOUDNEXUS_REGION="us-east-1"

Inline Configuration

⚠️
Warning: Never commit hardcoded credentials to version control. Use tfvars files or secret management tools.
main.tf
provider "cloudnexus" {
  api_key     = var.cloudnexus_api_key
  api_secret  = var.cloudnexus_api_secret
  region      = "us-east-1"
  project_id  = "proj_8f92a1"
}

Provider Configuration Reference

Argument Description Type Required
api_key CloudNexus API public key string Yes (or env var)
api_secret CloudNexus API private secret string Yes (or env var)
region Default deployment region string Optional
project_id Target project/workspace ID string Optional
timeout API request timeout (seconds) number Default: 60

Quick Example: Deploy VPS + Database

main.tf
resource "cloudnexus_vps" "app_server" {
  name      = "production-app"
  plan      = "cn-pro-8"
  image     = "ubuntu-22.04-lts"
  region    = "us-east-1"
  firewall  = true

  user_data = file("./bootstrap.sh")
}

resource "cloudnexus_database" "primary_db" {
  name        = "app-database"
  engine      = "postgres-15"
  plan        = "db-standard-4"
  region      = "us-east-1"
  backup_retention = 7

  vpc_peering = cloudnexus_vps.app_server.vpc_id
}

output "app_endpoint" {
  value = cloudnexus_vps.app_server.public_ip
}

output "db_connection_string" {
  value     = cloudnexus_database.primary_db.connection_uri
  sensitive = true
}

Available Resources

ResourceDescription
cloudnexus_vpsProvision virtual private servers with custom OS images and networking
cloudnexus_databaseManaged PostgreSQL, MySQL, Redis, and MongoDB clusters
cloudnexus_cdnConfigure edge caching, SSL, and custom domains
cloudnexus_k8s_clusterManaged Kubernetes with auto-scaling and multi-AZ support
cloudnexus_object_storageS3-compatible buckets with lifecycle policies
cloudnexus_firewallStateful firewall rules and security groups

Data Sources

Data SourceDescription
cloudnexus_regionsList available deployment regions and latency metrics
cloudnexus_vps_plansAvailable VPS tiers, pricing, and specs
cloudnexus_db_enginesSupported database versions and compatibility matrix
cloudnexus_imagesPre-built OS and application images

Contributing & Support

Found a bug or have a feature request? Open an issue on our GitHub repository. For enterprise support, contact sales@cloudnexus.dev.