-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
72 lines (58 loc) · 1.78 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
terraform {
required_version = ">=0.12"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.0"
}
azuread = {
source = "hashicorp/azuread"
version = "~>2.0"
}
http = {
source = "hashicorp/http"
version = "~>2.1.0"
}
random = {
source = "hashicorp/random"
version = "~>3.1.0"
}
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id
}
provider "azuread" {
tenant_id = var.tenant_id
}
provider "http" {
}
provider "random" {
}
data "azurerm_client_config" "current" {}
data "azurerm_virtual_network" "current" {
count = local.virtual_network_count == 1 ? 0 : 1
name = var.virtual_network_name
resource_group_name = var.virtual_network_resource_group_name
}
data "azuread_client_config" "current" {}
data "azuread_service_principal" "container_instance" {
display_name = "Azure Container Instance Service"
}
data "http" "myip" {
url = "http://ipv4.icanhazip.com"
}
resource "random_string" "resource_suffix" {
length = 8
special = false
lower = true
upper = false
}
locals {
region = var.virtual_network_name != "" ? data.azurerm_virtual_network.current[0].location : var.region
resource_group_name = var.virtual_network_name != "" ? data.azurerm_virtual_network.current[0].resource_group_name : azurerm_resource_group.cloudshell[0].name
virtual_network_count = var.virtual_network_name != "" ? 0 : 1
virtual_network_id = var.virtual_network_name != "" ? data.azurerm_virtual_network.current[0].id : azurerm_virtual_network.cloudshell[0].id
virtual_network_name = var.virtual_network_name != "" ? data.azurerm_virtual_network.current[0].name : azurerm_virtual_network.cloudshell[0].name
}