Skip to content

Commit 6f66c15

Browse files
DEVOPS-362 datafactory module
1 parent 0e9459b commit 6f66c15

File tree

4 files changed

+143
-85
lines changed

4 files changed

+143
-85
lines changed

main.tf

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
1-
# #This is the main configuration file where Azure resources are defined
2-
# #It contains the actual infrastructure as code declarations
1+
# This is the main configuration file where Azure resources are defined
2+
# It contains the actual infrastructure as code declarations
33

4-
# resource "azurerm_resource_group" "main" {
5-
# name = var.resource_group_name
6-
# location = var.location
4+
resource "azurerm_resource_group" "data_factory_rg" {
5+
name = var.resource_group_name
6+
location = var.location
7+
tags = {
8+
Environment = upper(var.environment)
9+
Orchestrator = "Terraform"
10+
DisplayName = upper(var.resource_group_name)
11+
ApplicationName = lower(var.application_name)
12+
Temporary = upper(var.temporary)
13+
}
14+
lifecycle {
15+
ignore_changes = [tags]
16+
}
17+
}
718

8-
# tags = {
9-
# Environment = var.environment,
10-
# ApplicationName = var.application_name
11-
# Temporary = var.temporary
12-
# }
13-
# }
19+
resource "azurerm_data_factory" "data_factory" {
20+
name = var.data_factory_name
21+
resource_group_name = azurerm_resource_group.data_factory_rg.name
22+
location = azurerm_resource_group.data_factory_rg.location
23+
public_network_enabled = var.public_network_enabled
1424

25+
managed_virtual_network_enabled = var.managed_virtual_network_enabled
26+
27+
tags = {
28+
Environment = upper(var.environment)
29+
Orchestrator = "Terraform"
30+
DisplayName = upper(var.data_factory_name)
31+
ApplicationName = lower(var.application_name)
32+
Temporary = upper(var.temporary)
33+
}
34+
depends_on = [azurerm_resource_group.data_factory_rg]
35+
lifecycle {
36+
ignore_changes = [tags]
37+
}
38+
}

outputs.tf

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
# This file defines output values that will be displayed after Terraform applies
22
# Outputs are useful for getting information about created resources
33

4-
# output "resource_group_id" {
5-
# description = "ID of the resource group"
6-
# value = azurerm_resource_group.main.id
7-
# }
4+
output "resource_group" {
5+
description = "Azure data factory resource group name"
6+
value = azurerm_resource_group.data_factory_rg.name
7+
}
88

9-
# output "resource_group_name" {
10-
# description = "Name of the resource group"
11-
# value = azurerm_resource_group.main.name
12-
# }
9+
output "data_factory_name" {
10+
description = "Azure Data Factory name"
11+
value = azurerm_data_factory.data_factory.name
12+
}
1313

14-
# output "resource_group_tags" {
15-
# description = "Tags of the resource group"
16-
# value = azurerm_resource_group.main.tags
17-
18-
# }
14+
output "data_factory_location" {
15+
description = "Azure data factory location"
16+
value = azurerm_data_factory.data_factory.location
17+
}
18+
19+
output "data_factory_id" {
20+
description = "Id of Azure Data Factory resource"
21+
value = azurerm_data_factory.data_factory.id
22+
}
23+
24+
output "public_access_enabled" {
25+
description = "Azure datafactory enabled public access or not"
26+
value = azurerm_data_factory.data_factory.public_network_enabled
27+
}
28+
29+
output "datafactory_tags" {
30+
description = "Azure data factory tags"
31+
value = azurerm_data_factory.data_factory.tags
32+
}

providers.tf

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# # This file configures the Terraform providers and backend settings
2-
# # It defines which providers are required and their version constraints
1+
# This file configures the Terraform providers and backend settings
2+
# It defines which providers are required and their version constraints
33

