How to import domain ?
Djiit opened this issue · 4 comments
Djiit commented
Hey,
How are we supposed to import a custom domain ?
I tried with the domain name as an ID, but it fails the Validation and I can't find any clue about it in the source code :
Error: 400 Bad Request: Path validation error: 'Object didn't pass validation for format custom-domain-id: auth.example.com' on property id (ID of the custom domain to retrieve).
stijndehaes commented
@Djiit Looking into the code it looks like the ID is indeed what you should import. In the create we can see:
func createCustomDomain(d *schema.ResourceData, m interface{}) error {
c := buildCustomDomain(d)
api := m.(*management.Management)
if err := api.CustomDomain.Create(c); err != nil {
return err
}
d.SetId(auth0.StringValue(c.ID))
return readCustomDomain(d, m)
}
So the custom domain id is indeed used to register the domain into the state. And the import in resource_auth0_custom_domain.go
just looks to be passing this id trough.
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Djiit commented
Yep. I just can't find the "id" format.
alexkappa commented
Hi @Djiit you should be able to find the id from using the API docs: https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains
Djiit commented
Okay, good catch. The format is cd_<generated_id>