Skip to content

Commit fea620c

Browse files
Merge pull request #3 from devwithkrishna/feature/data-factory
Azure Data Factory Terraform module
2 parents dad889b + 09e63ff commit fea620c

File tree

13 files changed

+427
-159
lines changed

13 files changed

+427
-159
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ terraform.rc
3939
# env file
4040
.env
4141
*.out
42+
43+
*.hcl

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Examples
1010

11-
Please find the [examples]((https://github.com/devwithkrishna/terraform-azure-datafactory//tree/main/examples)) here
11+
Please find the [examples]((https://github.com/devwithkrishna/terraform-azure-datafactory/tree/main/examples)) here
1212

1313
## 📂 Structure
1414

examples/sample/main.tf

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33

44

5-
# module "azure" {
6-
# source = "../../" # points to the module root
5+
module "azure" {
6+
source = "../../" # points to the module root
77

8-
# resource_group_name = var.resource_group_name
9-
# location = var.location
10-
# environment = var.environment
11-
# application_name = var.application_name
12-
# temporary = var.temporary
8+
resource_group_name = var.resource_group_name
9+
location = var.location
10+
environment = var.environment
11+
application_name = var.application_name
12+
temporary = var.temporary
13+
managed_virtual_network_enabled = var.managed_virtual_network_enabled
14+
public_network_enabled = var.public_network_enabled
15+
data_factory_name = var.data_factory_name
1316

14-
# }
17+
}

examples/sample/outputs.tf

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
# # Outputs for Terratest to validate
1+
# Outputs for Terratest to validate
22

3-
# output "resource_group_name" {
4-
# description = "Name of the test resource group"
5-
# value = module.azure.resource_group_name
6-
# }
3+
output "resource_group_name" {
4+
description = "Name of the test resource group"
5+
value = module.azure.resource_group
6+
}
77

8-
# output "resource_group_id" {
9-
# description = "ID of the test resource group"
10-
# value = module.azure.resource_group_id
11-
# }
8+
output "data_factory_name" {
9+
description = "Name of the test data factory"
10+
value = module.azure.data_factory_name
11+
}
12+
13+
output "public_access_enabled" {
14+
description = "Public Access enabled or not"
15+
value = module.azure.public_access_enabled
16+
}
17+
18+
output "data_factory_id" {
19+
description = "Id of Azure Data Factory resource"
20+
value = module.azure.data_factory_id
21+
}
22+
23+
output "datafactory_tags" {
24+
description = "Azure data factory tags"
25+
value = module.azure.datafactory_tags
26+
}

examples/sample/providers.tf

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# This file configures the Terraform providers and backend settings
22
# 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+
}

examples/sample/variables.tf

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
# # Variables for the test configuration
22

3-
# variable "resource_group_name" {
4-
# description = "Name of the resource group for testing"
5-
# type = string
6-
# }
7-
8-
# variable "location" {
9-
# description = "Azure region for testing"
10-
# type = string
11-
# default = "East US2"
12-
# }
13-
14-
# variable "environment" {
15-
# description = "Environment tag for testing"
16-
# type = string
17-
# default = "DEV"
18-
19-
# }
20-
21-
# variable "application_name" {
22-
# description = "value for application name tag"
23-
# type = string
24-
# default = "oscar"
25-
# }
26-
27-
# variable "temporary" {
28-
# description = "temporary name tag"
29-
# type = string
30-
# default = "TRUE"
31-
32-
# }
3+
variable "resource_group_name" {
4+
description = "Name of the resource group for testing"
5+
type = string
6+
}
7+
8+
variable "data_factory_name" {
9+
description = "Azure data factory name"
10+
type = string
11+
}
12+
13+
variable "location" {
14+
description = "Azure region for testing"
15+
type = string
16+
default = "East US2"
17+
}
18+
19+
variable "environment" {
20+
description = "Environment tag for testing"
21+
type = string
22+
default = "DEV"
23+
}
24+
25+
variable "application_name" {
26+
description = "value for application name tag"
27+
type = string
28+
default = "oscar"
29+
}
30+
31+
variable "temporary" {
32+
description = "temporary name tag"
33+
type = string
34+
default = "TRUE"
35+
}
36+
37+
variable "managed_virtual_network_enabled" {
38+
description = "Is Managed Virtual Network enabled"
39+
default = "true"
40+
type = string
41+
}
42+
43+
variable "public_network_enabled" {
44+
description = "Is Public Network enabled"
45+
default = "true"
46+
type = string
47+
}

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+
}

test/go.mod

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module github.com/devwithkrishna/terraform-azure-datafactory/test
2+
3+
go 1.24.0
4+
5+
toolchain go1.24.9
6+
7+
require (
8+
github.com/gruntwork-io/terratest v0.51.0
9+
github.com/stretchr/testify v1.11.1
10+
)
11+
12+
require (
13+
github.com/agext/levenshtein v1.2.3 // indirect
14+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
15+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
16+
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/hashicorp/errwrap v1.0.0 // indirect
18+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
19+
github.com/hashicorp/go-getter/v2 v2.2.3 // indirect
20+
github.com/hashicorp/go-multierror v1.1.1 // indirect
21+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
22+
github.com/hashicorp/go-version v1.7.0 // indirect
23+
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
24+
github.com/hashicorp/terraform-json v0.23.0 // indirect
25+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
26+
github.com/klauspost/compress v1.16.5 // indirect
27+
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
28+
github.com/mitchellh/go-homedir v1.1.0 // indirect
29+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
30+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
31+
github.com/pmezard/go-difflib v1.0.0 // indirect
32+
github.com/tmccombs/hcl2json v0.6.4 // indirect
33+
github.com/ulikunitz/xz v0.5.10 // indirect
34+
github.com/zclconf/go-cty v1.15.0 // indirect
35+
golang.org/x/crypto v0.36.0 // indirect
36+
golang.org/x/mod v0.21.0 // indirect
37+
golang.org/x/net v0.38.0 // indirect
38+
golang.org/x/sync v0.12.0 // indirect
39+
golang.org/x/sys v0.31.0 // indirect
40+
golang.org/x/text v0.23.0 // indirect
41+
golang.org/x/tools v0.26.0 // indirect
42+
gopkg.in/yaml.v3 v3.0.1 // indirect
43+
)

0 commit comments

Comments
 (0)