Skip to content

Commit c3e8b70

Browse files
authored
Merge pull request #345 from sassoftware/IAC-1196
chore: (IAC-1196) Update path pattern to support additional branches
2 parents 18c34b8 + f951885 commit c3e8b70

File tree

15 files changed

+65
-75
lines changed

15 files changed

+65
-75
lines changed

.github/workflows/linter-analysis.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Linter Analysis
22
on:
33
push:
4-
branches: ['*'] # '*' will cause the workflow to run on all commits to all branches.
4+
branches: ['**'] # '*' will cause the workflow to run on all commits to all branches.
55

66
jobs:
77
# Hadolint: Job-1
@@ -52,8 +52,11 @@ jobs:
5252
tflint_version: latest
5353
github_token: ${{ secrets.LINTER_TOKEN }}
5454

55+
- name: Initializing viya4-iac-azure
56+
run: terraform init
57+
5558
- name: Initializing TFLint
56-
run: TFLINT_LOG=info tflint --init -c .tflint.hcl
59+
run: TFLINT_LOG=info tflint --init -c "$(pwd)/linting-configs/.tflint.hcl"
5760

5861
- name: Run TFLint Action
59-
run: TFLINT_LOG=info tflint -c .tflint.hcl
62+
run: TFLINT_LOG=info tflint -c "$(pwd)/linting-configs/.tflint.hcl" --recursive

