-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
80 lines (71 loc) · 2.92 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
73
74
75
76
77
78
79
80
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.60"
}
}
}
provider "azurerm" {
features {}
}
terraform {
backend "azurerm" {
}
}
locals {
storage_account_prefix = "boot"
}
data "azurerm_client_config" "current" {
}
# Generate randon name for virtual machine
resource "random_string" "storage_account_suffix" {
length = 8
special = false
lower = true
upper = false
number = false
}
module "storage_account" {
source = "./modules/storage_account"
name = "${local.storage_account_prefix}${random_string.storage_account_suffix.result}"
location = var.location
resource_group_name = var.resource_group_name
account_kind = var.storage_account_kind
account_tier = var.storage_account_tier
replication_type = var.storage_account_replication_type
}
data "azurerm_log_analytics_workspace" "log_analytics_workspace" {
name = var.log_analytics_workspace_name
resource_group_name = var.log_analytics_resource_group_name
}
data "azurerm_subnet" "subnet" {
name = var.subnet_name
virtual_network_name = var.virtual_network_name
resource_group_name = var.virtual_network_resource_group_name
}
module "virtual_machine" {
source = "./modules/virtual_machine"
name = var.vm_name
size = var.vm_size
location = var.location
public_ip = var.vm_public_ip
vm_user = var.admin_username
admin_ssh_public_key = var.ssh_public_key
os_disk_image = var.vm_os_disk_image
resource_group_name = var.resource_group_name
subnet_id = data.azurerm_subnet.subnet.id
os_disk_storage_account_type = var.vm_os_disk_storage_account_type
boot_diagnostics_storage_account = module.storage_account.primary_blob_endpoint
log_analytics_workspace_id = data.azurerm_log_analytics_workspace.log_analytics_workspace.workspace_id
log_analytics_workspace_key = data.azurerm_log_analytics_workspace.log_analytics_workspace.primary_shared_key
log_analytics_workspace_resource_id = data.azurerm_log_analytics_workspace.log_analytics_workspace.id
log_analytics_retention_days = var.log_analytics_retention_days
script_storage_account_name = var.script_storage_account_name
script_storage_account_key = var.script_storage_account_key
container_name = var.container_name
script_name = var.script_name
azure_devops_url = var.azure_devops_url
azure_devops_pat = var.azure_devops_pat
azure_devops_agent_pool_name = var.azure_devops_agent_pool_name
}