Skip to content

Commit c8023a9

Browse files
committed
initial commit
1 parent 90f4bea commit c8023a9

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

examples/complete/.terraform.lock.hcl

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/complete/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module "redis" {
2+
// source = "kumarvna/redis/azurerm"
3+
// version = "1.0.0"
4+
source = "../../"
5+
6+
# By default, this module will create a resource group
7+
# proivde a name to use an existing resource group and set the argument
8+
# to `create_resource_group = false` if you want to existing resoruce group.
9+
# If you use existing resrouce group location will be the same as existing RG.
10+
create_resource_group = false
11+
resource_group_name = "rg-shared-westeurope-01"
12+
location = "westeurope"
13+
14+
15+
# Tags for Azure Resources
16+
tags = {
17+
Terraform = "true"
18+
Environment = "dev"
19+
Owner = "test-user"
20+
}
21+
}

main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#------------------------------------------------------------
2+
# Local configuration - Default (required).
3+
#------------------------------------------------------------
4+
5+
locals {
6+
resource_group_name = element(coalescelist(data.azurerm_resource_group.rgrp.*.name, azurerm_resource_group.rg.*.name, [""]), 0)
7+
location = element(coalescelist(data.azurerm_resource_group.rgrp.*.location, azurerm_resource_group.rg.*.location, [""]), 0)
8+
}
9+
10+
#---------------------------------------------------------
11+
# Resource Group Creation or selection - Default is "false"
12+
#----------------------------------------------------------
13+
data "azurerm_resource_group" "rgrp" {
14+
count = var.create_resource_group == false ? 1 : 0
15+
name = var.resource_group_name
16+
}
17+
18+
resource "azurerm_resource_group" "rg" {
19+
count = var.create_resource_group ? 1 : 0
20+
name = var.resource_group_name
21+
location = var.location
22+
tags = merge({ "Name" = format("%s", var.resource_group_name) }, var.tags, )
23+
}

variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variable "create_resource_group" {
2+
description = "Whether to create resource group and use it for all networking resources"
3+
default = true
4+
}
5+
6+
variable "resource_group_name" {
7+
description = "A container that holds related resources for an Azure solution"
8+
default = ""
9+
}
10+
11+
variable "location" {
12+
description = "The location/region to keep all your network resources. To get the list of all locations with table format from azure cli, run 'az account list-locations -o table'"
13+
default = ""
14+
}
15+
16+
17+
18+
19+
variable "tags" {
20+
description = "A map of tags to add to all resources"
21+
type = map(string)
22+
default = {}
23+
}

versions.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = ">= 2.59.0"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}
10+
11+
provider "azurerm" {
12+
features {}
13+
}

0 commit comments

Comments
 (0)