Skip to content

Commit

Permalink
feat: allow tenant id to be set via resource
Browse files Browse the repository at this point in the history
  • Loading branch information
MCBrandenburg committed Sep 19, 2020
1 parent f9c3249 commit 923f438
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/resources/tenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ resource "fusionauth_tenant" "example" {

## Argument Reference
* `source_tentant_id` - (Optional) The optional Id of an existing Tenant to make a copy of. If present, the tenant.id and tenant.name values of the request body will be applied to the new Tenant, all other values will be copied from the source Tenant to the new Tenant.
* `tenant_id` - (Optional) The Id to use for the new Tenant. If not specified a secure random UUID will be generated.
* `data` - (Optional) An object that can hold any information about the Tenant that should be persisted.
* `email_configuration` - (Required)
- `default_from_name` - (Optional) The default From Name used in sending emails when a from name is not provided on an individual email template. This is the display name part of the email address ( i.e. Jared Dunn <[email protected]>).
Expand Down
12 changes: 11 additions & 1 deletion fusionauth/schema_fusionauth_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ func newTenant() *schema.Resource {
Description: "The optional Id of an existing Tenant to make a copy of. If present, the tenant.id and tenant.name values of the request body will be applied to the new Tenant, all other values will be copied from the source Tenant to the new Tenant.",
ValidateFunc: validation.IsUUID,
},
"tenant_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id to use for the new Tenant. If not specified a secure random UUID will be generated.",
ValidateFunc: validation.IsUUID,
},
"data": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -1249,7 +1255,11 @@ func createTenant(data *schema.ResourceData, i interface{}) error {
SourceTenantId: data.Get("source_tentant_id").(string),
}

resp, faErrs, err := client.FAClient.CreateTenant("", t)
var tid string
if t, ok := data.GetOk("tenant_id"); ok {
tid = t.(string)
}
resp, faErrs, err := client.FAClient.CreateTenant(tid, t)

if err != nil {
return fmt.Errorf("CreateTenant err: %v", err)
Expand Down

0 comments on commit 923f438

Please sign in to comment.