Create DNS record with Terraform for domain managed in Vercel

I am attempting to use a Vercel API token with the Vercel Terraform provider to provision a CNAME DNS record for a subdomain on a domain I own (pointing to a programmatically generated frontend project on DigitalOcean), but I am running into authentication errors. The token has the full scope of permissions for my account that manages the domain. I’ve provided the sample code below. It injects environment variables to be used in different fields, and these variables work properly in other Terraform code. Even when hardcoding those variables, the error persists. Does anyone know what the issue could be?

Current:
Error: Could not create DNS Record, unexpected error: forbidden - You don’t have permission to create the domain record.

Expected:
vercel_dns_record.cname: Creating…
vercel_dns_record.cname: Creation complete after 1s
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

resource "vercel_dns_record" "cname" {
  domain = "endeavor.ai"
  name   = "${var.customer_name}-services"
  type   = "CNAME"
  ttl    = 60
  value  = "${replace(digitalocean_app.terraform-app-services.live_url, "https://", "")}." // Remove https://
}

Hi @ameallion. Assuming the domain already uses Vercel nameservers, I believe you can solve this by including the team_id. That’s required if a default team is not set in the provider. I hope that helps!

1 Like

Thanks Amy, that solved it!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.