With Auth0, you can use a custom domain to maintain a consistent user experience. This is a three-step process; you must configure the custom domain in Auth0, then create a DNS record for the domain, then verify the DNS record in Auth0. This resource allows for automating the verification part of the process.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as auth0 from "@pulumi/auth0";
import * as digitalocean from "@pulumi/digitalocean";
import * as std from "@pulumi/std";
// Example of a custom domain managed through DigitalOcean and verified using this resource.
const myCustomDomain = new auth0.CustomDomain("my_custom_domain", {
domain: "login.example.com",
type: "auth0_managed_certs",
});
const myDomainNameRecord = new digitalocean.index.Record("my_domain_name_record", {
domain: "example.com",
type: std.index.upper({
input: myCustomDomain.verifications[0].methods?.[0]?.name,
}).result,
name: std.index.trimsuffix({
input: myCustomDomain.verifications[0].methods?.[0]?.domain,
suffix: ".example.com",
}).result,
value: myCustomDomain.verifications[0].methods?.[0]?.record,
});
const myCustomDomainVerification = new auth0.CustomDomainVerification("my_custom_domain_verification", {customDomainId: myCustomDomain.id}, {
dependsOn: [myDomainNameRecord],
});
import pulumi
import pulumi_auth0 as auth0
import pulumi_digitalocean as digitalocean
import pulumi_std as std
# Example of a custom domain managed through DigitalOcean and verified using this resource.
my_custom_domain = auth0.CustomDomain("my_custom_domain",
domain="login.example.com",
type="auth0_managed_certs")
my_domain_name_record = digitalocean.index.Record("my_domain_name_record",
domain=example.com,
type=std.index.upper(input=my_custom_domain.verifications[0].methods[0].name).result,
name=std.index.trimsuffix(input=my_custom_domain.verifications[0].methods[0].domain,
suffix=.example.com).result,
value=my_custom_domain.verifications[0].methods[0].record)
my_custom_domain_verification = auth0.CustomDomainVerification("my_custom_domain_verification", custom_domain_id=my_custom_domain.id,
opts = pulumi.ResourceOptions(depends_on=[my_domain_name_record]))
package main
import (
"github.com/pulumi/pulumi-auth0/sdk/v3/go/auth0"
"github.com/pulumi/pulumi-digitalocean/sdk/go/digitalocean"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Example of a custom domain managed through DigitalOcean and verified using this resource.
myCustomDomain, err := auth0.NewCustomDomain(ctx, "my_custom_domain", &auth0.CustomDomainArgs{
Domain: pulumi.String("login.example.com"),
Type: pulumi.String("auth0_managed_certs"),
})
if err != nil {
return err
}
myDomainNameRecord, err := digitalocean.NewRecord(ctx, "my_domain_name_record", &digitalocean.RecordArgs{
Domain: "example.com",
Type: std.Upper(ctx, map[string]interface{}{
"input": myCustomDomain.Verifications[0].Methods[0].Name,
}, nil).Result,
Name: std.Trimsuffix(ctx, map[string]interface{}{
"input": myCustomDomain.Verifications[0].Methods[0].Domain,
"suffix": ".example.com",
}, nil).Result,
Value: myCustomDomain.Verifications[0].Methods[0].Record,
})
if err != nil {
return err
}
_, err = auth0.NewCustomDomainVerification(ctx, "my_custom_domain_verification", &auth0.CustomDomainVerificationArgs{
CustomDomainId: myCustomDomain.ID(),
}, pulumi.DependsOn([]pulumi.Resource{
myDomainNameRecord,
}))
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Auth0 = Pulumi.Auth0;
using Digitalocean = Pulumi.Digitalocean;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
// Example of a custom domain managed through DigitalOcean and verified using this resource.
var myCustomDomain = new Auth0.CustomDomain("my_custom_domain", new()
{
Domain = "login.example.com",
Type = "auth0_managed_certs",
});
var myDomainNameRecord = new Digitalocean.Index.Record("my_domain_name_record", new()
{
Domain = "example.com",
Type = Std.Index.Upper.Invoke(new()
{
Input = myCustomDomain.Verifications[0].Methods[0]?.Name,
}).Result,
Name = Std.Index.Trimsuffix.Invoke(new()
{
Input = myCustomDomain.Verifications[0].Methods[0]?.Domain,
Suffix = ".example.com",
}).Result,
Value = myCustomDomain.Verifications[0].Methods[0]?.Record,
});
var myCustomDomainVerification = new Auth0.CustomDomainVerification("my_custom_domain_verification", new()
{
CustomDomainId = myCustomDomain.Id,
}, new CustomResourceOptions
{
DependsOn =
{
myDomainNameRecord,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.auth0.CustomDomain;
import com.pulumi.auth0.CustomDomainArgs;
import com.pulumi.digitalocean.Record;
import com.pulumi.digitalocean.RecordArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.auth0.CustomDomainVerification;
import com.pulumi.auth0.CustomDomainVerificationArgs;
import com.pulumi.resources.CustomResourceOptions;
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) {
// Example of a custom domain managed through DigitalOcean and verified using this resource.
var myCustomDomain = new CustomDomain("myCustomDomain", CustomDomainArgs.builder()
.domain("login.example.com")
.type("auth0_managed_certs")
.build());
var myDomainNameRecord = new Record("myDomainNameRecord", RecordArgs.builder()
.domain("example.com")
.type(StdFunctions.upper(Map.of("input", myCustomDomain.verifications()[0].methods()[0].name())).result())
.name(StdFunctions.trimsuffix(Map.ofEntries(
Map.entry("input", myCustomDomain.verifications()[0].methods()[0].domain()),
Map.entry("suffix", ".example.com")
)).result())
.value(myCustomDomain.verifications()[0].methods()[0].record())
.build());
var myCustomDomainVerification = new CustomDomainVerification("myCustomDomainVerification", CustomDomainVerificationArgs.builder()
.customDomainId(myCustomDomain.id())
.build(), CustomResourceOptions.builder()
.dependsOn(myDomainNameRecord)
.build());
}
}
resources:
# Example of a custom domain managed through DigitalOcean and verified using this resource.
myCustomDomain:
type: auth0:CustomDomain
name: my_custom_domain
properties:
domain: login.example.com
type: auth0_managed_certs
myCustomDomainVerification:
type: auth0:CustomDomainVerification
name: my_custom_domain_verification
properties:
customDomainId: ${myCustomDomain.id}
options:
dependsOn:
- ${myDomainNameRecord}
myDomainNameRecord:
type: digitalocean:Record
name: my_domain_name_record
properties:
domain: example.com
type:
fn::invoke:
function: std:upper
arguments:
input: ${myCustomDomain.verifications[0].methods[0].name}
return: result
name:
fn::invoke:
function: std:trimsuffix
arguments:
input: ${myCustomDomain.verifications[0].methods[0].domain}
suffix: .example.com
return: result
value: ${myCustomDomain.verifications[0].methods[0].record}
Create CustomDomainVerification Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CustomDomainVerification(name: string, args: CustomDomainVerificationArgs, opts?: CustomResourceOptions);@overload
def CustomDomainVerification(resource_name: str,
args: CustomDomainVerificationInitArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CustomDomainVerification(resource_name: str,
opts: Optional[ResourceOptions] = None,
custom_domain_id: Optional[str] = None)func NewCustomDomainVerification(ctx *Context, name string, args CustomDomainVerificationArgs, opts ...ResourceOption) (*CustomDomainVerification, error)public CustomDomainVerification(string name, CustomDomainVerificationArgs args, CustomResourceOptions? opts = null)
public CustomDomainVerification(String name, CustomDomainVerificationArgs args)
public CustomDomainVerification(String name, CustomDomainVerificationArgs args, CustomResourceOptions options)
type: auth0:CustomDomainVerification
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 CustomDomainVerificationArgs
- 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 CustomDomainVerificationInitArgs
- 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 CustomDomainVerificationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CustomDomainVerificationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CustomDomainVerificationArgs
- 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 customDomainVerificationResource = new Auth0.CustomDomainVerification("customDomainVerificationResource", new()
{
CustomDomainId = "string",
});
example, err := auth0.NewCustomDomainVerification(ctx, "customDomainVerificationResource", &auth0.CustomDomainVerificationArgs{
CustomDomainId: pulumi.String("string"),
})
var customDomainVerificationResource = new CustomDomainVerification("customDomainVerificationResource", CustomDomainVerificationArgs.builder()
.customDomainId("string")
.build());
custom_domain_verification_resource = auth0.CustomDomainVerification("customDomainVerificationResource", custom_domain_id="string")
const customDomainVerificationResource = new auth0.CustomDomainVerification("customDomainVerificationResource", {customDomainId: "string"});
type: auth0:CustomDomainVerification
properties:
customDomainId: string
CustomDomainVerification 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 CustomDomainVerification resource accepts the following input properties:
- Custom
Domain stringId - ID of the custom domain resource.
- Custom
Domain stringId - ID of the custom domain resource.
- custom
Domain StringId - ID of the custom domain resource.
- custom
Domain stringId - ID of the custom domain resource.
- custom_
domain_ strid - ID of the custom domain resource.
- custom
Domain StringId - ID of the custom domain resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the CustomDomainVerification resource produces the following output properties:
- Cname
Api stringKey - Id string
- The provider-assigned unique ID for this managed resource.
- Origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- Cname
Api stringKey - Id string
- The provider-assigned unique ID for this managed resource.
- Origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api StringKey - id String
- The provider-assigned unique ID for this managed resource.
- origin
Domain StringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api stringKey - id string
- The provider-assigned unique ID for this managed resource.
- origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname_
api_ strkey - id str
- The provider-assigned unique ID for this managed resource.
- origin_
domain_ strname - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api StringKey - id String
- The provider-assigned unique ID for this managed resource.
- origin
Domain StringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
Look up Existing CustomDomainVerification Resource
Get an existing CustomDomainVerification 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?: CustomDomainVerificationState, opts?: CustomResourceOptions): CustomDomainVerification@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cname_api_key: Optional[str] = None,
custom_domain_id: Optional[str] = None,
origin_domain_name: Optional[str] = None) -> CustomDomainVerificationfunc GetCustomDomainVerification(ctx *Context, name string, id IDInput, state *CustomDomainVerificationState, opts ...ResourceOption) (*CustomDomainVerification, error)public static CustomDomainVerification Get(string name, Input<string> id, CustomDomainVerificationState? state, CustomResourceOptions? opts = null)public static CustomDomainVerification get(String name, Output<String> id, CustomDomainVerificationState state, CustomResourceOptions options)resources: _: type: auth0:CustomDomainVerification get: id: ${id}- 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.
- Cname
Api stringKey - Custom
Domain stringId - ID of the custom domain resource.
- Origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- Cname
Api stringKey - Custom
Domain stringId - ID of the custom domain resource.
- Origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api StringKey - custom
Domain StringId - ID of the custom domain resource.
- origin
Domain StringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api stringKey - custom
Domain stringId - ID of the custom domain resource.
- origin
Domain stringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname_
api_ strkey - custom_
domain_ strid - ID of the custom domain resource.
- origin_
domain_ strname - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
- cname
Api StringKey - custom
Domain StringId - ID of the custom domain resource.
- origin
Domain StringName - The DNS name of the Auth0 origin server that handles traffic for the custom domain.
Import
You can import this resource using the custom domain ID.
Example:
$ pulumi import auth0:index/customDomainVerification:CustomDomainVerification my_custom_domain_verification "cd_XXXXXXXXXXXXXXXX"
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Auth0 pulumi/pulumi-auth0
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
auth0Terraform Provider.
