![[airbyte-mysql.png]]
**Repository structure**
![[airbyte-bitbucket.png]]
Example of Terraform config for 1 data source (WMS) / Mysql Database
**plans/ingestion/airbyte/wms.tf**
```
# ----------------------------------
# Airbyte Destination snowflake
# ----------------------------------
resource "airbyte_destination_snowflake" "snowflake" {
for_each = var.create_airbyte_wms && var.create_airbyte_destination_snowflake_wms ? local.lh_db_name : []
name = upper("snowflake_${each.key}")
workspace_id = airbyte_workspace.lakehouse["${var.environment}"].workspace_id
configuration = {
credentials = {
key_pair_authentication = {
private_key = data.terraform_remote_state.lh_global.outputs.airbyte_private_key
}
}
host = local.airbyte_params["/lakehouse-${var.environment}/airbyte/snowflake/host"]
username = data.terraform_remote_state.lh_global.outputs.airbyte_loader_user_id
warehouse = data.terraform_remote_state.lh_global.outputs.wh_loading_name
database = each.key
schema = var.schema_wms
role = data.terraform_remote_state.lh_global.outputs.airbyte_service_role
}
}
# ----------------------------------
# Airbyte Source MySQL WMS
# ----------------------------------
resource "airbyte_source_mysql" "mysql" {
count = var.create_airbyte_wms && var.create_airbyte_source_wms ? 1 : 0
name = var.airbyte_destination_name_mysql
workspace_id = airbyte_workspace.lakehouse["${var.environment}"].workspace_id
configuration = {
port = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/rds/port"]
host = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/rds/endpoint"]
database = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/rds/database"]
username = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/rds/username"]
password = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/rds/password"]
replication_method = {
read_changes_using_change_data_capture_cdc = {
initial_waiting_seconds = 300
initial_load_timeout_hours = 8
invalid_cdc_cursor_position_behavior = "Fail sync"
}
}
tunnel_method = {
ssh_key_authentication = {
ssh_key = data.aws_secretsmanager_secret_version.mysql_ssh_key.secret_string
tunnel_host = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/bastion/tunnel_host"]
tunnel_user = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/bastion/tunnel_user"]
tunnel_port = local.airbyte_params["/lakehouse-${var.environment}/airbyte/wms-${var.environment}/bastion/tunnel_port"]
}
}
}
}
# ----------------------------------
# Airbyte Connection
# ----------------------------------
resource "airbyte_connection" "wms_to_snowflake" {
for_each = var.create_airbyte_wms && var.create_airbyte_connection_wms_to_snowflake ? local.lh_db_name : []
name = upper("wms_to_snowflake_${each.key}")
data_residency = "eu"
destination_id = resource.airbyte_destination_snowflake.snowflake[each.key].destination_id
namespace_definition = "custom_format"
namespace_format = "wms_default_inventory_management"
non_breaking_schema_updates_behavior = "propagate_columns"
source_id = resource.airbyte_source_mysql.mysql[0].source_id
schedule = {
cron_expression = "0 0 * * * ? UTC"
schedule_type = "cron"
}
configurations = {
streams = [{
"name" = "INM_INVENTORY_COUNT"
"sync_mode" = "full_refresh_overwrite"
}]
}
}
```