Hello team, it seems that we can’t use Terraform to set a domain correctly since we can’t restart an application after a domain is added
Terraform example
# ....
# create and deploy app with custom domain
resource "qovery_application" "backend" {
environment_id = qovery_environment.production.id
name = "backend"
cpu = 500
memory = 256
state = "RUNNING"
git_repository = {
url = "https://github.com/evoxmusic/ShortMe-URL-Shortener.git"
branch = "main"
root_path = "/"
}
build_mode = "DOCKER"
dockerfile_path = "Dockerfile"
min_running_instances = 1
max_running_instances = 1
custom_domains = [
{
domain = var.qovery_custom_domain
}
]
ports = [
{
internal_port = 5555
external_port = 443
protocol = "HTTP"
publicly_accessible = true
}
]
environment_variables = [
{
key = "DEBUG"
value = "false"
}
]
depends_on = [
qovery_environment.production,
]
}
# create custom domain record
resource "cloudflare_record" "foobar" {
zone_id = var.cloudflare_zone_id
name = var.cloudflare_record_name
value = one(qovery_application.backend.custom_domains[*].validation_domain)
type = "CNAME"
ttl = 3600
}
- Create the application with a custom domain, but the resource needs to be created to have access to the validation_domain
- The validation_domain is used to create a Cloudflare record
- But to apply this change, I need to restart the application
It’s okay with the web UI, but with Terraform, it does not work since the application’s state has not actually changed.
Potential solutions
I see 2 potential solutions that are not mutually exclusive:
- Supporting Wildcard domain
- Supporting dynamic domain change when a domain is added/changed.