digitalocean.Cdn
Explore with Pulumi AI
Provides a DigitalOcean CDN Endpoint resource for use with Spaces.
Example Usage
Basic Example
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
// Create a new Spaces Bucket
const mybucket = new digitalocean.SpacesBucket("mybucket", {
name: "example",
region: digitalocean.Region.SFO2,
acl: "public-read",
});
// Add a CDN endpoint to the Spaces Bucket
const mycdn = new digitalocean.Cdn("mycdn", {origin: mybucket.bucketDomainName});
export const fqdn = mycdn.endpoint;
import pulumi
import pulumi_digitalocean as digitalocean
# Create a new Spaces Bucket
mybucket = digitalocean.SpacesBucket("mybucket",
name="example",
region=digitalocean.Region.SFO2,
acl="public-read")
# Add a CDN endpoint to the Spaces Bucket
mycdn = digitalocean.Cdn("mycdn", origin=mybucket.bucket_domain_name)
pulumi.export("fqdn", mycdn.endpoint)
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a new Spaces Bucket
mybucket, err := digitalocean.NewSpacesBucket(ctx, "mybucket", &digitalocean.SpacesBucketArgs{
Name: pulumi.String("example"),
Region: pulumi.String(digitalocean.RegionSFO2),
Acl: pulumi.String("public-read"),
})
if err != nil {
return err
}
// Add a CDN endpoint to the Spaces Bucket
mycdn, err := digitalocean.NewCdn(ctx, "mycdn", &digitalocean.CdnArgs{
Origin: mybucket.BucketDomainName,
})
if err != nil {
return err
}
ctx.Export("fqdn", mycdn.Endpoint)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
// Create a new Spaces Bucket
var mybucket = new DigitalOcean.SpacesBucket("mybucket", new()
{
Name = "example",
Region = DigitalOcean.Region.SFO2,
Acl = "public-read",
});
// Add a CDN endpoint to the Spaces Bucket
var mycdn = new DigitalOcean.Cdn("mycdn", new()
{
Origin = mybucket.BucketDomainName,
});
return new Dictionary<string, object?>
{
["fqdn"] = mycdn.Endpoint,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.SpacesBucket;
import com.pulumi.digitalocean.SpacesBucketArgs;
import com.pulumi.digitalocean.Cdn;
import com.pulumi.digitalocean.CdnArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Create a new Spaces Bucket
var mybucket = new SpacesBucket("mybucket", SpacesBucketArgs.builder()
.name("example")
.region("sfo2")
.acl("public-read")
.build());
// Add a CDN endpoint to the Spaces Bucket
var mycdn = new Cdn("mycdn", CdnArgs.builder()
.origin(mybucket.bucketDomainName())
.build());
ctx.export("fqdn", mycdn.endpoint());
}
}
resources:
# Create a new Spaces Bucket
mybucket:
type: digitalocean:SpacesBucket
properties:
name: example
region: sfo2
acl: public-read
# Add a CDN endpoint to the Spaces Bucket
mycdn:
type: digitalocean:Cdn
properties:
origin: ${mybucket.bucketDomainName}
outputs:
# Output the endpoint for the CDN resource
fqdn: ${mycdn.endpoint}
Custom Sub-Domain Example
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
// Create a new Spaces Bucket
const mybucket = new digitalocean.SpacesBucket("mybucket", {
name: "example",
region: digitalocean.Region.SFO2,
acl: "public-read",
});
// Create a DigitalOcean managed Let's Encrypt Certificate
const cert = new digitalocean.Certificate("cert", {
name: "cdn-cert",
type: digitalocean.CertificateType.LetsEncrypt,
domains: ["static.example.com"],
});
// Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
const mycdn = new digitalocean.Cdn("mycdn", {
origin: mybucket.bucketDomainName,
customDomain: "static.example.com",
certificateName: cert.name,
});
import pulumi
import pulumi_digitalocean as digitalocean
# Create a new Spaces Bucket
mybucket = digitalocean.SpacesBucket("mybucket",
name="example",
region=digitalocean.Region.SFO2,
acl="public-read")
# Create a DigitalOcean managed Let's Encrypt Certificate
cert = digitalocean.Certificate("cert",
name="cdn-cert",
type=digitalocean.CertificateType.LETS_ENCRYPT,
domains=["static.example.com"])
# Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
mycdn = digitalocean.Cdn("mycdn",
origin=mybucket.bucket_domain_name,
custom_domain="static.example.com",
certificate_name=cert.name)
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a new Spaces Bucket
mybucket, err := digitalocean.NewSpacesBucket(ctx, "mybucket", &digitalocean.SpacesBucketArgs{
Name: pulumi.String("example"),
Region: pulumi.String(digitalocean.RegionSFO2),
Acl: pulumi.String("public-read"),
})
if err != nil {
return err
}
// Create a DigitalOcean managed Let's Encrypt Certificate
cert, err := digitalocean.NewCertificate(ctx, "cert", &digitalocean.CertificateArgs{
Name: pulumi.String("cdn-cert"),
Type: pulumi.String(digitalocean.CertificateTypeLetsEncrypt),
Domains: pulumi.StringArray{
pulumi.String("static.example.com"),
},
})
if err != nil {
return err
}
// Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
_, err = digitalocean.NewCdn(ctx, "mycdn", &digitalocean.CdnArgs{
Origin: mybucket.BucketDomainName,
CustomDomain: pulumi.String("static.example.com"),
CertificateName: cert.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
// Create a new Spaces Bucket
var mybucket = new DigitalOcean.SpacesBucket("mybucket", new()
{
Name = "example",
Region = DigitalOcean.Region.SFO2,
Acl = "public-read",
});
// Create a DigitalOcean managed Let's Encrypt Certificate
var cert = new DigitalOcean.Certificate("cert", new()
{
Name = "cdn-cert",
Type = DigitalOcean.CertificateType.LetsEncrypt,
Domains = new[]
{
"static.example.com",
},
});
// Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
var mycdn = new DigitalOcean.Cdn("mycdn", new()
{
Origin = mybucket.BucketDomainName,
CustomDomain = "static.example.com",
CertificateName = cert.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.SpacesBucket;
import com.pulumi.digitalocean.SpacesBucketArgs;
import com.pulumi.digitalocean.Certificate;
import com.pulumi.digitalocean.CertificateArgs;
import com.pulumi.digitalocean.Cdn;
import com.pulumi.digitalocean.CdnArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Create a new Spaces Bucket
var mybucket = new SpacesBucket("mybucket", SpacesBucketArgs.builder()
.name("example")
.region("sfo2")
.acl("public-read")
.build());
// Create a DigitalOcean managed Let's Encrypt Certificate
var cert = new Certificate("cert", CertificateArgs.builder()
.name("cdn-cert")
.type("lets_encrypt")
.domains("static.example.com")
.build());
// Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
var mycdn = new Cdn("mycdn", CdnArgs.builder()
.origin(mybucket.bucketDomainName())
.customDomain("static.example.com")
.certificateName(cert.name())
.build());
}
}
resources:
# Create a new Spaces Bucket
mybucket:
type: digitalocean:SpacesBucket
properties:
name: example
region: sfo2
acl: public-read
# Create a DigitalOcean managed Let's Encrypt Certificate
cert:
type: digitalocean:Certificate
properties:
name: cdn-cert
type: lets_encrypt
domains:
- static.example.com
# Add a CDN endpoint with a custom sub-domain to the Spaces Bucket
mycdn:
type: digitalocean:Cdn
properties:
origin: ${mybucket.bucketDomainName}
customDomain: static.example.com
certificateName: ${cert.name}
Create Cdn Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Cdn(name: string, args: CdnArgs, opts?: CustomResourceOptions);
@overload
def Cdn(resource_name: str,
args: CdnArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Cdn(resource_name: str,
opts: Optional[ResourceOptions] = None,
origin: Optional[str] = None,
certificate_id: Optional[str] = None,
certificate_name: Optional[str] = None,
custom_domain: Optional[str] = None,
ttl: Optional[int] = None)
func NewCdn(ctx *Context, name string, args CdnArgs, opts ...ResourceOption) (*Cdn, error)
public Cdn(string name, CdnArgs args, CustomResourceOptions? opts = null)
type: digitalocean:Cdn
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args CdnArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args CdnArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args CdnArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CdnArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CdnArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var cdnResource = new DigitalOcean.Cdn("cdnResource", new()
{
Origin = "string",
CertificateName = "string",
CustomDomain = "string",
Ttl = 0,
});
example, err := digitalocean.NewCdn(ctx, "cdnResource", &digitalocean.CdnArgs{
Origin: pulumi.String("string"),
CertificateName: pulumi.String("string"),
CustomDomain: pulumi.String("string"),
Ttl: pulumi.Int(0),
})
var cdnResource = new Cdn("cdnResource", CdnArgs.builder()
.origin("string")
.certificateName("string")
.customDomain("string")
.ttl(0)
.build());
cdn_resource = digitalocean.Cdn("cdnResource",
origin="string",
certificate_name="string",
custom_domain="string",
ttl=0)
const cdnResource = new digitalocean.Cdn("cdnResource", {
origin: "string",
certificateName: "string",
customDomain: "string",
ttl: 0,
});
type: digitalocean:Cdn
properties:
certificateName: string
customDomain: string
origin: string
ttl: 0
Cdn Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Cdn resource accepts the following input properties:
- Origin string
- The fully qualified domain name, (FQDN) for a Space.
- Certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- Ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- Origin string
- The fully qualified domain name, (FQDN) for a Space.
- Certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- Ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- origin String
- The fully qualified domain name, (FQDN) for a Space.
- certificate
Id String - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name String - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- custom
Domain String - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- ttl Integer
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- origin string
- The fully qualified domain name, (FQDN) for a Space.
- certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- ttl number
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- origin str
- The fully qualified domain name, (FQDN) for a Space.
- certificate_
id str - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate_
name str - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- custom_
domain str - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- origin String
- The fully qualified domain name, (FQDN) for a Space.
- certificate
Id String - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name String - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- custom
Domain String - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- ttl Number
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
Outputs
All input properties are implicitly available as output properties. Additionally, the Cdn resource produces the following output properties:
- created_
at str - The date and time when the CDN Endpoint was created.
- endpoint str
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- id str
- The provider-assigned unique ID for this managed resource.
Look up Existing Cdn Resource
Get an existing Cdn resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: CdnState, opts?: CustomResourceOptions): Cdn
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
certificate_id: Optional[str] = None,
certificate_name: Optional[str] = None,
created_at: Optional[str] = None,
custom_domain: Optional[str] = None,
endpoint: Optional[str] = None,
origin: Optional[str] = None,
ttl: Optional[int] = None) -> Cdn
func GetCdn(ctx *Context, name string, id IDInput, state *CdnState, opts ...ResourceOption) (*Cdn, error)
public static Cdn Get(string name, Input<string> id, CdnState? state, CustomResourceOptions? opts = null)
public static Cdn get(String name, Output<String> id, CdnState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Created
At string - The date and time when the CDN Endpoint was created.
- Custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- Endpoint string
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- Origin string
- The fully qualified domain name, (FQDN) for a Space.
- Ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- Certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- Created
At string - The date and time when the CDN Endpoint was created.
- Custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- Endpoint string
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- Origin string
- The fully qualified domain name, (FQDN) for a Space.
- Ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- certificate
Id String - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name String - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- created
At String - The date and time when the CDN Endpoint was created.
- custom
Domain String - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- endpoint String
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- origin String
- The fully qualified domain name, (FQDN) for a Space.
- ttl Integer
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- certificate
Id string - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name string - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- created
At string - The date and time when the CDN Endpoint was created.
- custom
Domain string - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- endpoint string
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- origin string
- The fully qualified domain name, (FQDN) for a Space.
- ttl number
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- certificate_
id str - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate_
name str - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- created_
at str - The date and time when the CDN Endpoint was created.
- custom_
domain str - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- endpoint str
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- origin str
- The fully qualified domain name, (FQDN) for a Space.
- ttl int
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
- certificate
Id String - Deprecated The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- certificate
Name String - The unique name of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided.
- created
At String - The date and time when the CDN Endpoint was created.
- custom
Domain String - The fully qualified domain name (FQDN) of the custom subdomain used with the CDN Endpoint.
- endpoint String
- The fully qualified domain name (FQDN) from which the CDN-backed content is served.
- origin String
- The fully qualified domain name, (FQDN) for a Space.
- ttl Number
- The time to live for the CDN Endpoint, in seconds. Default is 3600 seconds.
Import
CDN Endpoints can be imported using the CDN id
, e.g.
$ pulumi import digitalocean:index/cdn:Cdn mycdn fb06ad00-351f-45c8-b5eb-13523c438661
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitalocean
Terraform Provider.