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_log_analytics_cluster - support UserAssigned and SystemAssigned, UserAssigned identity #25940

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 @@ -52,7 +52,7 @@ func (l LogAnalyticsClusterResource) Arguments() map[string]*schema.Schema {

"location": commonschema.Location(),

"identity": commonschema.SystemAssignedIdentityRequiredForceNew(),
"identity": commonschema.SystemOrUserAssignedIdentityRequiredForceNew(),

"size_gb": {
Type: pluginsdk.TypeInt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ func TestAccLogAnalyticsCluster_basic(t *testing.T) {
})
}

func TestAccLogAnalyticsCluster_userAssignedIdentity(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_log_analytics_cluster", "test")
r := LogAnalyticsClusterResource{}

if os.Getenv("ARM_RUN_TEST_LOG_ANALYTICS_CLUSTERS") == "" {
t.Skip("Skipping as ARM_RUN_TEST_LOG_ANALYTICS_CLUSTERS is not specified")
return
}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.userAssignedIdentity(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccLogAnalyticsCluster_resize(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_log_analytics_cluster", "test")
r := LogAnalyticsClusterResource{}
Expand Down Expand Up @@ -161,3 +181,28 @@ resource "azurerm_log_analytics_cluster" "import" {
}
`, r.basic(data))
}

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

resource "azurerm_user_assigned_identity" "test" {
name = "acctestuai-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
}

resource "azurerm_log_analytics_cluster" "test" {
name = "acctest-LA-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location

identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.test.id,
]
}
}
`, r.template(data), data.RandomInteger)
}
8 changes: 6 additions & 2 deletions website/docs/r/log_analytics_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ The following arguments are supported:

An `identity` block supports the following:

* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Log Analytics Cluster. The only possible value is `SystemAssigned`. Changing this forces a new resource to be created.
* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Log Analytics Cluster. Possible values are `SystemAssigned` and `UserAssigned`. Changing this forces a new resource to be created.

~> **NOTE:** The assigned `principal_id` and `tenant_id` can be retrieved after the identity `type` has been set to `SystemAssigned` and the Log Analytics Cluster has been created. More details are available below.

* `identity_ids` - (Optional) A list of User Assigned Managed Identity IDs to be assigned to this Windows Web App Slot.

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

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
Expand All @@ -79,7 +83,7 @@ An `identity` block exports the following:

* `tenant_id` - The Tenant ID associated with this Managed Service Identity.

* `type` - (Required) The identity type of this Managed Service Identity.
* `type` - The identity type of this Managed Service Identity.

-> You can access the Principal ID via `azurerm_log_analytics_cluster.example.identity[0].principal_id` and the Tenant ID via `azurerm_log_analytics_cluster.example.identity[0].tenant_id`

Expand Down
Loading