Skip to content

Commit

Permalink
azurerm_databricks_access_connector: add support for UAI
Browse files Browse the repository at this point in the history
  • Loading branch information
favoretti committed Mar 21, 2023
1 parent 83576ec commit f266a5a
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 75 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.1.2
github.com/hashicorp/go-azure-helpers v0.55.0
github.com/hashicorp/go-azure-sdk v0.20230317.1100159
github.com/hashicorp/go-azure-sdk v0.20230320.1165256
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg=
github.com/hashicorp/go-azure-helpers v0.55.0 h1:2A2KWPiaDC5kQWr6tYHTD/P1k9bO0HvflEb/Nc1yLeU=
github.com/hashicorp/go-azure-helpers v0.55.0/go.mod h1:RQugkG8wEcNIjYmcBLHpuEI/u2mTJwO4r37rR/OKRpo=
github.com/hashicorp/go-azure-sdk v0.20230317.1100159 h1:Nup/Opy0OB1j2Km/kd/yxWkcxs5zQ4psb1W4qd8AtPE=
github.com/hashicorp/go-azure-sdk v0.20230317.1100159/go.mod h1:L9JXVUcnL0GjMizCnngYUlMp1lLhDBNgSTvn6Of/5O4=
github.com/hashicorp/go-azure-sdk v0.20230320.1165256 h1:Xi1rfDN57F7i80YY8ImqsW8Gk38dTgiwyMs0AHpiZBs=
github.com/hashicorp/go-azure-sdk v0.20230320.1165256/go.mod h1:L9JXVUcnL0GjMizCnngYUlMp1lLhDBNgSTvn6Of/5O4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
Expand Down
2 changes: 1 addition & 1 deletion internal/services/databricks/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector"
"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-10-01-preview/accessconnector"
"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2023-02-01/workspaces"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector"
"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-10-01-preview/accessconnector"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/databricks/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand All @@ -22,11 +22,10 @@ type AccessConnectorResource struct {
var _ sdk.ResourceWithUpdate = AccessConnectorResource{}

type AccessConnectorResourceModel struct {
Name string `tfschema:"name"`
ResourceGroup string `tfschema:"resource_group_name"`
Location string `tfschema:"location"`
Tags map[string]string `tfschema:"tags"`
Identity []identity.ModelSystemAssigned `tfschema:"identity"`
Name string `tfschema:"name"`
ResourceGroup string `tfschema:"resource_group_name"`
Location string `tfschema:"location"`
Tags map[string]string `tfschema:"tags"`
}

func (r AccessConnectorResource) Arguments() map[string]*pluginsdk.Schema {
Expand All @@ -42,7 +41,7 @@ func (r AccessConnectorResource) Arguments() map[string]*pluginsdk.Schema {

"resource_group_name": commonschema.ResourceGroupName(),

"identity": commonschema.SystemAssignedIdentityOptional(),
"identity": commonschema.SystemOrUserAssignedIdentityOptional(),

"tags": commonschema.Tags(),
}
Expand Down Expand Up @@ -84,7 +83,7 @@ func (r AccessConnectorResource) Create() sdk.ResourceFunc {
return metadata.ResourceRequiresImport(r.ResourceType(), id)
}

expandedIdentity, err := identity.ExpandSystemAssignedFromModel(model.Identity)
expandedIdentity, err := identity.ExpandLegacySystemAndUserAssignedMap(metadata.ResourceData.Get("identity").([]interface{}))
if err != nil {
return fmt.Errorf("expanding `identity`: %+v", err)
}
Expand Down Expand Up @@ -170,7 +169,13 @@ func (r AccessConnectorResource) Read() sdk.ResourceFunc {
state.Tags = *model.Tags
}
if model.Identity != nil {
state.Identity = identity.FlattenSystemAssignedToModel(model.Identity)
identityValue, err := identity.FlattenLegacySystemAndUserAssignedMap(model.Identity)
if err != nil {
return fmt.Errorf("flattening `identity`: %+v", err)
}
if err := metadata.ResourceData.Set("identity", identityValue); err != nil {
return fmt.Errorf("setting `identity`: %+v", err)
}
}
}
return metadata.Encode(&state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector"
"github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-10-01-preview/accessconnector"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -80,6 +80,12 @@ provider "azurerm" {
features {}
}
resource "azurerm_user_assigned_identity" "test" {
name = "acctestUAI-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-databricks-%d"
location = "%s"
Expand All @@ -90,10 +96,13 @@ resource "azurerm_databricks_access_connector" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
identity {
type = "SystemAssigned"
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.test.id,
]
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
`, data.RandomInteger, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (DatabricksAccessConnectorResource) basic(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ func (r SecurityInsightsIndicatorResource) complete(data acceptance.TestData, pa
%s
resource "azurerm_sentinel_threat_intelligence_indicator" "test" {
workspace_id = azurerm_log_analytics_workspace.test.id
pattern_type = "%s"
pattern = "%s"
confidence = 5
created_by = "testcraeted@microsoft.com"
description = "test indicator"
display_name = "test"
language = "en"
pattern_version = 1
revoked = true
tags = ["test-tags"]
workspace_id = azurerm_log_analytics_workspace.test.id
pattern_type = "%s"
pattern = "%s"
confidence = 5
created_by = "testcraeted@microsoft.com"
description = "test indicator"
display_name = "test"
language = "en"
pattern_version = 1
revoked = true
tags = ["test-tags"]
kill_chain_phase {
name = "testtest"
}
Expand All @@ -229,7 +229,7 @@ resource "azurerm_sentinel_threat_intelligence_indicator" "test" {
source = "test Sentinel"
validate_from_utc = "2022-12-14T16:00:00Z"
depends_on = [azurerm_sentinel_log_analytics_workspace_onboarding.test]
depends_on = [azurerm_sentinel_log_analytics_workspace_onboarding.test]
}
`, r.template(data), patternType, pattern)
}
Expand All @@ -239,17 +239,17 @@ func (r SecurityInsightsIndicatorResource) update(data acceptance.TestData, patt
%s
resource "azurerm_sentinel_threat_intelligence_indicator" "test" {
workspace_id = azurerm_log_analytics_workspace.test.id
pattern_type = "%s"
pattern = "%s"
confidence = 5
created_by = "testcraeted@microsoft.com"
description = "updated indicator"
display_name = "updated"
language = "en"
pattern_version = 1
revoked = true
tags = ["updated-tags"]
workspace_id = azurerm_log_analytics_workspace.test.id
pattern_type = "%s"
pattern = "%s"
confidence = 5
created_by = "testcraeted@microsoft.com"
description = "updated indicator"
display_name = "updated"
language = "en"
pattern_version = 1
revoked = true
tags = ["updated-tags"]
kill_chain_phase {
name = "testtest"
}
Expand All @@ -263,7 +263,7 @@ resource "azurerm_sentinel_threat_intelligence_indicator" "test" {
source = "updated Sentinel"
validate_from_utc = "2022-12-15T16:00:00Z"
depends_on = [azurerm_sentinel_log_analytics_workspace_onboarding.test]
depends_on = [azurerm_sentinel_log_analytics_workspace_onboarding.test]
}
`, r.template(data), patternType, pattern)
}
4 changes: 2 additions & 2 deletions internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3990,8 +3990,8 @@ resource "azurerm_storage_account" "test" {
}
infrastructure_encryption_enabled = true
table_encryption_key_type = "Account"
queue_encryption_key_type = "Account"
table_encryption_key_type = "Account"
queue_encryption_key_type = "Account"
tags = {
environment = "production"
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/zones
github.com/hashicorp/go-azure-helpers/resourceproviders
github.com/hashicorp/go-azure-helpers/sender
github.com/hashicorp/go-azure-helpers/storage
# github.com/hashicorp/go-azure-sdk v0.20230317.1100159
# github.com/hashicorp/go-azure-sdk v0.20230320.1165256
## explicit; go 1.19
github.com/hashicorp/go-azure-sdk/resource-manager/aad/2021-05-01/domainservices
github.com/hashicorp/go-azure-sdk/resource-manager/aadb2c/2021-04-01-preview
Expand Down Expand Up @@ -250,8 +250,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/customproviders/2018-09-01-pr
github.com/hashicorp/go-azure-sdk/resource-manager/dashboard/2022-08-01/grafanaresource
github.com/hashicorp/go-azure-sdk/resource-manager/databoxedge/2020-12-01/devices
github.com/hashicorp/go-azure-sdk/resource-manager/databoxedge/2020-12-01/orders
github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/accessconnector
github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-04-01-preview/workspaces
github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2022-10-01-preview/accessconnector
github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2023-02-01/workspaces
github.com/hashicorp/go-azure-sdk/resource-manager/datadog/2021-03-01
github.com/hashicorp/go-azure-sdk/resource-manager/datadog/2021-03-01/agreements
Expand Down
17 changes: 13 additions & 4 deletions website/docs/r/databricks_access_connector.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ The following arguments are supported:

An `identity` block supports the following:

* `type` - (Required) The type of identity to use for this Access Connector. `SystemAssigned` is the only possible value.
* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Access Connector. Possible values are `SystemAssigned`, `UserAssigned`, `SystemAssigned, UserAssigned` (to enable both).

* `identity_ids` - (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Access Connector.

~> **NOTE:** This is required when `type` is set to `UserAssigned` or `SystemAssigned, UserAssigned`.

---

## Attributes Reference

Expand All @@ -65,11 +71,14 @@ The following attributes are exported:

An `identity` block exports the following:

* `type` - The type of identity.
* `type` - (Required) The type of Managed Service Identity that is configured on this Access Connector.

* `principal_id` - The Principal ID of the System Assigned Managed Service Identity that is configured on this Access Connector.

* `tenant_id` - The Tenant ID of the System Assigned Managed Service Identity that is configured on this Access Connector.

* `principal_id` - The Principal ID associated with this system-assigned managed identity.
* `identity_ids` - (Optional) The list of User Assigned Managed Identity IDs assigned to this Access Connector.

* `tenant_id` - The Tenant ID associated with this system-assigned managed identity.

## Timeouts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ Sentinel Threat Intelligence Indicators can be imported using the `resource id`,

```shell
terraform import azurerm_sentinel_threat_intelligence_indicator.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourcegroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/providers/Microsoft.SecurityInsights/threatIntelligence/main/indicators/indicator1
```
```

0 comments on commit f266a5a

Please sign in to comment.