Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow the vercel_project_domain resource to output the required IP and CNAME addresses #92

Closed
Inlustra opened this issue Nov 18, 2022 · 4 comments

Comments

@Inlustra
Copy link

Inlustra commented Nov 18, 2022

As mentioned in the title, I'd really love to be able to use vercel and google managed zones together.
I'm currently doing it manually, however it would be really awesome if the vercel_project_domain could output the required targets.

This would automate a little more of my workflow, what is currently hardcoded:

Note that I haven't even worked out how to add the IP address which can potentially change based on the domain?

resource "google_dns_record_set" "app" {
  name = data.google_dns_managed_zone.app.dns_name
  type = "CNAME"
  ttl  = 300

  managed_zone = data.google_dns_managed_zone.app.name

  rrdatas = ["cname.vercel-dns.com"]
}

could become

resource "vercel_project_domain" "app" {
  project_id = data.vercel_project.app.id
  domain     = data.google_dns_managed_zone.app.dns_name
  git_branch = var.env_git_branch
}

resource "google_dns_record_set" "cname" {
  name = data.google_dns_managed_zone.app.dns_name
  type = "CNAME"
  ttl  = 300

  managed_zone = data.google_dns_managed_zone.app.name

  rrdatas = [vercel_project_domain.app.cname.target]
}

resource "google_dns_record_set" "a" {
  name = data.google_dns_managed_zone.app.dns_name
  type = "A"
  ttl  = 300

  managed_zone = data.google_dns_managed_zone.app.name

  rrdatas = [vercel_project_domain.app.a.target]
}
@yourbuddyconner
Copy link

I was looking into this, and while I initially thought the "hardcode a CNAME to cname.vercel-dns.com" approach was sub-optimal, I am coming around to the fact that this is actually hugely convenient if and only if you are setting up subdomains.

For subdomains (assuming you have already set up and verified your root domain via a TXT record):

  1. Deploy vercel_project_domain resource
  2. Deploy CNAME record in external DNS for subdomain hardcoded to cname.vercel-dns.com
  3. it "just works"

This becomes kind of a headache however if you are setting up a root domain via external DNS for the first time however, because you need to first verify it with a TXT record, and then set up an A record pointed at a specific IP address.

For anyone else looking at this and needing to do the latter, you could opt to deploy the domain with terraform, and then follow with another PR to my terraform that hard-codes the values the UI gave me. Annoying, but would probably work.

I ended up manually setting up my root domain in the UI, and can use the above mentioned approach for subdomains without any more manual config.

@dglsparsons
Copy link
Collaborator

Hey @yourbuddyconner, r.e. hard-coding the CNAME to cname.vercel-dns.com, I think this is fine. The alternative you've suggested would just be to hardcode it in the terraform provider, which is not really any different :D.

For IP address, I'm not totally following what you mean.

@mglagola
Copy link
Member

Hard coding is fine 👍. As for which IP to use, you can hard code 76.76.21.21

@yourbuddyconner
Copy link

Awesome, as long as the IP address doesn't change then this is super smoove!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants