|
| 1 | +# # resource "azurerm_resource_group" "azrm" { |
| 2 | + |
| 3 | +# # # for_each = { |
| 4 | +# # # dc1-apps = "eastus" |
| 5 | +# # # dc2-apps = "eastus2" |
| 6 | +# # # dc3-apps = "westus" |
| 7 | +# # # } |
| 8 | +# # # name = "${each.key}-rg" |
| 9 | +# # # location = each.value |
| 10 | + |
| 11 | +# # # for_each = toset(["eastus", "eastus2", "westus"]) |
| 12 | +# # # name = "rg-${each.key}" |
| 13 | +# # # location=each.value |
| 14 | + |
| 15 | + |
| 16 | +# # } |
| 17 | + |
| 18 | + |
| 19 | +# resource "azurerm_resource_group" "azrg" { |
| 20 | + |
| 21 | +# count = length(var.env2) |
| 22 | +# name = "${local.rg_name}-${count.index}-rg" |
| 23 | +# location = var.location |
| 24 | + |
| 25 | +# } |
| 26 | + |
| 27 | +resource "azurerm_resource_group" "azrm" { |
| 28 | + # for_each = var.env |
| 29 | + # count = 3 |
| 30 | + name = "${var.business_unit}-${var.resource_group_name}" |
| 31 | + # name = "my-resource-group_${count.index}" |
| 32 | + location = var.location |
| 33 | + |
| 34 | + tags = { |
| 35 | + "addition" = "minus" |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +resource "random_string" "new1" { |
| 40 | + # for_each = var.env |
| 41 | + length = 16 |
| 42 | + special = false |
| 43 | + upper = false |
| 44 | +} |
| 45 | + |
| 46 | +# module "vnet" { |
| 47 | +# source = "Azure/vnet/azurerm" |
| 48 | +# version = "4.1.0" |
| 49 | +# # insert the 3 required variables here |
| 50 | +# resource_group_name = local.rg_name |
| 51 | +# use_for_each = false |
| 52 | +# # for_each = var.env |
| 53 | +# vnet_location = azurerm_resource_group.azrm.location |
| 54 | +# depends_on = [azurerm_resource_group.azrm] |
| 55 | +# address_space = (var.env != "pat" ? var.virtual_network_address_space_for_dev : ["10.0.0.0/24"]) |
| 56 | +# subnet_names = ["subnet1", "subnet2", "subnet3"] |
| 57 | +# subnet_prefixes = [ "10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24" ] |
| 58 | +# } |
| 59 | +# resource "azurerm_virtual_network" "vmnetwork" { |
| 60 | + |
| 61 | +# # for_each = var.env |
| 62 | + |
| 63 | +# count = (var.env == "dev" ? 1 : 3) |
| 64 | +# name = "${local.vnet_name}-${count.index}" |
| 65 | +# location = azurerm_resource_group.azrm.location |
| 66 | +# resource_group_name = local.rg_name |
| 67 | +# address_space = (var.env != "pat" ? var.virtual_network_address_space_for_dev : ["10.0.0.0/24"]) |
| 68 | +# # dns_servers = ["10.0.0.4", "10.0.0.5"] |
| 69 | +# tags = var.common_tags |
| 70 | + |
| 71 | +# } |
| 72 | + |
| 73 | + |
| 74 | +resource "azurerm_storage_account" "storage_account" { |
| 75 | + name = "storagea98038" |
| 76 | + resource_group_name = azurerm_resource_group.azrm.name |
| 77 | + |
| 78 | + location = var.location |
| 79 | + account_tier = var.storage_account_tier |
| 80 | + account_replication_type = var.storage_account_replication_type |
| 81 | + account_kind = var.storage_account_kind |
| 82 | + |
| 83 | + static_website { |
| 84 | + index_document = var.static_website_index_document |
| 85 | + error_404_document = var.static_website_error_404_document |
| 86 | + |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +# resource "azurerm_subnet" "sn1" { |
| 93 | + |
| 94 | +# for_each = var.env |
| 95 | +# name = "${azurerm_virtual_network.vmnetwork[each.key].name}-subnte1" |
| 96 | +# resource_group_name = azurerm_resource_group.azrm.name |
| 97 | +# virtual_network_name =mo |
| 98 | +# address_prefixes = module.vnet.vnet_address_space |
| 99 | +# } |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +# resource "azurerm_public_ip" "pubip" { |
| 104 | + |
| 105 | +# # lifecycle { |
| 106 | +# # prevent_destroy = true |
| 107 | +# # } |
| 108 | + |
| 109 | +# # depends_on = [ azurerm_virtual_network.vmnetwork, |
| 110 | +# # azurerm_subnet.sn1 ] |
| 111 | +# # count =1 |
| 112 | +# name = "acceptanceTestPublicIp-${var.resource_group_name}" |
| 113 | +# resource_group_name = azurerm_resource_group.azrm.name |
| 114 | +# location = azurerm_resource_group.azrm.location |
| 115 | +# allocation_method = "Static" |
| 116 | +# domain_name_label = "check-string" |
| 117 | +# sku = "Standard" |
| 118 | + |
| 119 | +# tags = { |
| 120 | +# environment = "Production" |
| 121 | +# } |
| 122 | +# } |
| 123 | + |
| 124 | +# # element(list,id) |
| 125 | +# # lookup(map,key,default) |
| 126 | +# # # resource "azurerm_public_ip" "pubip" { |
| 127 | +# # # for_each = toset(["vm1", "vm2"]) |
| 128 | + |
| 129 | +# # # # depends_on = [ |
| 130 | +# # # # azurerm_virtual_network.vmnetwork, |
| 131 | +# # # # azurerm_network_interface.vmnic |
| 132 | +# # # # ] |
| 133 | + |
| 134 | +# # # # depends_on = [ azurerm_virtual_network.vmnetwork, |
| 135 | +# # # # azurerm_subnet.sn1 ] |
| 136 | +# # # # count = 2 |
| 137 | +# # # name = "pbip-${each.key}" |
| 138 | +# # # resource_group_name = azurerm_resource_group.azrm.name |
| 139 | +# # # location = azurerm_resource_group.azrm.location |
| 140 | +# # # allocation_method = "Static" |
| 141 | + |
| 142 | +# # # domain_name_label = "check-string${random_string.new1.id}${each.key}" |
| 143 | + |
| 144 | +# # # tags = { |
| 145 | +# # # environment = "Production" |
| 146 | +# # # } |
| 147 | +# # # } |
| 148 | + |
| 149 | + |
| 150 | +# resource "azurerm_network_interface" "vmnic" { |
| 151 | +# depends_on = [ module.vnet ] |
| 152 | +# # count = 2 |
| 153 | +# # for_each = toset(["vm1", "vm2"]) |
| 154 | +# # name = "vmnic${count.index}" |
| 155 | +# name = "vmnic-${module.vnet.vnet_name}" |
| 156 | +# location = module.vnet.vnet_location |
| 157 | +# resource_group_name = azurerm_resource_group.azrm.name |
| 158 | + |
| 159 | +# ip_configuration { |
| 160 | +# name = "internal" |
| 161 | +# subnet_id = module.vnet.vnet_subnets[0] |
| 162 | +# private_ip_address_allocation = "Dynamic" |
| 163 | +# public_ip_address_id = azurerm_public_ip.pubip.id #key is equal to the name of pbip=pbip-vm1 |
| 164 | +# # element(azurerm_public_ip.pubip[*].id,count.index) |
| 165 | +# } |
| 166 | +# } |
| 167 | + |
| 168 | + |
| 169 | +# resource "azurerm_linux_virtual_machine" "linux_machine" { |
| 170 | +# # count = 2 |
| 171 | +# for_each = azurerm_network_interface.vmnic |
| 172 | +# name = "mymachine-linux${each.key}" |
| 173 | +# location = azurerm_resource_group.azrm.location |
| 174 | +# resource_group_name = azurerm_resource_group.azrm.name |
| 175 | +# admin_username = "lokesh" |
| 176 | +# size = "Standard_DS1_v2" |
| 177 | +# # network_interface_ids = element([azurerm_network_interface.vmnic[*].id],count.index) |
| 178 | +# network_interface_ids = [azurerm_network_interface.vmnic[each.key].id] |
| 179 | + |
| 180 | +# admin_ssh_key { |
| 181 | +# username = "lokesh" |
| 182 | +# public_key = file("${path.module}/ssh-keys/terraform-azure.pub") |
| 183 | +# } |
| 184 | +# os_disk { |
| 185 | +# name = "OSDISK${each.key}" |
| 186 | +# caching = "ReadWrite" |
| 187 | +# storage_account_type = "Standard_LRS" |
| 188 | +# } |
| 189 | +# source_image_reference { |
| 190 | +# publisher = "Canonical" |
| 191 | +# offer = "0001-com-ubuntu-server-focal" |
| 192 | +# sku = "20_04-lts" |
| 193 | +# version = "latest" |
| 194 | +# } |
| 195 | +# connection { |
| 196 | +# type = "ssh" |
| 197 | +# host = self.public_ip_address |
| 198 | +# } |
| 199 | +# } |
| 200 | + |
0 commit comments