-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
150 lines (131 loc) · 4.19 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "terraform-demo" {
name = var.resource_group_name
location = var.location
}
resource "azurerm_storage_account" "mystorageaccount" {
name = var.storage_account_name
resource_group_name = azurerm_resource_group.terraform-demo.name
location = azurerm_resource_group.terraform-demo.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_storage_container" "source-container" {
name = var.storage_container_source_name
storage_account_name = azurerm_storage_account.mystorageaccount.name
}
resource "azurerm_storage_container" "destination-container" {
name = var.storage_container_destination_name
storage_account_name = azurerm_storage_account.mystorageaccount.name
}
resource "azurerm_data_factory" "adf-terraform" {
name = var.data_factory_name
resource_group_name = azurerm_resource_group.terraform-demo.name
location = azurerm_resource_group.terraform-demo.location
}
resource "azurerm_data_factory_linked_service_azure_blob_storage" "my-linked-service" {
name = var.linked_service_name
data_factory_id = azurerm_data_factory.adf-terraform.id
connection_string = azurerm_storage_account.mystorageaccount.primary_connection_string
}
resource "azurerm_data_factory_custom_dataset" "source-dataset" {
name = var.source_dataset_name
data_factory_id = azurerm_data_factory.adf-terraform.id
type = "Json"
linked_service {
name = azurerm_data_factory_linked_service_azure_blob_storage.my-linked-service.name
parameters = {
key1 = "value1"
}
}
type_properties_json = jsonencode({
location = {
container = azurerm_storage_container.source-container.name
fileName = "test.csv"
folderPath = ""
type = "AzureBlobStorageLocation"
}
encodingName = "UTF-8"
})
description = "Source dataset description"
annotations = ["sourcedataset_tag"]
schema_json = jsonencode({
type = "object",
properties = {
Month = { type = "string" },
"1958" = { type = "integer" },
"1959" = { type = "integer" },
"1960" = { type = "integer" },
}
})
}
resource "azurerm_data_factory_custom_dataset" "destination-dataset" {
name = var.destination_dataset_name
data_factory_id = azurerm_data_factory.adf-terraform.id
type = "Json"
linked_service {
name = azurerm_data_factory_linked_service_azure_blob_storage.my-linked-service.name
parameters = {
key1 = "value1"
}
}
type_properties_json = jsonencode({
location = {
container = azurerm_storage_container.destination-container.name
fileName = "test.csv"
folderPath = ""
type = "AzureBlobStorageLocation"
}
encodingName = "UTF-8"
})
description = "Destination dataset description"
annotations = ["destinationdataset_tag"]
schema_json = jsonencode({
type = "object",
properties = {
Month = { type = "string" },
"1958" = { type = "integer" },
"1959" = { type = "integer" },
"1960" = { type = "integer" },
}
})
}
resource "azurerm_data_factory_pipeline" "etl-pipeline" {
name = var.pipeline_name
data_factory_id = azurerm_data_factory.adf-terraform.id
activities_json = jsonencode([
{
"name" : "CopyDataActivity",
"type" : "Copy",
"inputs" : [
{
"referenceName" : azurerm_data_factory_custom_dataset.source-dataset.name,
"type" : "DatasetReference"
}
],
"outputs" : [
{
"referenceName" : azurerm_data_factory_custom_dataset.destination-dataset.name,
"type" : "DatasetReference"
}
],
"typeProperties" : {
"source" : {
"type" : "DelimitedTextSource",
"storeSettings" : {
"type" : "AzureBlobFSReadSettings",
"recursive" : true
}
},
"sink" : {
"type" : "DelimitedTextSink",
"storeSettings" : {
"type" : "AzureBlobFSWriteSettings"
}
}
}
}
])
}