Archived
Live Safe DNS Record Example
This example is an opt-in live test for writable Dynu provider functionality.
It creates exactly one disposable DNS A record under a user-supplied Dynu root domain,
then you remove it with terraform destroy.
Safety model
- Creates a new unique subdomain every run using
random_id. - Hostname format is:
<test_prefix>-<random_hex>.<dynu_root_domain>
- Creates exactly one record:
Arecord, default content198.51.100.10, default TTL300.
- Does not import, update, replace, or delete existing production hostnames/records.
terraform destroyremoves only the disposable record in this state.
Warning
Do not repurpose this example to target existing production subdomains. Always provide only a root Dynu-managed domain (for example,
example.com) viadynu_root_domain.
Prerequisites
- Local provider binary and Terraform
dev_overridesset up fordynu/dynu. DYNU_API_KEYexported (or setdynu_api_keyinterraform.tfvars).- A Dynu-managed root domain you control.
Workflow
go build -o terraform-provider-dynu
cd examples/live_safe_dns_record
cp terraform.tfvars.example terraform.tfvars
# edit terraform.tfvars and set only dynu_root_domain
terraform validate
terraform plan
terraform apply
After apply, inspect outputs to confirm the generated disposable hostname and record ID, then clean up:
terraform destroy
Cleanup guidance
- Always run
terraform destroyafter testing. - If apply is interrupted or partially succeeds, rerun
terraform destroyfrom this same directory with the sameterraform.tfvarsand state files. - If re-running without destroying first, Terraform may keep state for the previous disposable record until it is destroyed.