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
| Resources | Data sources |
|---|---|
dtcloud_ssh_key | dtcloud_ssh_key |
dtcloud_vm | dtcloud_ssh_keys |
dtcloud_vm_volume_attachment | dtcloud_vm |
dtcloud_vm_network_interface | dtcloud_vms |
dtcloud_network | dtcloud_vm_history |
dtcloud_security_group | dtcloud_vm_history_entry |
dtcloud_security_group_rule | dtcloud_network |
dtcloud_elastic_ip | dtcloud_networks |
dtcloud_volume | dtcloud_security_group |
dtcloud_snapshot | dtcloud_security_groups |
dtcloud_router | dtcloud_my_ip |
dtcloud_router_interface | dtcloud_elastic_ip |
dtcloud_router_static_route | dtcloud_elastic_ips |
dtcloud_lb | dtcloud_volume |
dtcloud_lb_listener | dtcloud_volumes |
dtcloud_lb_pool | dtcloud_volume_snapshots |
dtcloud_lb_member | dtcloud_storage_policies |
dtcloud_lb_health_monitor | dtcloud_snapshot |
dtcloud_lb_balancing_pool | dtcloud_snapshots |
dtcloud_image | dtcloud_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:
-
The
providerblock. Explicit and version-controlled. Never write the secret key as a literal here -- reference avariablewith no default and Terraform will prompt for it, or put it in a gitignoredterraform.tfvars. -
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. -
The configuration file. Anything still unset is read from
config.yamlin this machine's configuration directory:OS Path Linux ~/.config/terraform-provider-dtcloud/config.yamlmacOS ~/Library/Application Support/terraform-provider-dtcloud/config.yamlWindows %AppData%\terraform-provider-dtcloud\config.yamlapi:
access_key: "..."
secret_key: "..."
base_url: https://console.dt.net.tr/api/v1
region_id: 2The 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'sdefault_profile, then todefault.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.