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

Add -static suffix option to digitalocean_cdn for Spaces static website support #1241

Open
jahwag opened this issue Oct 6, 2024 · 0 comments
Labels
do-api Depends on changes to the DigitalOcean API

Comments

@jahwag
Copy link

jahwag commented Oct 6, 2024

Problem Description

The DigitalOcean provider CDN option should support configurations using website.json. The digitalocean_cdn resource in Terraform currently generates a CNAME record with the value as [bucket-name].[region].cdn.digitaloceanspaces.com.

However, to enable automatic serving of index pages (e.g., index.html defined in website.json), instructions state the need to append -static to the region eg.[bucket-name].[region]-static.digitaloceanspaces.com. This however does not appear to work with CDN, which suggests the feature is not fully ready.

Proposed Solutions

A. Expose the CNAME record value:

resource "digitalocean_cdn" "frontend" {
  origin           = digitalocean_spaces_bucket.frontend.bucket_domain_name
  custom_domain    = var.custom_domain
  certificate_name = digitalocean_certificate.frontend.name
  cname_value      = "${digitalocean_spaces_bucket.frontend.bucket_domain_name}-static"
}

B. Add a boolean flag to compute the -static suffix:

resource "digitalocean_cdn" "frontend" {
  origin           = digitalocean_spaces_bucket.frontend.bucket_domain_name
  custom_domain    = var.custom_domain
  certificate_name = digitalocean_certificate.frontend.name
  website    = true
}

C. Allow selection of a pre-existing CNAME record:

resource "digitalocean_cdn" "frontend" {
  origin           = digitalocean_spaces_bucket.frontend.bucket_domain_name
  custom_domain    = var.custom_domain
  certificate_name = digitalocean_certificate.frontend.name
  use_existing_cname = true
}

Attempted Workaround

Creating the CDN's CNAME record in advance using digitalocean_record causes digitalocean_cdn to fail with a CNAME conflict error.

Additional Context

@andrewsomething andrewsomething added the do-api Depends on changes to the DigitalOcean API label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-api Depends on changes to the DigitalOcean API
Projects
None yet
Development

No branches or pull requests

2 participants