Skip to content

Commit eec104a

Browse files
committed
Clean up
1 parent 09fa7ad commit eec104a

File tree

11 files changed

+72
-160
lines changed

11 files changed

+72
-160
lines changed

scenarios/AksOpenAiTerraform/terraform/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ resource "random_string" "rg_suffix" {
2323
}
2424

2525
locals {
26-
tenant_id = data.azurerm_client_config.current.tenant_id
26+
tenant_id = data.azurerm_client_config.current.tenant_id
2727
subscription_id = data.azurerm_client_config.current.subscription_id
28-
random_id = random_string.rg_suffix.result
28+
random_id = random_string.rg_suffix.result
2929

3030
vm_subnet_name = "VmSubnet"
3131
system_node_pool_subnet_name = "SystemSubnet"
@@ -158,7 +158,7 @@ module "deployment_script" {
158158
resource_group_name = azurerm_resource_group.rg.name
159159

160160
azure_cli_version = "2.64.0"
161-
aks_cluster_id = module.aks_cluster.id
161+
aks_cluster_id = module.aks_cluster.id
162162
managed_identity_name = "ScriptManagedIdentity"
163163
aks_cluster_name = module.aks_cluster.name
164164
hostname = "magic8ball.contoso.com"
@@ -177,10 +177,12 @@ module "deployment_script" {
177177

178178
module "log_analytics_workspace" {
179179
source = "./modules/log_analytics"
180-
name = "${local.log_analytics_workspace_name}"
180+
name = local.log_analytics_workspace_name
181181
location = var.location
182182
resource_group_name = azurerm_resource_group.rg.name
183183

184+
sku = "PerGB2018"
185+
retention_in_days = local.log_analytics_retention_days
184186
solution_plan_map = {
185187
ContainerInsights = {
186188
product = "OMSGallery/ContainerInsights"

scenarios/AksOpenAiTerraform/terraform/modules/deployment_script/main.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ resource "azurerm_user_assigned_identity" "script_identity" {
55
}
66

77
resource "azurerm_role_assignment" "network_contributor_assignment" {
8-
scope = var.aks_cluster_id
9-
role_definition_name = "Azure Kubernetes Service Cluster Admin Role"
10-
principal_id = azurerm_user_assigned_identity.script_identity.principal_id
8+
scope = var.aks_cluster_id
9+
role_definition_name = "Azure Kubernetes Service Cluster Admin Role"
10+
principal_id = azurerm_user_assigned_identity.script_identity.principal_id
1111
}
1212

1313
resource "azurerm_resource_deployment_script_azure_cli" "script" {
1414
name = var.name
1515
resource_group_name = var.resource_group_name
1616
location = var.location
1717

18-
version = var.azure_cli_version
19-
retention_interval = "P1D"
20-
command_line = "'foo' 'bar'"
21-
cleanup_preference = "OnSuccess"
22-
force_update_tag = "1"
23-
timeout = "PT30M"
24-
primary_script_uri = var.primary_script_uri
18+
version = var.azure_cli_version
19+
retention_interval = "P1D"
20+
command_line = "'foo' 'bar'"
21+
cleanup_preference = "OnSuccess"
22+
force_update_tag = "1"
23+
timeout = "PT30M"
24+
primary_script_uri = var.primary_script_uri
2525

2626
identity {
2727
type = "UserAssigned"

scenarios/AksOpenAiTerraform/terraform/modules/deployment_script/variables.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
variable "resource_group_name" {
2-
type = string
2+
type = string
33
}
44

55
variable "location" {
6-
type = string
6+
type = string
77
}
88

99
variable "name" {
10-
type = string
10+
type = string
1111
}
1212

1313
variable "aks_cluster_id" {
14-
type = string
14+
type = string
1515
}
1616

1717
variable "azure_cli_version" {
18-
type = string
18+
type = string
1919
}
2020

2121
variable "managed_identity_name" {
22-
type = string
22+
type = string
2323
}
2424

2525
variable "primary_script_uri" {
26-
type = string
26+
type = string
2727
}
2828

2929
variable "aks_cluster_name" {
30-
type = string
30+
type = string
3131
}
3232

3333
variable "tenant_id" {
34-
type = string
34+
type = string
3535
}
3636

3737
variable "subscription_id" {
38-
type = string
38+
type = string
3939
}
4040

4141
variable "hostname" {
42-
type = string
42+
type = string
4343
}
4444

4545
variable "namespace" {
46-
type = string
46+
type = string
4747
}
4848

4949
variable "service_account_name" {
50-
type = string
50+
type = string
5151
}
5252

5353
variable "workload_managed_identity_client_id" {
54-
type = string
54+
type = string
5555
}
5656

5757
variable "email" {

scenarios/AksOpenAiTerraform/terraform/modules/key_vault/main.tf

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
resource "azurerm_key_vault" "key_vault" {
2-
name = var.name
3-
location = var.location
4-
resource_group_name = var.resource_group_name
5-
tenant_id = var.tenant_id
2+
name = var.name
3+
location = var.location
4+
resource_group_name = var.resource_group_name
5+
tenant_id = var.tenant_id
6+
67
sku_name = var.sku_name
78
enabled_for_deployment = var.enabled_for_deployment
89
enabled_for_disk_encryption = var.enabled_for_disk_encryption
@@ -16,10 +17,8 @@ resource "azurerm_key_vault" "key_vault" {
1617
}
1718

1819
network_acls {
19-
bypass = var.bypass
20-
default_action = var.default_action
21-
ip_rules = var.ip_rules
22-
virtual_network_subnet_ids = var.virtual_network_subnet_ids
20+
bypass = var.bypass
21+
default_action = var.default_action
2322
}
2423
}
2524

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
output "name" {
2-
value = azurerm_key_vault.key_vault.name
3-
description = "Specifies the name of the key vault."
2+
value = azurerm_key_vault.key_vault.name
43
}
54

65
output "id" {
7-
value = azurerm_key_vault.key_vault.id
8-
description = "Specifies the resource id of the key vault."
6+
value = azurerm_key_vault.key_vault.id
97
}
Lines changed: 15 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,59 @@
11
variable "name" {
2-
description = "(Required) Specifies the name of the key vault."
3-
type = string
2+
type = string
43
}
54

65
variable "resource_group_name" {
7-
description = "(Required) Specifies the resource group name of the key vault."
8-
type = string
6+
type = string
97
}
108

119
variable "location" {
12-
description = "(Required) Specifies the location where the key vault will be deployed."
13-
type = string
10+
type = string
1411
}
1512

1613
variable "tenant_id" {
17-
description = "(Required) The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault."
18-
type = string
14+
type = string
1915
}
2016

2117
variable "sku_name" {
22-
description = "(Required) The Name of the SKU used for this Key Vault. Possible values are standard and premium."
23-
type = string
24-
default = "standard"
25-
26-
validation {
27-
condition = contains(["standard", "premium"], var.sku_name)
28-
error_message = "The value of the sku name property of the key vault is invalid."
29-
}
30-
}
31-
32-
variable "tags" {
33-
description = "(Optional) Specifies the tags of the log analytics workspace"
34-
type = map(any)
35-
default = {}
18+
type = string
3619
}
3720

3821
variable "enabled_for_deployment" {
39-
description = "(Optional) Boolean flag to specify whether Azure Virtual Machines are permitted to retrieve certificates stored as secrets from the key vault. Defaults to false."
40-
type = bool
41-
default = false
22+
type = bool
4223
}
4324

4425
variable "enabled_for_disk_encryption" {
45-
description = " (Optional) Boolean flag to specify whether Azure Disk Encryption is permitted to retrieve secrets from the vault and unwrap keys. Defaults to false."
46-
type = bool
47-
default = false
26+
type = bool
4827
}
4928

5029
variable "enabled_for_template_deployment" {
51-
description = "(Optional) Boolean flag to specify whether Azure Resource Manager is permitted to retrieve secrets from the key vault. Defaults to false."
52-
type = bool
53-
default = false
30+
type = bool
5431
}
5532

5633
variable "enable_rbac_authorization" {
57-
description = "(Optional) Boolean flag to specify whether Azure Key Vault uses Role Based Access Control (RBAC) for authorization of data actions. Defaults to false."
58-
type = bool
59-
default = false
34+
type = bool
6035
}
6136

6237
variable "purge_protection_enabled" {
63-
description = "(Optional) Is Purge Protection enabled for this Key Vault? Defaults to false."
64-
type = bool
65-
default = false
38+
type = bool
6639
}
6740

6841
variable "soft_delete_retention_days" {
69-
description = "(Optional) The number of days that items should be retained for once soft-deleted. This value can be between 7 and 90 (the default) days."
70-
type = number
71-
default = 30
42+
type = number
7243
}
7344

7445
variable "bypass" {
75-
description = "(Required) Specifies which traffic can bypass the network rules. Possible values are AzureServices and None."
76-
type = string
77-
default = "AzureServices"
78-
79-
validation {
80-
condition = contains(["AzureServices", "None"], var.bypass)
81-
error_message = "The valut of the bypass property of the key vault is invalid."
82-
}
46+
type = string
8347
}
8448

8549
variable "default_action" {
86-
description = "(Required) The Default Action to use when no rules match from ip_rules / virtual_network_subnet_ids. Possible values are Allow and Deny."
87-
type = string
88-
default = "Allow"
89-
90-
validation {
91-
condition = contains(["Allow", "Deny"], var.default_action)
92-
error_message = "The value of the default action property of the key vault is invalid."
93-
}
94-
}
95-
96-
variable "ip_rules" {
97-
description = "(Optional) One or more IP Addresses, or CIDR Blocks which should be able to access the Key Vault."
98-
default = []
99-
}
100-
101-
variable "virtual_network_subnet_ids" {
102-
description = "(Optional) One or more Subnet ID's which should be able to access this Key Vault."
103-
default = []
50+
type = string
10451
}
10552

10653
variable "log_analytics_workspace_id" {
107-
description = "Specifies the log analytics workspace id"
108-
type = string
54+
type = string
10955
}
11056

11157
variable "log_analytics_retention_days" {
112-
description = "Specifies the number of days of the retention policy"
113-
type = number
114-
default = 7
58+
type = number
11559
}

scenarios/AksOpenAiTerraform/terraform/modules/log_analytics/main.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
33
location = var.location
44
resource_group_name = var.resource_group_name
55
sku = var.sku
6-
retention_in_days = var.retention_in_days != "" ? var.retention_in_days : null
6+
retention_in_days = var.retention_in_days
77
}
88

99
resource "azurerm_log_analytics_solution" "la_solution" {
@@ -19,10 +19,4 @@ resource "azurerm_log_analytics_solution" "la_solution" {
1919
product = each.value.product
2020
publisher = each.value.publisher
2121
}
22-
23-
lifecycle {
24-
ignore_changes = [
25-
tags
26-
]
27-
}
2822
}
Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,23 @@
11
variable "resource_group_name" {
2-
description = "(Required) Specifies the resource group name"
3-
type = string
2+
type = string
43
}
54

65
variable "location" {
7-
description = "(Required) Specifies the location of the log analytics workspace"
8-
type = string
6+
type = string
97
}
108

119
variable "name" {
12-
description = "(Required) Specifies the name of the log analytics workspace"
13-
type = string
10+
type = string
1411
}
1512

1613
variable "sku" {
17-
description = "(Optional) Specifies the sku of the log analytics workspace"
18-
type = string
19-
default = "PerGB2018"
20-
21-
validation {
22-
condition = contains(["Free", "Standalone", "PerNode", "PerGB2018"], var.sku)
23-
error_message = "The log analytics sku is incorrect."
24-
}
14+
type = string
2515
}
2616

2717
variable "solution_plan_map" {
28-
description = "(Required) Specifies the map structure containing the list of solutions to be enabled."
29-
type = map(any)
30-
}
31-
32-
variable "tags" {
33-
description = "(Optional) Specifies the tags of the log analytics workspace"
34-
type = map(any)
35-
default = {}
18+
type = map(any)
3619
}
3720

3821
variable "retention_in_days" {
39-
description = " (Optional) Specifies the workspace data retention in days. Possible values are either 7 (Free Tier only) or range between 30 and 730."
40-
type = number
41-
default = 30
22+
type = number
4223
}

scenarios/AksOpenAiTerraform/terraform/modules/openai/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
resource "azurerm_cognitive_account" "openai" {
2-
name = var.name
3-
location = var.location
4-
resource_group_name = var.resource_group_name
5-
2+
name = var.name
3+
location = var.location
4+
resource_group_name = var.resource_group_name
5+
66
kind = "OpenAI"
77
custom_subdomain_name = var.custom_subdomain_name
88
sku_name = var.sku_name

0 commit comments

Comments
 (0)