1- locals {
2- create_sa = var. azure_subscription_id == null || var. azure_tenant_id == null || var. azure_client_secret == null || var. azure_client_id == null
3- }
4-
51data "azuread_client_config" "current" {}
62
73data "azurerm_subscription" "primary" {}
84
95resource "azurerm_role_definition" "this" {
10- count = local . create_sa ? 1 : 0
6+ count = var . create_sa ? 1 : 0
117
128 name = var. name
139 scope = data. azurerm_subscription . primary . id
@@ -71,7 +67,7 @@ resource "azurerm_role_definition" "this" {
7167}
7268
7369resource "azuread_application" "this" {
74- count = local . create_sa ? 1 : 0
70+ count = var . create_sa ? 1 : 0
7571
7672 display_name = var. name
7773 owners = [
@@ -80,7 +76,7 @@ resource "azuread_application" "this" {
8076}
8177
8278resource "azuread_service_principal" "this" {
83- count = local . create_sa ? 1 : 0
79+ count = var . create_sa ? 1 : 0
8480
8581 client_id = azuread_application. this [0 ]. client_id
8682 owners = [
@@ -89,15 +85,15 @@ resource "azuread_service_principal" "this" {
8985}
9086
9187resource "azuread_service_principal_password" "this" {
92- count = local . create_sa ? 1 : 0
88+ count = var . create_sa ? 1 : 0
9389
9490 service_principal_id = azuread_service_principal. this [0 ]. id
9591 end_date_relative = var. end_date_relative
9692 end_date = var. end_date
9793}
9894
9995resource "azurerm_role_assignment" "this" {
100- count = local . create_sa ? 1 : 0
96+ count = var . create_sa ? 1 : 0
10197
10298 scope = data. azurerm_subscription . primary . id
10399 role_definition_id = azurerm_role_definition. this [0 ]. role_definition_resource_id
@@ -108,13 +104,13 @@ resource "volterra_cloud_credentials" "this" {
108104 name = var. name
109105 namespace = " system"
110106 azure_client_secret {
111- client_id = local . create_sa ? azuread_application. this [0 ]. client_id : var. azure_client_id
107+ client_id = var . create_sa ? azuread_application. this [0 ]. client_id : var. azure_client_id
112108 client_secret {
113109 clear_secret_info {
114- url = " string:///${ base64encode (local . create_sa ? azuread_service_principal_password. this [0 ]. value : var. azure_client_secret )} "
110+ url = " string:///${ base64encode (var . create_sa ? azuread_service_principal_password. this [0 ]. value : var. azure_client_secret )} "
115111 }
116112 }
117- subscription_id = local . create_sa ? replace (data. azurerm_subscription . primary . id , " //subscriptions//" , " " ) : var. azure_subscription_id
118- tenant_id = local . create_sa ? data. azuread_client_config . current . tenant_id : var. azure_tenant_id
113+ subscription_id = var . create_sa ? replace (data. azurerm_subscription . primary . id , " //subscriptions//" , " " ) : var. azure_subscription_id
114+ tenant_id = var . create_sa ? data. azuread_client_config . current . tenant_id : var. azure_tenant_id
119115 }
120116}
0 commit comments