Skip to content

Commit

Permalink
use new config module in vulnerability-scan in dev+playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Feb 7, 2024
1 parent 77d4fdb commit d87070a
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 89 deletions.
32 changes: 32 additions & 0 deletions terraform/subscriptions/modules/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
variable "configfile" {
type = string
default = "../config.yaml"
}

locals {
config = yamldecode(file(var.configfile))
}

output "environment" {
value = local.config.environment
}

output "location" {
value = local.config.location
}

output "common_resource_group" {
value = "common-${local.config.environment}"
}
output "cluster_resource_group" {
value = "clusters-${local.config.environment}"
}
output "vnet_resource_group" {
value = "cluster-vnet-hub-${local.config.environment}"
}
output "key_vault_name" {
value = "radix-kv-${local.config.environment}"
}
output "backend" {
value = local.config.backend
}
2 changes: 0 additions & 2 deletions terraform/subscriptions/s941/dev/common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ variable "resource_groups_ver1" {
role_definition_name = "Log Analytics Contributor"
policyassignment = true
policy_name = "Radix-Enforce-Diagnostics-AKS-Clusters"


}
}

Expand Down
9 changes: 9 additions & 0 deletions terraform/subscriptions/s941/dev/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
environment: "dev"
location: "northeurope"
backend:
resource_group_name: "s941-tfstate"
storage_account_name: "s941radixinfra"
container_name: "infrastructure"
subscription_id: "16ede44b-1f74-40a5-b428-46cca9a5741b"
tenant_id: "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"

34 changes: 0 additions & 34 deletions terraform/subscriptions/s941/dev/vulnerability-scanner/input.tf

This file was deleted.

22 changes: 16 additions & 6 deletions terraform/subscriptions/s941/dev/vulnerability-scanner/main.tf
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
module "resourcegroup" {
source = "../../../modules/resourcegroups"
name = "${var.resourse_group_name}-${local.external_outputs.common.data.enviroment}"
location = local.external_outputs.common.data.location
name = "${var.resourse_group_name}-${module.config.environment}"
location = module.config.location
}

module "config" {
source = "../../../modules/config"
}

# TODO: Migrate keys to radix-kv-dev when ready
data "azurerm_key_vault" "keyvault" {
name = "radix-vault-dev" # module.config.key_vault_name
resource_group_name = "common" # module.config.common_resource_group
}

data "azurerm_key_vault_secret" "keyvault_secrets" {
name = var.keyvault_dbadmin_secret_name
key_vault_id = local.external_outputs.keyvault.vault_id
key_vault_id = data.azurerm_key_vault.keyvault.id
}

# MS SQL Server
module "mssql-database" {
source = "../../../modules/mssqldatabase"
env = local.external_outputs.common.data.enviroment
env = module.config.environment
database_name = "radix-vulnerability-scan"
server_name = "sql-radix-vulnerability-scan-${local.external_outputs.common.data.enviroment}"
server_name = "sql-radix-vulnerability-scan-${module.config.environment}"
admin_adgroup = var.admin-adgroup
administrator_login = "radix"
administrator_password = data.azurerm_key_vault_secret.keyvault_secrets.value
rg_name = module.resourcegroup.data.name
location = local.external_outputs.common.data.location
location = module.config.location
public_network_access_enabled = true
zone_redundant = false

Expand Down
9 changes: 9 additions & 0 deletions terraform/subscriptions/s941/playground/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
environment: "playground"
location: "northeurope"
backend:
resource_group_name: "s941-tfstate"
storage_account_name: "s941radixinfra"
container_name: "infrastructure"
subscription_id: "16ede44b-1f74-40a5-b428-46cca9a5741b"
tenant_id: "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@

module "config" {
source = "../../../modules/config"
}
module "resourcegroup" {
source = "../../../modules/resourcegroups"
name = "${var.resourse_group_name}-${local.external_outputs.common.data.enviroment}"
location = local.external_outputs.common.data.location
name = "vulnerability-scan-${module.config.environment}"
location = module.config.location
}

data "azurerm_key_vault" "keyvault" {
name = "radix-vault-dev"
resource_group_name = "common"
name = module.config.key_vault_name
resource_group_name = module.config.common_resource_group
}
data "azurerm_key_vault_secret" "keyvault_secrets" {
name = var.keyvault_dbadmin_secret_name
key_vault_id = data.azurerm_key_vault.keyvault.id # local.external_outputs.keyvault.vault_id
key_vault_id = data.azurerm_key_vault.keyvault.id
}

# MS SQL Server
module "mssql-database" {
source = "../../../modules/mssqldatabase"
env = local.external_outputs.common.data.enviroment
env = module.config.environment
database_name = "radix-vulnerability-scan"
server_name = "sql-radix-vulnerability-scan-${local.external_outputs.common.data.enviroment}"
server_name = "sql-radix-vulnerability-scan-${module.config.environment}"
admin_adgroup = var.admin-adgroup
administrator_login = "radix"
administrator_password = data.azurerm_key_vault_secret.keyvault_secrets.value
rg_name = module.resourcegroup.data.name
location = local.external_outputs.common.data.location
location = module.config.location
public_network_access_enabled = false
zone_redundant = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ variable "admin-adgroup" {
default = "Radix SQL server admin - playground"
}

variable "resourse_group_name" {
type = string
default = "vulnerability-scan"
}

variable "keyvault_dbadmin_secret_name" {
type = string
default = "radix-vulnerability-scan-db-admin"
Expand Down

0 comments on commit d87070a

Please sign in to comment.