| 1 | provider "aws" { |
| 2 | alias = "primary" |
| 3 | region = var.primary_region |
| 4 | allowed_account_ids = [var.aws_account_id] |
| 5 | default_tags { tags = { Project = var.name, ManagedBy = "OpenTofu" } } |
| 6 | } |
| 7 | provider "aws" { |
| 8 | alias = "secondary" |
| 9 | region = var.secondary_region |
| 10 | allowed_account_ids = [var.aws_account_id] |
| 11 | default_tags { tags = { Project = var.name, ManagedBy = "OpenTofu" } } |
| 12 | } |
| 13 | module "deployment" { |
| 14 | control_plane = true |
| 15 | source = "../../modules/storage" |
| 16 | providers = { aws = aws.primary } |
| 17 | name = "${var.name}-${var.aws_account_id}-platform" |
| 18 | } |
| 19 | module "primary_data" { |
| 20 | source = "../../modules/storage" |
| 21 | providers = { aws = aws.primary } |
| 22 | name = "${var.name}-${var.aws_account_id}-${var.primary_region}-data" |
| 23 | } |
| 24 | module "secondary_data" { |
| 25 | source = "../../modules/storage" |
| 26 | providers = { aws = aws.secondary } |
| 27 | name = "${var.name}-${var.aws_account_id}-${var.secondary_region}-data" |
| 28 | } |
| 29 | module "primary" { |
| 30 | source = "../../modules/region" |
| 31 | providers = { aws = aws.primary } |
| 32 | name = "${var.name}-${var.primary_region}" |
| 33 | host_count = 1 |
| 34 | vpc_cidr = "10.40.0.0/16" |
| 35 | deployment_bucket_name = module.deployment.name |
| 36 | deployment_bucket_arn = module.deployment.arn |
| 37 | deployment_region = var.primary_region |
| 38 | data_bucket_name = module.primary_data.name |
| 39 | data_bucket_arn = module.primary_data.arn |
| 40 | placement_region = "primary" |
| 41 | release_public_key = var.release_public_key |
| 42 | apps_domain = var.apps_domain |
| 43 | instance_type = var.instance_type |
| 44 | root_volume_gib = var.root_volume_gib |
| 45 | } |
| 46 | module "secondary" { |
| 47 | source = "../../modules/region" |
| 48 | providers = { aws = aws.secondary } |
| 49 | name = "${var.name}-${var.secondary_region}" |
| 50 | host_count = 1 |
| 51 | vpc_cidr = "10.41.0.0/16" |
| 52 | deployment_bucket_name = module.deployment.name |
| 53 | deployment_bucket_arn = module.deployment.arn |
| 54 | deployment_region = var.primary_region |
| 55 | data_bucket_name = module.secondary_data.name |
| 56 | data_bucket_arn = module.secondary_data.arn |
| 57 | placement_region = "secondary" |
| 58 | release_public_key = var.release_public_key |
| 59 | apps_domain = var.apps_domain |
| 60 | instance_type = var.instance_type |
| 61 | root_volume_gib = var.root_volume_gib |
| 62 | } |
| 63 | output "hosts" { value = { primary = module.primary.hosts, secondary = module.secondary.hosts } } |
| 64 | output "deployment_bucket" { value = module.deployment.name } |
| 65 | output "data_buckets" { value = { primary = module.primary_data.name, secondary = module.secondary_data.name } } |
| 66 | |