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

Is there a better way to get default_ingress from digitalocean_app? #1207

Closed
bartekpacia opened this issue Sep 8, 2024 · 3 comments · Fixed by #1209
Closed

Is there a better way to get default_ingress from digitalocean_app? #1207

bartekpacia opened this issue Sep 8, 2024 · 3 comments · Fixed by #1209

Comments

@bartekpacia
Copy link

My app has a top-level domain bee-ci.pacia.tech, and I set the zone of my digitalocean_app.app to that that domain (=bee-ci.pacia.tech).

I want for my app to be available at subdomain backend.bee-ci.pacia.tech. For this I create a new digitalocean_record.backend, but to get the ingress address for my app, I have to write this which I think is a bit convoluted:

format("%s.", split("://", digitalocean_app.app.default_ingress)[1])

Is there a better way?

Here's my full main.tf:

resource "digitalocean_project" "project" {
  name        = "bee-ci-proj-tf"
  description = "A simple container-based CI system"
  environment = "Development"
  resources = [
    digitalocean_app.app.urn,
    digitalocean_database_cluster.main-db-cluster.urn,
    digitalocean_domain.main.urn,
  ]
}

resource "digitalocean_app" "app" {
  spec {
    name   = "bee-ci-tf"
    region = "sfo"

    domain {
      name = "backend.bee-ci.pacia.tech"
      type = "PRIMARY"
      zone = digitalocean_domain.main.name
    }
    
    # ...
}

resource "digitalocean_domain" "main" {
  name = "bee-ci.pacia.tech"
}


resource "digitalocean_record" "backend" {
  domain = digitalocean_domain.main.id
  type   = "CNAME"
  name   = "backend"
  value  = format("%s.", split("://", digitalocean_app.app.default_ingress)[1])
  # value  = "bee-ci.pacia.tech." # this is the value I want
}
@andrewsomething
Copy link
Member

Hi @bartekpacia,

The API has actually added a live_domain attribute that should give you exactly what you want. We'll get that added here.

@bartekpacia
Copy link
Author

That's great to hear! Thanks so much! 💙

@alex35mil
Copy link

@andrewsomething I don't think it addresses the issue.

If I set a custom domain as PRIMARY, then live_domain would be the value of this primary domain, not the default one which should be used for CNAME.

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

Successfully merging a pull request may close this issue.

3 participants