Skip to content

Commit

Permalink
support for attaching to AMPLS (#80)
Browse files Browse the repository at this point in the history
* connect to existing AMPLS

* post pr-check update
  • Loading branch information
rbradley51 authored Aug 26, 2024
1 parent dcc4071 commit 9786c4c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.5)

- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (~> 1.14)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)

- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)
Expand All @@ -22,6 +24,7 @@ The following requirements are needed by this module:

The following resources are used by this module:

- [azapi_resource.ampls](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
- [azurerm_log_analytics_workspace.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) (resource)
- [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
- [azurerm_monitor_diagnostic_setting.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) (resource)
Expand Down Expand Up @@ -293,6 +296,22 @@ Type: `string`

Default: `"PrivateOnly"`

### <a name="input_monitor_private_link_scoped_resource"></a> [monitor\_private\_link\_scoped\_resource](#input\_monitor\_private\_link\_scoped\_resource)

Description: - `name` - Defaults to the name of the Log Analytics Workspace.
- `resource_id` - Resource ID of an existing Monitor Private Link Scope to connect to.

Type:

```hcl
map(object({
name = optional(string)
resource_id = string
}))
```

Default: `{}`

### <a name="input_monitor_private_link_scoped_service_name"></a> [monitor\_private\_link\_scoped\_service\_name](#input\_monitor\_private\_link\_scoped\_service\_name)

Description: (Required) The name of the Azure Monitor Private Link Scoped Service. Changing this forces a new resource to be created.
Expand Down
13 changes: 13 additions & 0 deletions main.ampls_connect.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "azapi_resource" "ampls" {
for_each = var.monitor_private_link_scoped_resource

type = "Microsoft.Insights/privateLinkScopes/scopedResources@2021-07-01-preview"
body = jsonencode({
properties = {
linkedResourceId = azurerm_log_analytics_workspace.this.id
}
})
ignore_casing = true
name = each.value.name != null ? each.value.name : azurerm_log_analytics_workspace.this.name
parent_id = each.value.resource_id
}
12 changes: 8 additions & 4 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ terraform {
required_version = "~> 1.5"
required_providers {
# TODO: Ensure all required providers are listed here.
azapi = {
source = "Azure/azapi"
version = "~> 1.14"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.71"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
modtm = {
source = "Azure/modtm"
version = "~> 0.3"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ variable "monitor_private_link_scope_query_access_mode" {
description = "(Optional) The default query access mode for the associated private endpoints in scope. Possible values are 'Open' and 'PrivateOnly'."
}

variable "monitor_private_link_scoped_resource" {
type = map(object({
name = optional(string)
resource_id = string
}))
default = {}
description = <<DESCRIPTION
- `name` - Defaults to the name of the Log Analytics Workspace.
- `resource_id` - Resource ID of an existing Monitor Private Link Scope to connect to.
DESCRIPTION
}

variable "monitor_private_link_scoped_service_name" {
type = string
default = null
Expand Down

0 comments on commit 9786c4c

Please sign in to comment.