linting-configs/.tflint.hcl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ plugin "terraform" {
2626
rule "azurerm_kubernetes_cluster_default_node_pool_invalid_vm_size" {
2727
enabled = false
2828
}
29+
30+
# We specify the versions and providers in the top level versions.tf.
31+
# This stops it from throwing a warning when scanning our modules
32+
# in viya4-iac-azure/modules/
33+
rule "terraform_required_version" {
34+
enabled = false
35+
}
36+
37+
rule "terraform_required_providers" {
38+
enabled = false
39+
}

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ locals {
55

66
# Useful flags
77
ssh_public_key = (var.create_jump_vm || var.storage_type == "standard"
8-
? file(var.ssh_public_key)
8+
? can(file(var.ssh_public_key)) ? file(var.ssh_public_key) : var.ssh_public_key != null ? length(var.ssh_public_key) > 0 ? var.ssh_public_key : null : null
99
: null
1010
)
1111

main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ module "aks" {
131131

132132
aks_cluster_name = "${var.prefix}-aks"
133133
aks_cluster_rg = local.aks_rg.name
134-
aks_cluster_rg_id = local.aks_rg.id
135134
aks_cluster_dns_prefix = "${var.prefix}-aks"
136135
aks_cluster_sku_tier = var.aks_cluster_sku_tier
137136
aks_cluster_location = var.location
@@ -241,7 +240,6 @@ module "netapp" {
241240
prefix = var.prefix
242241
resource_group_name = local.aks_rg.name
243242
location = var.location
244-
vnet_name = module.vnet.name
245243
subnet_id = module.vnet.subnets["netapp"].id
246244
network_features = var.netapp_network_features
247245
service_level = var.netapp_service_level

modules/aks_node_pool/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ variable "min_nodes" {
8585

8686
variable "node_taints" {
8787
description = "A list of the taints added to new nodes during node pool create and scale. Changing this forces a new resource to be created."
88-
type = list(any)
89-
default = []
88+
type = list(any)
89+
default = []
9090
}
9191

9292
variable "node_labels" {

modules/azure_aks/main.tf

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33

44
# Reference: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster
55
resource "azurerm_kubernetes_cluster" "aks" {
6-
name = var.aks_cluster_name
7-
location = var.aks_cluster_location
8-
resource_group_name = var.aks_cluster_rg
9-
dns_prefix = var.aks_private_cluster == false || var.aks_cluster_private_dns_zone_id == "" ? var.aks_cluster_dns_prefix : null
10-
dns_prefix_private_cluster = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_dns_prefix : null
11-
12-
sku_tier = var.aks_cluster_sku_tier
13-
role_based_access_control_enabled = true
14-
http_application_routing_enabled = false
15-
6+
name = var.aks_cluster_name
7+
location = var.aks_cluster_location
8+
resource_group_name = var.aks_cluster_rg
9+
dns_prefix = var.aks_private_cluster == false || var.aks_cluster_private_dns_zone_id == "" ? var.aks_cluster_dns_prefix : null
10+
dns_prefix_private_cluster = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_dns_prefix : null
11+
12+
sku_tier = var.aks_cluster_sku_tier
13+
role_based_access_control_enabled = true
14+
http_application_routing_enabled = false
15+
1616
# https://docs.microsoft.com/en-us/azure/aks/supported-kubernetes-versions
1717
# az aks get-versions --location eastus -o table
18-
kubernetes_version = var.kubernetes_version
19-
api_server_authorized_ip_ranges = var.aks_cluster_endpoint_public_access_cidrs
20-
private_cluster_enabled = var.aks_private_cluster
21-
private_dns_zone_id = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_private_dns_zone_id : (var.aks_private_cluster ? "System" : null)
18+
kubernetes_version = var.kubernetes_version
19+
api_server_authorized_ip_ranges = var.aks_cluster_endpoint_public_access_cidrs
20+
private_cluster_enabled = var.aks_private_cluster
21+
private_dns_zone_id = var.aks_private_cluster && var.aks_cluster_private_dns_zone_id != "" ? var.aks_cluster_private_dns_zone_id : (var.aks_private_cluster ? "System" : null)
2222

2323
network_profile {
2424
network_plugin = var.aks_network_plugin
@@ -45,7 +45,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
4545
content {
4646
admin_username = var.aks_cluster_node_admin
4747
ssh_key {
48-
key_data = var.aks_cluster_ssh_public_key
48+
key_data = var.aks_cluster_ssh_public_key
4949
}
5050
}
5151
}
@@ -80,7 +80,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
8080
dynamic "identity" {
8181
for_each = var.aks_uai_id == null ? [] : [1]
8282
content {
83-
type = "UserAssigned"
83+
type = "UserAssigned"
8484
identity_ids = [var.aks_uai_id]
8585
}
8686
}
@@ -108,8 +108,8 @@ resource "azurerm_kubernetes_cluster" "aks" {
108108

109109
}
110110

111-
data "azurerm_public_ip" "cluster_public_ip" {
112-
count = var.cluster_egress_type == "loadBalancer" ? 1 : 0
111+
data "azurerm_public_ip" "cluster_public_ip" {
112+
count = var.cluster_egress_type == "loadBalancer" ? 1 : 0
113113

114114
# effective_outbound_ips is a set of strings, that needs to be converted to a list type
115115
name = split("/", tolist(azurerm_kubernetes_cluster.aks.network_profile[0].load_balancer_profile[0].effective_outbound_ips)[0])[8]

modules/azure_aks/variables.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ variable "aks_cluster_rg" {
1111
type = string
1212
}
1313

14-
variable "aks_cluster_rg_id" {
15-
description = "The `azurerm_kubernetes_cluster`'s id."
16-
type = string
17-
}
18-
1914
variable "aks_cluster_dns_prefix" {
2015
description = "DNS prefix specified when creating the managed cluster."
2116
type = string
@@ -146,7 +141,7 @@ variable "aks_dns_service_ip" {
146141
type = string
147142
default = "10.0.0.10"
148143
validation {
149-
condition = var.aks_dns_service_ip != null ? can(regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",var.aks_dns_service_ip)) : false
144+
condition = var.aks_dns_service_ip != null ? can(regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", var.aks_dns_service_ip)) : false
150145
error_message = "ERROR: aks_dns_service_ip - value must not be null and must be a valid IP address."
151146
}
152147

@@ -225,6 +220,6 @@ variable "cluster_egress_type" {
225220
}
226221

227222
variable "aks_cluster_private_dns_zone_id" {
228-
type = string
223+
type = string
229224
default = ""
230225
}

modules/azurerm_netapp/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ output "netapp_pool_id" {
1010
}
1111

1212
output "netapp_endpoint" {
13-
value = azurerm_netapp_volume.anf.mount_ip_addresses.0
13+
value = azurerm_netapp_volume.anf.mount_ip_addresses[0]
1414
}
1515

1616
output "netapp_path" {

modules/azurerm_netapp/variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
variable create_netapp {
5-
description = "Boolean flag to create Azure NetApp Files"
6-
type = bool
7-
default = false
8-
}
9-
104
variable "prefix" {
115
description = "A prefix used in the name for all the Azure resources created by this script."
126
type = string
@@ -22,11 +16,6 @@ variable "location" {
2216
type = string
2317
}
2418

25-
variable "vnet_name" {
26-
description = "Azure Virtual Network"
27-
type = string
28-
}
29-
3019
variable "subnet_id" {
3120
description = "Azure subnet id for Azure NetApp Files"
3221
type = string

modules/azurerm_postgresql_flex/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ resource "azurerm_postgresql_flexible_server" "flexpsql" {
4949
}
5050

5151
resource "azurerm_postgresql_flexible_server_configuration" "flexpsql" {
52-
for_each = {
53-
for config in var.postgresql_configurations:
54-
config.name => config
52+
for_each = {
53+
for config in var.postgresql_configurations :
54+
config.name => config
5555
}
5656

57-
name = each.value.name
58-
server_id = azurerm_postgresql_flexible_server.flexpsql.id
59-
value = each.value.value
57+
name = each.value.name
58+
server_id = azurerm_postgresql_flexible_server.flexpsql.id
59+
value = each.value.value
6060
}
6161

6262
resource "azurerm_postgresql_flexible_server_firewall_rule" "flexpsql" {

0 commit comments

Comments
 (0)