Skip to content

Commit ec677b7

Browse files
committed
Wrap log_analytics_solution_id to an object to fix #263.
Add symbolic links notice in the readme.
1 parent 3d63a90 commit ec677b7

5 files changed

Lines changed: 45 additions & 8 deletions

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ This Terraform module deploys a Kubernetes cluster on Azure using AKS (Azure Kub
66

77
-> **NOTE:** If you have not assigned `client_id` or `client_secret`, A `SystemAssigned` identity will be created.
88

9+
-> **NOTE:** Since this repo contains some symbolic links, clone this repo via the following command is **HIGHLY RECOMMENDED**, or your repo might not work as expected on your machine:
10+
11+
```shell
12+
$ git clone -c core.symlinks=true <repository_url>
13+
```
14+
15+
Or you may need to set `core.sysmlinks` to `true` after you've cloned this repo then reset to the latest master branch:
16+
17+
```shell
18+
$ git config core.symlinks true
19+
$ git reset --hard origin/master
20+
```
21+
922
## Notice on Upgrade to V6.x
1023

1124
We've added a CI pipeline for this module to speed up our code review and to enforce a high code quality standard, if you want to contribute by submitting a pull request, please read [Pre-Commit & Pr-Check & Test](#Pre-Commit--Pr-Check--Test) section, or your pull request might be rejected by CI pipeline.
@@ -305,7 +318,7 @@ No modules.
305318
| <a name="input_kubernetes_version"></a> [kubernetes\_version](#input\_kubernetes\_version) | Specify which Kubernetes release to use. The default used is the latest Kubernetes version available in the region | `string` | `null` | no |
306319
| <a name="input_local_account_disabled"></a> [local\_account\_disabled](#input\_local\_account\_disabled) | (Optional) - If `true` local accounts will be disabled. Defaults to `false`. See [the documentation](https://docs.microsoft.com/azure/aks/managed-aad#disable-local-accounts) for more information. | `bool` | `null` | no |
307320
| <a name="input_location"></a> [location](#input\_location) | Location of cluster, if not defined it will be read from the resource-group | `string` | `null` | no |
308-
| <a name="input_log_analytics_solution_id"></a> [log\_analytics\_solution\_id](#input\_log\_analytics\_solution\_id) | (Optional) Existing azurerm\_log\_analytics\_solution ID. Providing ID disables creation of azurerm\_log\_analytics\_solution. | `string` | `null` | no |
321+
| <a name="input_log_analytics_solution"></a> [log\_analytics\_solution](#input\_log\_analytics\_solution) | (Optional) Object which contains existing azurerm\_log\_analytics\_solution ID. Providing ID disables creation of azurerm\_log\_analytics\_solution. | <pre>object({<br> id = string<br> })</pre> | `null` | no |
309322
| <a name="input_log_analytics_workspace"></a> [log\_analytics\_workspace](#input\_log\_analytics\_workspace) | (Optional) Existing azurerm\_log\_analytics\_workspace to attach azurerm\_log\_analytics\_solution. Providing the config disables creation of azurerm\_log\_analytics\_workspace. | <pre>object({<br> id = string<br> name = string<br> })</pre> | `null` | no |
310323
| <a name="input_log_analytics_workspace_enabled"></a> [log\_analytics\_workspace\_enabled](#input\_log\_analytics\_workspace\_enabled) | Enable the integration of azurerm\_log\_analytics\_workspace and azurerm\_log\_analytics\_solution: https://docs.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-onboard | `bool` | `true` | no |
311324
| <a name="input_log_analytics_workspace_resource_group_name"></a> [log\_analytics\_workspace\_resource\_group\_name](#input\_log\_analytics\_workspace\_resource\_group\_name) | (Optional) Resource group name to create azurerm\_log\_analytics\_solution. | `string` | `null` | no |

examples/named_cluster/main.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ resource "azurerm_log_analytics_workspace" "main" {
4646
sku = "PerGB2018"
4747
}
4848

49+
resource "azurerm_log_analytics_solution" "main" {
50+
location = local.resource_group.location
51+
resource_group_name = local.resource_group.name
52+
solution_name = "ContainerInsights"
53+
workspace_name = azurerm_log_analytics_workspace.main.name
54+
workspace_resource_id = azurerm_log_analytics_workspace.main.id
55+
56+
plan {
57+
product = "OMSGallery/ContainerInsights"
58+
publisher = "Microsoft"
59+
}
60+
}
61+
4962
module "aks_cluster_name" {
5063
source = "../.."
5164

@@ -58,7 +71,10 @@ module "aks_cluster_name" {
5871
disk_encryption_set_id = azurerm_disk_encryption_set.des.id
5972
identity_ids = [azurerm_user_assigned_identity.test.id]
6073
identity_type = "UserAssigned"
61-
log_analytics_workspace_enabled = true
74+
log_analytics_solution = {
75+
id = azurerm_log_analytics_solution.main.id
76+
}
77+
log_analytics_workspace_enabled = true
6278
log_analytics_workspace = {
6379
id = azurerm_log_analytics_workspace.main.id
6480
name = azurerm_log_analytics_workspace.main.name

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
# Abstract the decision whether to create an Analytics Workspace or not.
3-
create_analytics_solution = var.log_analytics_workspace_enabled && var.log_analytics_solution_id == null
3+
create_analytics_solution = var.log_analytics_workspace_enabled && var.log_analytics_solution == null
44
create_analytics_workspace = var.log_analytics_workspace_enabled && var.log_analytics_workspace == null
55
# Abstract the decision whether to use an Analytics Workspace supplied via vars, provision one ourselves or leave it null.
66
# This guarantees that local.log_analytics_workspace will contain a valid `id` and `name` IFF log_analytics_workspace_enabled

test/unit/unit_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ func TestLogAnalyticsWorkspaceEnabledNoSolutionProvidedShouldCreateSolution(t *t
9494
func TestLogAnalyticsWorkspaceEnabledSolutionProvidedShouldNotCreateSolution(t *testing.T) {
9595
vars := dummyRequiredVariables()
9696
vars["log_analytics_workspace_enabled"] = true
97-
vars["log_analytics_solution_id"] = "dummySolutionId"
97+
vars["log_analytics_solution"] = map[string]interface{}{
98+
"id": "dummySolutionId",
99+
}
98100
test_helper.RunE2ETest(t, "../../", "unit-test-fixture", terraform.Options{
99101
Upgrade: false,
100102
Vars: vars,

variables.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,17 @@ variable "location" {
228228
default = null
229229
}
230230

231-
variable "log_analytics_solution_id" {
232-
type = string
233-
description = "(Optional) Existing azurerm_log_analytics_solution ID. Providing ID disables creation of azurerm_log_analytics_solution."
231+
variable "log_analytics_solution" {
232+
type = object({
233+
id = string
234+
})
235+
description = "(Optional) Object which contains existing azurerm_log_analytics_solution ID. Providing ID disables creation of azurerm_log_analytics_solution."
234236
default = null
235-
nullable = true
237+
validation {
238+
condition = var.log_analytics_solution == null ? true : var.log_analytics_solution.id != null && var.log_analytics_solution.id != ""
239+
error_message = "`var.log_analytics_solution` must be `null` or an object with a valid `id`."
240+
}
241+
nullable = true
236242
}
237243

238244
variable "log_analytics_workspace" {

0 commit comments

Comments
 (0)