digitalocean_cdn

Provides a DigitalOcean CDN Endpoint resource for use with Spaces.

Example Usage

Basic Example

# Create a new Spaces Bucket
resource "digitalocean_spaces_bucket" "mybucket" {
  name   = "example"
  region = "sfo2"
  acl    = "public-read"
}

# Add a CDN endpoint to the Spaces Bucket
resource "digitalocean_cdn" "mycdn" {
  origin = digitalocean_spaces_bucket.mybucket.bucket_domain_name
}

# Output the endpoint for the CDN resource
output "fqdn" {
  value = digitalocean_cdn.mycdn.endpoint
}

Custom Sub-Domain Example

# Create a new Spaces Bucket
resource "digitalocean_spaces_bucket" "mybucket" {
  name   = "example"
  region = "sfo2"
  acl    = "public-read"
}

# Create a DigitalOcean managed Let's Encrypt Certificate
resource "digitalocean_certificate" "cert" {
  name    = "cdn-cert"
  type    = "lets_encrypt"
  domains = ["static.example.com"]
}

# Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
resource "digitalocean_cdn" "mycdn" {
  origin           = digitalocean_spaces_bucket.mybucket.bucket_domain_name
  custom_domain    = "static.example.com"
  certificate_name = digitalocean_certificate.cert.name
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Import

CDN Endpoints can be imported using the CDN id, e.g.

terraform import digitalocean_cdn.mycdn fb06ad00-351f-45c8-b5eb-13523c438661