4-
# terraform {
5-
# required_version = ">= 1.0"
4+
terraform {
5+
required_version = ">= 1.0"
66

7-
# required_providers {
8-
# azurerm = {
9-
# source = "hashicorp/azurerm"
10-
# version = ">= 4.0, < 4.40.0"
11-
# }
12-
# }
13-
# }
7+
required_providers {
8+
azurerm = {
9+
source = "hashicorp/azurerm"
10+
version = ">= 4.0, < 4.40.0"
11+
}
12+
}
13+
}
1414

1515

16-
# # Configure the Azure provider
17-
# provider "azurerm" {
18-
# features {} # Required block for Azure provider, can configure specific features here
19-
20-
# # TODO: Add authentication methods if not using Azure CLI/Environment variables
21-
# # subscription_id = var.subscription_id
22-
# # tenant_id = var.tenant_id
23-
# # client_id = var.client_id
24-
# # client_secret = var.client_secret
25-
# }
16+
# Configure the Azure provider
17+
provider "azurerm" {
18+
features {} # Required block for Azure provider, can configure specific features here
19+
20+
# TODO: Add authentication methods if not using Azure CLI/Environment variables
21+
# subscription_id = var.subscription_id
22+
# tenant_id = var.tenant_id
23+
# client_id = var.client_id
24+
# client_secret = var.client_secret
25+
}

variables.tf

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
1-
# # This file defines all input variables for your Terraform configuration
2-
# # Variables allow users to customize the deployment without modifying code
3-
4-
# variable "resource_group_name" {
5-
# description = "Name of the resource group"
6-
# type = string
7-
# default = "example-rg"
8-
# }
9-
10-
# variable "location" {
11-
# description = "Azure region"
12-
# type = string
13-
# default = "Central India"
14-
# }
15-
16-
# variable "environment" {
17-
# description = "Environment tag"
18-
# type = string
19-
# default = "DEV"
20-
# }
21-
22-
# variable "application_name" {
23-
# description = "Application name tag"
24-
# type = string
25-
# default = "devwithkrishna"
26-
27-
# }
28-
# variable "temporary" {
29-
# description = "temporary name tag"
30-
# type = string
31-
# default = "TRUE"
32-
33-
# }
34-
35-
# # TODO: Add more variables as needed for your specific resources
36-
# # variable "variable_name" {
37-
# # description = "variable description"
38-
# # type = data type
39-
# # default = "default value (if any)" q
40-
# # }
1+
# This file defines all input variables for your Terraform configuration
2+
# Variables allow users to customize the deployment without modifying code
3+
4+
variable "resource_group_name" {
5+
type = string
6+
description = "Azure Datafactory Rg"
7+
default = ""
8+
}
9+
10+
variable "location" {
11+
type = string
12+
description = "Azure Data factory location"
13+
default = ""
14+
}
15+
16+
variable "data_factory_name" {
17+
description = "Azure Data factory name"
18+
type = string
19+
default = ""
20+
21+
}
22+
23+
variable "environment" {
24+
default = "DEV"
25+
description = "Environment tag value in Azure"
26+
type = string
27+
validation {
28+
condition = contains(["DEV", "QA", "UAT", "PROD"], var.environment)
29+
error_message = "Environment value should be one among DEV or QA or UAT or PROD."
30+
}
31+
}
32+
33+
variable "application_name" {
34+
default = "devwithkrishna"
35+
description = "Azure application name tag"
36+
}
37+
38+
39+
variable "temporary" {
40+
default = "TRUE"
41+
description = "Temporary tag value in Azure"
42+
type = string
43+
validation {
44+
condition = contains(["TRUE", "FALSE"], upper(var.temporary))
45+
error_message = "The temporary tag value must be either 'TRUE' or 'FALSE'."
46+
}
47+
48+
}
49+
50+
variable "managed_virtual_network_enabled" {
51+
description = "Is Managed Virtual Network enabled"
52+
default = "true"
53+
type = string
54+
}
55+
56+
variable "public_network_enabled" {
57+
description = "Is Public Network enabled"
58+
default = "true"
59+
type = string
60+
}

0 commit comments

Comments
 (0)