Skip to main content

dtcloud Provider

Manage DT Cloud (CMP) resources with Terraform: describe the infrastructure you want in a configuration file, run terraform apply, and the provider makes the platform match it.

The provider talks to the DT Cloud API through the dt-go SDK -- the same SDK behind the dtctl command-line tool, so both tools see the same API and behave the same way.

What this provider manages​

ResourcesData sources
dtcloud_ssh_keydtcloud_ssh_key
dtcloud_vmdtcloud_ssh_keys
dtcloud_vm_volume_attachmentdtcloud_vm
dtcloud_vm_network_interfacedtcloud_vms
dtcloud_networkdtcloud_vm_history
dtcloud_security_groupdtcloud_vm_history_entry
dtcloud_security_group_ruledtcloud_network
dtcloud_elastic_ipdtcloud_networks
dtcloud_volumedtcloud_security_group
dtcloud_snapshotdtcloud_security_groups
dtcloud_routerdtcloud_my_ip
dtcloud_router_interfacedtcloud_elastic_ip
dtcloud_router_static_routedtcloud_elastic_ips
dtcloud_lbdtcloud_volume
dtcloud_lb_listenerdtcloud_volumes
dtcloud_lb_pooldtcloud_volume_snapshots
dtcloud_lb_memberdtcloud_storage_policies
dtcloud_lb_health_monitordtcloud_snapshot
dtcloud_lb_balancing_pooldtcloud_snapshots
dtcloud_imagedtcloud_router
dtcloud_routers
dtcloud_router_interfaces
dtcloud_router_static_routes
dtcloud_lb
dtcloud_lbs
dtcloud_lb_vms
dtcloud_lb_flavors
dtcloud_image
dtcloud_images
dtcloud_image_versions
dtcloud_flavors
dtcloud_regions
dtcloud_projects
dtcloud_project_quotas
dtcloud_project_limits

Every page carries its own examples, behaviour notes and import instructions.

Example Usage​

terraform {
required_providers {
dtcloud = {
source = "dtcloudnow/dtcloud"
version = "~> 26.0.0"
}
}
}

# Terraform asks for every variable that has no default and no value yet. Put the
# values in a terraform.tfvars you do not commit, or use the DTCLOUD_* environment
# variables instead. The endpoint defaults to production; set it for any other
# environment.
variable "dtcloud_access_key" {
type = string
}

variable "dtcloud_secret_key" {
type = string
sensitive = true
}

variable "dtcloud_region_id" {
type = string
}

variable "dtcloud_api_url" {
type = string
default = "https://console.dt.net.tr/api/v1"
}

provider "dtcloud" {
access_key = var.dtcloud_access_key
secret_key = var.dtcloud_secret_key
region_id = var.dtcloud_region_id
api_endpoint = var.dtcloud_api_url
}

Authentication​

Every request carries an access key and a secret key, and is scoped to one region. The provider takes each of access_key, secret_key, api_endpoint and region_id from the first source that supplies it:

  1. The provider block. Explicit and version-controlled. Never write the secret key as a literal here -- reference a variable with no default and Terraform will prompt for it, or put it in a gitignored terraform.tfvars.

  2. Environment variables -- DTCLOUD_ACCESS_KEY, DTCLOUD_SECRET_KEY, DTCLOUD_API_URL, DTCLOUD_REGION_ID. The right answer in CI: they override the configuration file, so a build agent never silently inherits a developer's account.

  3. The configuration file. Anything still unset is read from config.yaml in this machine's configuration directory:

    OSPath
    Linux~/.config/terraform-provider-dtcloud/config.yaml
    macOS~/Library/Application Support/terraform-provider-dtcloud/config.yaml
    Windows%AppData%\terraform-provider-dtcloud\config.yaml
    api:
    access_key: "..."
    secret_key: "..."
    base_url: https://console.dt.net.tr/api/v1
    region_id: 2

    The file holds a secret key, so it must be owner-readable only. The provider tightens a too-permissive file at its own default path and warns about one elsewhere.

The provider binary doubles as its own setup command: terraform-provider-dtcloud configure prompts for the access key, secret key and region, verifies them against the API before saving, and writes the file with the right permissions. -profile prod writes a second account, selectable with the profile argument or DTCLOUD_PROFILE.

Schema​

Optional​

  • access_key (String) API access key, sent as the x-api-access-key header.
  • api_endpoint (String) Base URL of the DT Cloud API, ending in /api/v1. Required: it decides which environment resources are created in, and the provider will not guess. Can come from DTCLOUD_API_URL or the configuration file instead.
  • config_file (String) Path to the configuration file. Defaults to config.yaml in this machine's configuration directory, under terraform-provider-dtcloud.
  • profile (String) Which account in the configuration file to use. Defaults to the file's default_profile, then to default.
  • region_id (String) Region / server id, sent as the serverId query parameter on every request.
  • secret_key (String, Sensitive) API secret key, sent as the x-api-secret-key header.