diff --git a/docs/resources/webhook.md b/docs/resources/webhook.md index 216c20b..e0f82ad 100644 --- a/docs/resources/webhook.md +++ b/docs/resources/webhook.md @@ -8,6 +8,10 @@ A FusionAuth Webhook is intended to consume JSON events emitted by FusionAuth. C ```hcl resource "fusionauth_webhook" "example" { + tenant_ids = [ + "00000000-0000-0000-0000-000000000003", + fusionauth_tenant.example.id + ] connect_timeout = 1000 description = "The standard game Webhook" events_enabled { @@ -27,6 +31,7 @@ resource "fusionauth_webhook" "example" { ``` ## Argument Reference +* `tenant_ids` - (Optional) The Ids of the tenants that this Webhook should be associated with. If no Ids are specified and the global field is false, this Webhook will not be used. * `connect_timeout` - (Required) The connection timeout in milliseconds used when FusionAuth sends events to the Webhook. * `description` - (Optional) A description of the Webhook. This is used for display purposes only. * `events_enabled` - (Optional) A mapping for the events that are enabled for this Webhook. @@ -76,4 +81,4 @@ resource "fusionauth_webhook" "example" { * `http_authentication_username` -(Optional) The HTTP basic authentication username that is sent as part of the HTTP request for the events. * `read_timeout` - (Required) The read timeout in milliseconds used when FusionAuth sends events to the Webhook. * `ssl_certificate` - (Optional) An SSL certificate in PEM format that is used to establish the a SSL (TLS specifically) connection to the Webhook. -* `url` - (Required) The fully qualified URL of the Webhook’s endpoint that will accept the event requests from FusionAuth. +* `url` - (Required) The fully qualified URL of the Webhook’s endpoint that will accept the event requests from FusionAuth. \ No newline at end of file diff --git a/fusionauth/resource_fusionauth_webhook.go b/fusionauth/resource_fusionauth_webhook.go index 7e7d3e9..5703071 100644 --- a/fusionauth/resource_fusionauth_webhook.go +++ b/fusionauth/resource_fusionauth_webhook.go @@ -16,6 +16,12 @@ func newWebhook() *schema.Resource { UpdateContext: updateWebhook, DeleteContext: deleteWebhook, Schema: map[string]*schema.Schema{ + "tenant_ids": { + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Description: "The Ids of the Tenants that this Webhook should be associated with. If no Ids are specified and the global field is false, this Webhook will not be used.", + }, "connect_timeout": { Type: schema.TypeInt, Required: true, @@ -282,6 +288,7 @@ func newWebhook() *schema.Resource { func buildWebhook(data *schema.ResourceData) fusionauth.Webhook { wh := fusionauth.Webhook{ + TenantIds: handleStringSlice("tenant_ids", data), ConnectTimeout: data.Get("connect_timeout").(int), Description: data.Get("description").(string), EventsEnabled: buildEventsEnabled("events_enabled", data), @@ -380,6 +387,9 @@ func readWebhook(_ context.Context, data *schema.ResourceData, i interface{}) di } l := resp.Webhook + if err := data.Set("tenant_ids", l.TenantIds); err != nil { + return diag.Errorf("webhook.tenant_ids: %s", err.Error()) + } if err := data.Set("connect_timeout", l.ConnectTimeout); err != nil { return diag.Errorf("webhook.connect_timeout: %s", err.Error()) } diff --git a/go.mod b/go.mod index f47b429..2cf36c5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gpsinsight/terraform-provider-fusionauth go 1.18 require ( - github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0 + github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-sdk/v2 v2.14.0 diff --git a/go.sum b/go.sum index b1f94bb..4938b49 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/FusionAuth/go-client v0.0.0-20220429153148-63e95adfac4e h1:1GkB6QE01BlB7+OCwWBBiUM/xBqMA5vpFgr7C/fF2ck= github.com/FusionAuth/go-client v0.0.0-20220429153148-63e95adfac4e/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4= -github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0 h1:gV0qAy8Su8r4pOJxj6uZ/qqycVhW6uU8tUMSkOcgr+s= -github.com/FusionAuth/go-client v0.0.0-20220927000356-028dacca67f0/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4= +github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f h1:a7M72XffsaShvWiJVyCMEXzXJWVU9GzkUrDxVaxlFnQ= +github.com/FusionAuth/go-client v0.0.0-20220928202602-4f85e4f2101f/go.mod h1:SyRrXMJAzMVQLiJjKfQUR59dRI3jPyZv+BXIZ//HwE4= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=