-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
32 lines (29 loc) · 972 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
locals {
type_codes = {
"DevTest" = "MS-AZR-0148P",
"Prod" = "MS-AZR-0017P"
}
}
data "azurerm_client_config" "current" {}
data "external" "az_client_config" {
program = ["pwsh", "-command", "@{tenant=$env:ARM_TENANT_ID;client=$env:ARM_CLIENT_ID;secret=$env:ARM_CLIENT_SECRET} | ConvertTo-Json | Write-Output"]
}
resource "shell_script" "subscription" {
working_directory = path.module
interpreter = ["pwsh", "-command"]
lifecycle_commands {
create = ". ./subscription.ps1; Create"
read = ". ./subscription.ps1; Read"
update = ". ./subscription.ps1; Update"
delete = ". ./subscription.ps1; Delete"
}
environment = {
name = var.name
type = local.type_codes[var.type]
}
sensitive_environment = {
azsub_client_id = data.external.az_client_config.result.client
azsub_client_secret = data.external.az_client_config.result.secret
azsub_tenant_id = data.azurerm_client_config.current.tenant_id
}
}