Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: create twingate-connector with disabled status #453

3 changes: 2 additions & 1 deletion docs/resources/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ resource "twingate_remote_network" "aws_network" {

twingate-blee marked this conversation as resolved.
Show resolved Hide resolved
resource "twingate_connector" "aws_connector" {
remote_network_id = twingate_remote_network.aws_network.id
status_updates_enabled = true
}
```

Expand All @@ -37,7 +38,7 @@ resource "twingate_connector" "aws_connector" {
### Optional

- `name` (String) Name of the Connector, if not provided one will be generated.
- `status_updates_enabled` (Boolean) Determines whether status notifications are enabled for the Connector.
- `status_updates_enabled` (Boolean) Determines whether status notifications are enabled for the Connector. Default is `false`.

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions examples/resources/twingate_connector/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ resource "twingate_remote_network" "aws_network" {

resource "twingate_connector" "aws_connector" {
remote_network_id = twingate_remote_network.aws_network.id
status_updates_enabled = true
}
5 changes: 3 additions & 2 deletions twingate/internal/provider/resource/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ func (r *connector) Create(ctx context.Context, req resource.CreateRequest, resp
}

conn, err := r.client.CreateConnector(ctx, &model.Connector{
Name: plan.Name.ValueString(),
NetworkID: plan.RemoteNetworkID.ValueString(),
Name: plan.Name.ValueString(),
NetworkID: plan.RemoteNetworkID.ValueString(),
StatusUpdatesEnabled: getOptionalBool(plan.StatusUpdatesEnabled),
})

r.helper(ctx, conn, &plan, &resp.State, &resp.Diagnostics, err, operationCreate)
Expand Down
20 changes: 20 additions & 0 deletions twingate/internal/test/acctests/resource/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,23 @@ func terraformResourceTwingateConnectorWithNotificationStatus(terraformRemoteNet
}
`, terraformResourceRemoteNetwork(terraformRemoteNetworkName, remoteNetworkName), terraformConnectorName, terraformRemoteNetworkName, notificationStatus)
}

func TestAccRemoteConnectorCreateWithNotificationStatusFalse(t *testing.T) {
const terraformResourceName = "test_c8"
theResource := acctests.TerraformConnector(terraformResourceName)
remoteNetworkName := test.RandomName()

sdk.Test(t, sdk.TestCase{
ProtoV6ProviderFactories: acctests.ProviderFactories,
PreCheck: func() { acctests.PreCheck(t) },
CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy,
Steps: []sdk.TestStep{
{
Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, false),
Check: acctests.ComposeTestCheckFunc(
sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"),
),
},
},
})
}
Loading