Skip to content

Commit

Permalink
fix: errors and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese committed Oct 16, 2024
1 parent 0c4c0a8 commit 2e0da2f
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 39 deletions.
12 changes: 6 additions & 6 deletions src/_modules/data_factory_storage_account/datasets_containers.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "azurerm_data_factory_custom_dataset" "source_dataset_container" {
for_each = local.containers
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value.name}-blob-${module.naming_convention.suffix}"
for_each = toset(local.containers)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value}-blob-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id
type = "AzureBlob"

Expand All @@ -14,13 +14,13 @@ resource "azurerm_data_factory_custom_dataset" "source_dataset_container" {
type = "LinkedServiceReference"
}
type = "AzureBlob"
folderPath = each.value.name
folderPath = each.value
})
}

resource "azurerm_data_factory_custom_dataset" "target_dataset_container" {
for_each = local.containers
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.target.name}-${each.value.name}-blob-${module.naming_convention.suffix}"
for_each = toset(local.containers)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.target.name}-${each.value}-blob-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id
type = "AzureBlob"

Expand All @@ -34,6 +34,6 @@ resource "azurerm_data_factory_custom_dataset" "target_dataset_container" {
type = "LinkedServiceReference"
}
type = "AzureBlob"
folderPath = each.value.name
folderPath = each.value
})
}
12 changes: 6 additions & 6 deletions src/_modules/data_factory_storage_account/datasets_tables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "azurerm_data_factory_custom_dataset" "source_dataset_table" {
for_each = local.tables
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value.name}-table-${module.naming_convention.suffix}"
for_each = toset(local.tables)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value}-table-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id
type = "AzureTable"

Expand All @@ -9,13 +9,13 @@ resource "azurerm_data_factory_custom_dataset" "source_dataset_table" {
}

type_properties_json = jsonencode({
tableName = each.value.name
tableName = each.value
})
}

resource "azurerm_data_factory_custom_dataset" "target_dataset_table" {
for_each = local.tables
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.target.name}-${each.value.name}-table-${module.naming_convention.suffix}"
for_each = toset(local.tables)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.target.name}-${each.value}-table-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id
type = "AzureTable"

Expand All @@ -24,6 +24,6 @@ resource "azurerm_data_factory_custom_dataset" "target_dataset_table" {
}

type_properties_json = jsonencode({
tableName = each.value.name
tableName = each.value
})
}
4 changes: 3 additions & 1 deletion src/_modules/data_factory_storage_account/locals.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
locals {
containers = var.what_to_migrate.blob.enabled ? (length(var.what_to_migrate.blob.containers) > 0 ? var.what_to_migrate.blob.containers : [for container in data.azurerm_storage_containers.this[0].containers : container.name]) : []
tables = var.what_to_migrate.table.enabled ? (length(var.what_to_migrate.table.tables) > 0 ? var.what_to_migrate.table.tables : [for table in jsondecode(data.azapi_resource_list.tables.output).value : table.TableName]) : []

azapi_tables = jsondecode(data.azapi_resource_list.tables.output)
tables = var.what_to_migrate.table.enabled ? (length(var.what_to_migrate.table.tables) > 0 ? var.what_to_migrate.table.tables : [for table in local.azapi_tables.value : table.name]) : []
}
2 changes: 1 addition & 1 deletion src/_modules/data_factory_storage_account/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output "pipelines" {
value = {
for pipeline in concat(azurerm_data_factory_pipeline.pipeline_container, azurerm_data_factory_pipeline.pipeline_table)
for pipeline in merge(azurerm_data_factory_pipeline.pipeline_container, azurerm_data_factory_pipeline.pipeline_table)
: pipeline.name => {
id = pipeline.id
name = pipeline.name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "azurerm_data_factory_pipeline" "pipeline_container" {
for_each = local.containers
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value.name}-blob-${module.naming_convention.suffix}"
for_each = toset(local.containers)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value}-blob-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id

activities_json = jsonencode(
Expand Down
4 changes: 2 additions & 2 deletions src/_modules/data_factory_storage_account/pipeline_tables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "azurerm_data_factory_pipeline" "pipeline_table" {
for_each = local.tables
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value.name}-table-${module.naming_convention.suffix}"
for_each = toset(local.tables)
name = "${module.naming_convention.prefix}-adf-${var.storage_accounts.source.name}-${each.value}-table-${module.naming_convention.suffix}"
data_factory_id = var.data_factory_id

activities_json = jsonencode(
Expand Down
28 changes: 14 additions & 14 deletions src/migration/prod/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file removed src/migration/prod/data.tf
Empty file.
19 changes: 13 additions & 6 deletions src/migration/prod/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ locals {
}

storage_accounts = [
{
source = { name = "iopweuabc", resource_group_name = "abc" }
target = { name = "iopitnabc", resource_group_name = "abc" }
blob = { enabled = true }
table = { enabled = true }
}
# Copy both containers and tables
# {
# source = { name = "stdevbiptest1", resource_group_name = "RG-BIP-DEV-TEST" }
# target = { name = "stbipdevtest1", resource_group_name = "dev-fasanorg" }
# },
#
# Copy only selected containers and tables
# {
# source = { name = "stdevbiptest1", resource_group_name = "RG-BIP-DEV-TEST" }
# target = { name = "stbipdevtest1", resource_group_name = "dev-fasanorg" }
# blob = {enabled = true, containers = ["c1", "c2", "c3"]}
# table = {enabled = true, tables = ["t1", "t2", "t3"]}
# }
]
}
2 changes: 1 addition & 1 deletion src/migration/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "<= 3.112.0"
version = "<= 3.116.0"
}

azapi = {
Expand Down

0 comments on commit 2e0da2f

Please sign in to comment.