Skip to content

Commit

Permalink
fix: changed folder structure and ran pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese committed Oct 16, 2024
1 parent f9aa68d commit 9d2c460
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/_modules/data_factory_storage_account/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ data "azurerm_storage_account" "target" {
}

data "azurerm_storage_containers" "this" {
for_each = var.what_to_migrate.blob.enabled && length(var.what_to_migrate.blob.containers) == 0 ? [1] : []
for_each = var.what_to_migrate.blob.enabled && length(var.what_to_migrate.blob.containers) == 0 ? [1] : []
storage_account_id = data.azurerm_storage_account.source.id
}
2 changes: 1 addition & 1 deletion src/_modules/data_factory_storage_account/locals.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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 ? var.what_to_migrate.table.tables : []
tables = var.what_to_migrate.table.enabled ? var.what_to_migrate.table.tables : []
}
14 changes: 7 additions & 7 deletions src/_modules/data_factory_storage_account/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
output "pipelines" {
value = {
for pipeline in concat(azurerm_data_factory_pipeline.pipeline_container, azurerm_data_factory_pipeline.pipeline_table)
: pipeline.name => {
id = pipeline.id
name = pipeline.name
url = "https://adf.azure.com/en/authoring/pipeline/${pipeline.name}?factory=${pipeline.data_factory_id}"
}
value = {
for pipeline in concat(azurerm_data_factory_pipeline.pipeline_container, azurerm_data_factory_pipeline.pipeline_table)
: pipeline.name => {
id = pipeline.id
name = pipeline.name
url = "https://adf.azure.com/en/authoring/pipeline/${pipeline.name}?factory=${pipeline.data_factory_id}"
}
}
}
23 changes: 9 additions & 14 deletions src/_modules/data_factory_storage_account/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,20 @@ variable "environment" {
description = "Values which are used to generate resource names and location short names. They are all mandatory except for domain, which should not be used only in the case of a resource used by multiple domains."
}

variable "data_factory" {
description = "Data Factory information."
type = map(object({
id = string
name = string
location = string
resource_group_name = string
}))
variable "data_factory_id" {
description = "Data Factory id where to create resources."
type = string
}

variable "storage_accounts" {
type = object({
source = object({
name = string
name = string
resource_group_name = string
})

target = object({
name = string
name = string
resource_group_name = string
})
})
Expand All @@ -39,16 +34,16 @@ variable "what_to_migrate" {
type = object({
blob = optional(object(
{
enabled = bool
enabled = bool
containers = optional(list(string), [])
}),
}),
{ enabled = false }
)
table = optional(object(
{
enabled = bool
tables = list(string)
}),
tables = list(string)
}),
{ enabled = false }
)
})
Expand Down
19 changes: 0 additions & 19 deletions src/migration/_modules/datafactory/main.tf

This file was deleted.

19 changes: 0 additions & 19 deletions src/migration/_modules/datafactory/variables.tf

This file was deleted.

37 changes: 37 additions & 0 deletions src/migration/prod/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# prod

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | <= 3.112.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | <= 3.112.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_migrate_storage_accounts"></a> [migrate\_storage\_accounts](#module\_migrate\_storage\_accounts) | ../../_modules/data_factory_storage_account | n/a |

## Resources

| Name | Type |
|------|------|
| [azurerm_data_factory.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory) | resource |
| [azurerm_data_factory_integration_runtime_azure.azure_runtime](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory_integration_runtime_azure) | resource |
| [azurerm_resource_group.migration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |

## Inputs

No inputs.

## Outputs

No outputs.
<!-- END_TF_DOCS -->
58 changes: 54 additions & 4 deletions src/migration/prod/italynorth.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,59 @@
module "adf" {
source = "../_modules/datafactory"
resource "azurerm_resource_group" "migration" {
name = "${local.project_itn}-migration-rg-01"
location = "italynorth"

project = local.project_itn
tags = local.tags
}

# Create Azure Data Factory instances
# Enables system-assigned managed identity for secure access to resources
resource "azurerm_data_factory" "this" {
name = "${local.project_itn}-migration-adf-01"
location = "italynorth"
resource_group_name = azurerm_resource_group.github_runner.name
resource_group_name = azurerm_resource_group.migration.name

identity {
type = "SystemAssigned"
}

tags = local.tags
}

resource "azurerm_data_factory_integration_runtime_azure" "azure_runtime" {
name = "${local.project_itn}-migration-adfir-01"
location = "italynorth"
data_factory_id = azurerm_data_factory.this.id
}

module "migrate_storage_accounts" {
for_each = local.storage_accounts
source = "../../_modules/data_factory_storage_account"

environment = {
prefix = local.prefix
env_short = local.env_short
location = "italynorth"
domain = "eng"
app_name = "mig"
instance_number = "01"
}

data_factory_id = azurerm_data_factory.this.id

storage_accounts = {
source = each.value.source
target = each.value.target
}

what_to_migrate = {
blob = {
enabled = each.value.blob.enabled
containers = each.value.blob.containers
}

table = {
enabled = each.value.table.enabled
tables = each.value.table.tables
}
}
}

0 comments on commit 9d2c460

Please sign in to comment.