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

feat(gateway): onboard new resource/data-source #219

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
89b87ac
add gateway resource + datasource w/o tests
badeamarjieh Jan 26, 2025
c99ac71
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Jan 26, 2025
2053dcc
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Feb 2, 2025
5959a1c
1. support OnPremises and OnPremisesPersonal gateway types as data so…
badeamarjieh Feb 2, 2025
2d87bb6
add docs
badeamarjieh Feb 2, 2025
f7ce0e6
1. change get method from returning error to diag.Diagnostics
badeamarjieh Feb 2, 2025
577dab4
add unit tests phase 1
badeamarjieh Feb 11, 2025
c4714b2
add docs
badeamarjieh Feb 11, 2025
123b9d9
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Feb 11, 2025
36bd990
add unit tests and accept reference by id and display name for data s…
badeamarjieh Feb 12, 2025
944a727
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Feb 12, 2025
e556a7e
fix linting issues
badeamarjieh Feb 13, 2025
514a95b
Merge branch 'main' into support_polymorphic_gateway_datasource_and_r…
badeamarjieh Feb 13, 2025
2e6ab85
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Feb 13, 2025
cbdfc4f
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Feb 13, 2025
9784d7a
Merge branch 'support_polymorphic_gateway_datasource_and_resource' of…
badeamarjieh Feb 13, 2025
8e61321
remove onprem acc tests and from wellknown
badeamarjieh Feb 13, 2025
c544a10
fix well known ps script
badeamarjieh Feb 13, 2025
45079bb
fix lint and remove redundant code in Set-WellKno
badeamarjieh Feb 25, 2025
728c498
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Mar 6, 2025
545019b
update docs
badeamarjieh Mar 6, 2025
f1d729b
fix removal of graphql from merge fix
badeamarjieh Mar 6, 2025
5e278f5
add changelog and skip testacc for gateway role assignments CRUD for SPN
badeamarjieh Mar 7, 2025
715e469
Merge branch 'main' of https://github.com/microsoft/terraform-provide…
badeamarjieh Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/added-20250307-024333.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: added
body: Onboard new resource/data-source `fabric_gateway`.
time: 2025-03-07T02:43:33.229242334Z
custom:
Issue: "170"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ testresults.xml
golangci-report.xml
.wellknown.json
.wellknown.*.json
!.wellknown.template.json
changie.md
.lycheecache
*.env
Expand Down
2 changes: 2 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ FABRIC_TESTACC_WELLKNOWN_AZURE_SUBSCRIPTION_ID="<AZURE SUBSCRIPTION ID>"
FABRIC_TESTACC_WELLKNOWN_FABRIC_CAPACITY_NAME="<FABRIC CAPACITY NAME>"
FABRIC_TESTACC_WELLKNOWN_AZDO_ORGANIZATION_NAME="<AZURE DEVOPS ORGANIZATION NAME>"
FABRIC_TESTACC_WELLKNOWN_NAME_PREFIX="<RESOURCES PREFIX>"
FABRIC_TESTACC_WELLKNOWN_AZURE_RESOURCE_GROUP_NAME="<AZURE RESOURCE GROUP NAME>"
FABRIC_TESTACC_WELLKNOWN_AZURE_LOCATION"<AZURE LOCATION>"

# Optional
FABRIC_TESTACC_WELLKNOWN_NAME_SUFFIX=""
Expand Down
67 changes: 67 additions & 0 deletions docs/data-sources/gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_gateway Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
Get a Fabric Gateway.
Use this data source to get Gateway https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways.
-> This item supports Service Principal authentication.
---

# fabric_gateway (Data Source)

Get a Fabric Gateway.

Use this data source to get [Gateway](https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways).

