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

azurerm_healthcare_dicom_service, azurerm_healthcare_fhir_service - fix identity schema in in data source #21594

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func dataSourceHealthcareApisFhirService() *pluginsdk.Resource {
},
},

"identity": commonschema.SystemAssignedIdentityComputed(),
"identity": commonschema.SystemOrUserAssignedIdentityComputed(),

"container_registry_login_server_url": {
Type: pluginsdk.TypeList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ func TestAccHealthCareFhirServiceDataSource_basic(t *testing.T) {
})
}

func TestAccHealthCareFhirServiceDataSource_identity(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_healthcare_fhir_service", "test")
r := HealthCareFhirServiceDataSource{}

data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.dataSourceUserAssignedIdentity(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("name").Exists()),
},
})
}

func (HealthCareFhirServiceDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand All @@ -33,3 +46,14 @@ data "azurerm_healthcare_fhir_service" "test" {
}
`, HealthcareApiFhirServiceResource{}.basic(data))
}

func (HealthCareFhirServiceDataSource) dataSourceUserAssignedIdentity(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

data "azurerm_healthcare_fhir_service" "test" {
name = azurerm_healthcare_fhir_service.test.name
workspace_id = azurerm_healthcare_fhir_service.test.workspace_id
}
`, HealthcareApiFhirServiceResource{}.updateIdentityUserAssigned(data))
}
57 changes: 55 additions & 2 deletions internal/services/healthcare/healthcare_fhir_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,28 @@ func TestAccHealthcareApiFhirService_updateIdentity(t *testing.T) {
},
data.ImportStep(),
{
Config: r.updateIdentity(data),
Config: r.updateIdentitySystemAssigned(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.updateIdentityUserAssigned(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.updateIdentitySystemAssigned(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -171,7 +192,7 @@ resource "azurerm_healthcare_fhir_service" "test" {
`, r.template(data), data.RandomInteger)
}

func (r HealthcareApiFhirServiceResource) updateIdentity(data acceptance.TestData) string {
func (r HealthcareApiFhirServiceResource) updateIdentitySystemAssigned(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_healthcare_fhir_service" "test" {
Expand All @@ -193,6 +214,38 @@ resource "azurerm_healthcare_fhir_service" "test" {
`, r.template(data), data.RandomInteger)
}

func (r HealthcareApiFhirServiceResource) updateIdentityUserAssigned(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

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_healthcare_fhir_service" "test" {
name = "fhir%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
workspace_id = azurerm_healthcare_workspace.test.id
kind = "fhir-R4"

authentication {
authority = "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47"
audience = "https://acctestfhir.fhir.azurehealthcareapis.com"
}

identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.test.id
]
}
}
`, r.template(data), data.RandomInteger, data.RandomInteger)
}

func (r HealthcareApiFhirServiceResource) requiresImport(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func dataSourceHealthcareIotConnector() *pluginsdk.Resource {
ValidateFunc: workspaces.ValidateWorkspaceID,
},

"identity": commonschema.SystemAssignedIdentityComputed(),
"identity": commonschema.SystemOrUserAssignedIdentityComputed(),

"eventhub_namespace_name": {
Type: pluginsdk.TypeString,
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/healthcare_fhir_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ The following arguments are supported:
---
An `identity` block supports the following:

* `type` - (Required) The type of identity used for the Healthcare FHIR service. Possible values are `SystemAssigned`.
* `type` - The type of managed identity to assign. Possible values are `UserAssigned` and `SystemAssigned`

* `identity_ids` - A list of one or more Resource IDs for User Assigned Managed identities to assign. Required when `type` is set to `UserAssigned`.

---
A `cors` block supports the following:
Expand Down