Skip to content

Commit df829ef

Browse files
committed
feat: support auth0_organization_discovery_domains resource
1 parent 7a8e48c commit df829ef

File tree

8 files changed

+5573
-0
lines changed

8 files changed

+5573
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
page_title: "Resource: auth0_organization_discovery_domains"
3+
description: |-
4+
With this resource, you can manage discovery domains on an organization.
5+
---
6+
7+
# Resource: auth0_organization_discovery_domains
8+
9+
With this resource, you can manage discovery domains on an organization.
10+
11+
## Example Usage
12+
13+
```terraform
14+
resource "auth0_organization" "my_organization" {
15+
name = "my-organization"
16+
display_name = "My Organization"
17+
}
18+
19+
resource "auth0_organization_discovery_domains" "my_org_discovery_domains" {
20+
organization_id = auth0_organization.my_organization.id
21+
22+
discovery_domains {
23+
domain = "example.com"
24+
status = "pending"
25+
}
26+
27+
discovery_domains {
28+
domain = "test.com"
29+
status = "verified"
30+
}
31+
}
32+
```
33+
34+
<!-- schema generated by tfplugindocs -->
35+
## Schema
36+
37+
### Required
38+
39+
- `discovery_domains` (Set of Object) Discovery domains that are configured for the organization. (see [below for nested schema](#nestedatt--discovery_domains))
40+
- `organization_id` (String) ID of the organization on which to manage the discovery domains.
41+
42+
### Read-Only
43+
44+
- `id` (String) The ID of this resource.
45+
46+
<a id="nestedatt--discovery_domains"></a>
47+
### Nested Schema for `discovery_domains`
48+
49+
Required:
50+
51+
- `domain` (String) The domain name for organization discovery.
52+
- `status` (String) Verification status. Must be either 'pending' or 'verified'.
53+
54+
Read-Only:
55+
56+
- `id` (String) The ID of the discovery domain.
57+
- `verification_host` (String) The full domain where the TXT record should be added.
58+
- `verification_txt` (String) TXT record value for domain verification.
59+
60+
## Import
61+
62+
Import is supported using the following syntax:
63+
64+
```shell
65+
# Organization discovery domains can be imported using the organization ID.
66+
terraform import auth0_organization_discovery_domains.my_org_discovery_domains "org_XXXXXXXXXXXXXXXX"
67+
```

internal/auth0/organization/expand.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,23 @@ func expandOrganizationDiscoveryDomain(data *schema.ResourceData) *management.Or
9090
// Note: ID, VerificationTXT, and VerificationHost are read-only and should not be sent to the API.
9191
}
9292
}
93+
94+
func expandOrganizationDiscoveryDomainFromConfig(domainCfg cty.Value) *management.OrganizationDiscoveryDomain {
95+
return &management.OrganizationDiscoveryDomain{
96+
Domain: value.String(domainCfg.GetAttr("domain")),
97+
Status: value.String(domainCfg.GetAttr("status")),
98+
// Note: ID, VerificationTXT, and VerificationHost are read-only and should not be sent to the API.
99+
}
100+
}
101+
102+
func expandOrganizationDiscoveryDomains(cfg cty.Value) []*management.OrganizationDiscoveryDomain {
103+
domains := make([]*management.OrganizationDiscoveryDomain, 0)
104+
105+
cfg.ForEachElement(func(_ cty.Value, domainCfg cty.Value) (stop bool) {
106+
domains = append(domains, expandOrganizationDiscoveryDomainFromConfig(domainCfg))
107+
108+
return stop
109+
})
110+
111+
return domains
112+
}

internal/auth0/organization/flatten.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,22 @@ func flattenOrganizationDiscoveryDomain(data *schema.ResourceData, discoveryDoma
142142

143143
return result.ErrorOrNil()
144144
}
145+
146+
func flattenOrganizationDiscoveryDomains(data *schema.ResourceData, domains []*management.OrganizationDiscoveryDomain) error {
147+
if len(domains) == 0 {
148+
return data.Set("discovery_domains", []interface{}{})
149+
}
150+
151+
var enabledDomains []interface{}
152+
for _, domain := range domains {
153+
enabledDomains = append(enabledDomains, map[string]interface{}{
154+
"id": domain.GetID(),
155+
"domain": domain.GetDomain(),
156+
"status": domain.GetStatus(),
157+
"verification_txt": domain.GetVerificationTXT(),
158+
"verification_host": domain.GetVerificationHost(),
159+
})
160+
}
161+
162+
return data.Set("discovery_domains", enabledDomains)
163+
}

0 commit comments

Comments
 (0)