Skip to content

Commit c3b4369

Browse files
committed
Added variable for existing resource group
1 parent 55d9178 commit c3b4369

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

terraform/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "azurerm_subscription" "current" {}

terraform/resource_group.tf

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
resource "azurerm_resource_group" "main" {
2-
name = "calculators-and-converters"
3-
location = "Central India" # Change this to your preferred region
1+
resource "azurerm_resource_group" "rg" {
2+
name = var.resource_group_name
3+
location = var.location
44

5-
tags = {
6-
environment = "production"
5+
lifecycle {
6+
prevent_destroy = true
77
}
8+
}
9+
10+
import {
11+
to = azurerm_resource_group.rg
12+
id = "/subscriptions/${data.azurerm_subscription.current.subscription_id}/resourceGroups/${var.resource_group_name}"
813
}

terraform/variables.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
variable "resource_group_name" {
2+
default = "calculators-and-converters"
3+
}
4+
5+
variable "location" {
6+
default = "Central India"
7+
}
8+

0 commit comments

Comments
 (0)