-> This item supports Service Principal authentication.

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `display_name` (String) The Gateway display name.
- `id` (String) The Gateway ID.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `allow_cloud_connection_refresh` (Boolean) Allow cloud connection refresh.
- `allow_custom_connectors` (Boolean) Allow custom connectors.
- `capacity_id` (String) The Gateway capacity ID.
- `inactivity_minutes_before_sleep` (Number) The Gateway inactivity minutes before sleep. Possible values: `120`, `1440`, `150`, `240`, `30`, `360`, `480`, `60`, `720`, `90`
- `load_balancing_setting` (String) The load balancing setting. Possible values: `DistributeEvenly`, `Failover`
- `number_of_member_gateways` (Number) The number of member gateways. Possible values: 1 to 7.
- `public_key` (Attributes) The public key of the primary gateway member. Used to encrypt the credentials for creating and updating connections. (see [below for nested schema](#nestedatt--public_key))
- `type` (String) The Gateway type. Possible values: `OnPremises`, `OnPremisesPersonal`, `VirtualNetwork`
- `version` (String) The Gateway version.
- `virtual_network_azure_resource` (Attributes) The Azure virtual network resource. (see [below for nested schema](#nestedatt--virtual_network_azure_resource))

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

<a id="nestedatt--public_key"></a>

### Nested Schema for `public_key`

Read-Only:

- `exponent` (String) The exponent.
- `modulus` (String) The modulus.

<a id="nestedatt--virtual_network_azure_resource"></a>

### Nested Schema for `virtual_network_azure_resource`

Read-Only:

- `resource_group_name` (String) The resource group name.
- `subnet_name` (String) The subnet name.
- `subscription_id` (String) The subscription ID.
- `virtual_network_name` (String) The virtual network name.
50 changes: 50 additions & 0 deletions docs/data-sources/gateway_role_assignments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_gateway_role_assignments Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
List Fabric Gateway Role Assignments.
Use this data source to list [Gateway Role Assignments].
-> This item supports Service Principal authentication.
---

# fabric_gateway_role_assignments (Data Source)

List Fabric Gateway Role Assignments.

Use this data source to list [Gateway Role Assignments].

-> This item supports Service Principal authentication.

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `gateway_id` (String) The Gateway ID.

### Optional

- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `values` (Attributes List) The list of Gateway Role Assignments. (see [below for nested schema](#nestedatt--values))

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

<a id="nestedatt--values"></a>

### Nested Schema for `values`

Read-Only:

- `id` (String) The Principal ID.
- `role` (String) The gateway role of the principal. Possible values: `Admin`, `ConnectionCreator`, `ConnectionCreatorWithResharing`.
- `type` (String) The type of the principal. Possible values: `Group`, `ServicePrincipal`, `ServicePrincipalProfile`, `User`.
78 changes: 78 additions & 0 deletions docs/data-sources/gateways.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_gateways Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
List a Fabric Gateways.
Use this data source to list Gateways https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways.
-> This item supports Service Principal authentication.
---

# fabric_gateways (Data Source)

List a Fabric Gateways.

Use this data source to list [Gateways](https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways).

-> This item supports Service Principal authentication.

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `values` (Attributes List) The list of Gateways. (see [below for nested schema](#nestedatt--values))

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

<a id="nestedatt--values"></a>

### Nested Schema for `values`

Optional:

- `display_name` (String) The Gateway display name.
- `id` (String) The Gateway ID.

Read-Only:

- `allow_cloud_connection_refresh` (Boolean) Allow cloud connection refresh.
- `allow_custom_connectors` (Boolean) Allow custom connectors.
- `capacity_id` (String) The Gateway capacity ID.
- `inactivity_minutes_before_sleep` (Number) The Gateway inactivity minutes before sleep. Possible values: `120`, `1440`, `150`, `240`, `30`, `360`, `480`, `60`, `720`, `90`
- `load_balancing_setting` (String) The load balancing setting. Possible values: `DistributeEvenly`, `Failover`
- `number_of_member_gateways` (Number) The number of member gateways. Possible values: 1 to 7.
- `public_key` (Attributes) The public key of the primary gateway member. Used to encrypt the credentials for creating and updating connections. (see [below for nested schema](#nestedatt--values--public_key))
- `type` (String) The Gateway type. Possible values: `OnPremises`, `OnPremisesPersonal`, `VirtualNetwork`
- `version` (String) The Gateway version.
- `virtual_network_azure_resource` (Attributes) The Azure virtual network resource. (see [below for nested schema](#nestedatt--values--virtual_network_azure_resource))

<a id="nestedatt--values--public_key"></a>

### Nested Schema for `values.public_key`

Read-Only:

- `exponent` (String) The exponent.
- `modulus` (String) The modulus.

<a id="nestedatt--values--virtual_network_azure_resource"></a>

### Nested Schema for `values.virtual_network_azure_resource`

Read-Only:

- `resource_group_name` (String) The resource group name.
- `subnet_name` (String) The subnet name.
- `subscription_id` (String) The subscription ID.
- `virtual_network_name` (String) The virtual network name.
4 changes: 2 additions & 2 deletions docs/data-sources/workspace_role_assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
page_title: "fabric_workspace_role_assignments Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
List a Fabric Workspace Role Assignments.
List Fabric Workspace Role Assignments.
Use this data source to list Workspace Role Assignments https://learn.microsoft.com/power-bi/collaborate-share/service-roles-new-workspaces.
-> This item supports Service Principal authentication.
---

# fabric_workspace_role_assignments (Data Source)

List a Fabric Workspace Role Assignments.
List Fabric Workspace Role Assignments.

Use this data source to list [Workspace Role Assignments](https://learn.microsoft.com/power-bi/collaborate-share/service-roles-new-workspaces).

Expand Down
59 changes: 59 additions & 0 deletions docs/resources/gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_gateway Resource - terraform-provider-fabric"
subcategory: ""
description: |-
This resource manages a Fabric Gateway.
See Gateways https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways for more information.
-> This item supports Service Principal authentication.
---

# fabric_gateway (Resource)

This resource manages a Fabric Gateway.

See [Gateways](https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways) for more information.

-> This item supports Service Principal authentication.

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `type` (String) The Gateway type. Accepted values: `OnPremises`, `OnPremisesPersonal`, `VirtualNetwork`

### Optional

- `capacity_id` (String) The Gateway capacity ID.
- `display_name` (String) The Gateway display name.
- `inactivity_minutes_before_sleep` (Number) The Gateway inactivity minutes before sleep.
- `number_of_member_gateways` (Number) The Gateway number of member gateways.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
- `virtual_network_azure_resource` (Attributes) The Gateway virtual network Azure resource. (see [below for nested schema](#nestedatt--virtual_network_azure_resource))

### Read-Only

- `id` (String) The Gateway ID.

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

<a id="nestedatt--virtual_network_azure_resource"></a>

### Nested Schema for `virtual_network_azure_resource`

Required:

- `resource_group_name` (String) The resource group name.
- `subnet_name` (String) The subnet name.
- `subscription_id` (String) The subscription ID.
- `virtual_network_name` (String) The virtual network name.
43 changes: 43 additions & 0 deletions docs/resources/gateway_role_assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_gateway_role_assignment Resource - terraform-provider-fabric"
subcategory: ""
description: |-
Manage a Gateway Role Assignment.
-> This item supports Service Principal authentication.
---

# fabric_gateway_role_assignment (Resource)

Manage a Gateway Role Assignment.

-> This item supports Service Principal authentication.

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `gateway_id` (String) The Gateway ID.
- `principal_id` (String) The Principal ID.
- `principal_type` (String) The type of the principal. Accepted values: `Group`, `ServicePrincipal`, `ServicePrincipalProfile`, `User`.
- `role` (String) The Gateway Role of the principal. Accepted values: `Admin`, `ConnectionCreator`, `ConnectionCreatorWithResharing`.

### Optional

- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `id` (String) The Gateway Role Assignment ID.

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
6 changes: 6 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/services/environment"
"github.com/microsoft/terraform-provider-fabric/internal/services/eventhouse"
"github.com/microsoft/terraform-provider-fabric/internal/services/eventstream"
"github.com/microsoft/terraform-provider-fabric/internal/services/gateway"
"github.com/microsoft/terraform-provider-fabric/internal/services/graphqlapi"
"github.com/microsoft/terraform-provider-fabric/internal/services/kqldashboard"
"github.com/microsoft/terraform-provider-fabric/internal/services/kqldatabase"
Expand Down Expand Up @@ -390,6 +391,8 @@ func (p *FabricProvider) Resources(ctx context.Context) []func() resource.Resour
func() resource.Resource { return environment.NewResourceEnvironment(ctx) },
func() resource.Resource { return eventhouse.NewResourceEventhouse(ctx) },
eventstream.NewResourceEventstream,
gateway.NewResourceGateway,
gateway.NewResourceGatewayRoleAssignment,
graphqlapi.NewResourceGraphQLApi,
kqldashboard.NewResourceKQLDashboard,
kqldatabase.NewResourceKQLDatabase,
Expand Down Expand Up @@ -430,6 +433,9 @@ func (p *FabricProvider) DataSources(ctx context.Context) []func() datasource.Da
func() datasource.DataSource { return eventhouse.NewDataSourceEventhouses(ctx) },
eventstream.NewDataSourceEventstream,
eventstream.NewDataSourceEventstreams,
gateway.NewDataSourceGateway,
gateway.NewDataSourceGateways,
gateway.NewDataSourceGatewayRoleAssignments,
graphqlapi.NewDataSourceGraphQLApi,
graphqlapi.NewDataSourceGraphQLApis,
kqldashboard.NewDataSourceKQLDashboard,
Expand Down
28 changes: 28 additions & 0 deletions internal/services/gateway/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MPL-2.0

package gateway

import (
"github.com/microsoft/terraform-provider-fabric/internal/common"
)

const (
ItemName = "Gateway"
ItemTFName = "gateway"
ItemsName = "Gateways"
ItemsTFName = "gateways"
ItemDocsSPNSupport = common.DocsSPNSupported
ItemDocsURL = "https://learn.microsoft.com/power-bi/guidance/powerbi-implementation-planning-data-gateways"
GatewayRoleAssignmentName = "Gateway Role Assignment"
GatewayRoleAssignmentTFName = "gateway_role_assignment"
GatewayRoleAssignmentsName = "Gateway Role Assignments"
GatewayRoleAssignmentsTFName = "gateway_role_assignments"
ItemPreview = true
)

var (
PossibleInactivityMinutesBeforeSleepValues = []int32{30, 60, 90, 120, 150, 240, 360, 480, 720, 1440} //nolint:gochecknoglobals
MinNumberOfMemberGatewaysValues = int32(1) //nolint:gochecknoglobals
MaxNumberOfMemberGatewaysValues = int32(7) //nolint:gochecknoglobals
)
Loading
Loading