By mwisniowski
I’m trying to create a Terraform config that will set up a load balancer with Let’s encrypt’s certificate installed for the particular domain.
The configuration I have resulted in
“Error: Cycle: digitalocean_record.static, digitalocean_certificate.cert, digitalocean_loadbalancer.www-lb”
Is there any other way to handle it?
resource "digitalocean_domain" "default" {
// Note: in reality, the domain name is not "example.com".
name = "example.com"
}
resource "digitalocean_record" "static" {
domain = digitalocean_domain.default.name
type = "A"
name = "static"
value = digitalocean_loadbalancer.www-lb.ip
}
resource "digitalocean_certificate" "cert" {
name = "examplecert"
type = "lets_encrypt"
domains = [digitalocean_record.static.fqdn]
lifecycle {
create_before_destroy = true
}
}
resource "digitalocean_loadbalancer" "www-lb" {
name = "example-lb"
region = var.region
vpc_uuid = digitalocean_vpc.vpc.id
forwarding_rule {
entry_port = 443
entry_protocol = "https"
target_port = 80
target_protocol = "http"
certificate_id = digitalocean_certificate.cert.id
}
healthcheck {
port = 80
protocol = "http"
}
droplet_ids = digitalocean_droplet.www.*.id
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I’ve sorted this out by hardcoding the “static” subdomain name like this:
domains = [“static.${digitalocean_domain.default.id}”]
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.