Skip to content

Commit

Permalink
fix: Ensure conditional creation of EFS and entire module are functio…
Browse files Browse the repository at this point in the history
…ning as intended (#370)
  • Loading branch information
bryantbiggs authored Nov 10, 2023
1 parent 1cf5f42 commit 2a8d178
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions examples/github-separate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Note that this example may create resources which cost money. Run `terraform des
|------|--------|---------|
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | 9.1.0 |
| <a name="module_atlantis"></a> [atlantis](#module\_atlantis) | ../../ | n/a |
| <a name="module_atlantis_disabled"></a> [atlantis\_disabled](#module\_atlantis\_disabled) | ../../ | n/a |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | terraform-aws-modules/ecs/aws//modules/cluster | 5.6.0 |
| <a name="module_github_repository_webhooks"></a> [github\_repository\_webhooks](#module\_github\_repository\_webhooks) | ../../modules/github-repository-webhook | n/a |
| <a name="module_secrets_manager"></a> [secrets\_manager](#module\_secrets\_manager) | terraform-aws-modules/secrets-manager/aws | ~> 1.0 |
Expand Down
22 changes: 6 additions & 16 deletions examples/github-separate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,6 @@ module "atlantis" {
service_subnets = module.vpc.private_subnets
vpc_id = module.vpc.vpc_id

# EFS
enable_efs = true
efs = {
mount_targets = {
"eu-west-1a" = {
subnet_id = module.vpc.private_subnets[0]
}
"eu-west-1b" = {
subnet_id = module.vpc.private_subnets[1]
}
"eu-west-1c" = {
subnet_id = module.vpc.private_subnets[2]
}
}
}

tags = local.tags
}

Expand All @@ -108,6 +92,12 @@ module "github_repository_webhooks" {
webhook_secret = random_password.webhook_secret.result
}

module "atlantis_disabled" {
source = "../../"

create = false
}

################################################################################
# Supporting Resources
################################################################################
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ module "ecs_service" {
ignore_task_definition_changes = try(var.service.ignore_task_definition_changes, false)
alarms = try(var.service.alarms, {})
capacity_provider_strategy = try(var.service.capacity_provider_strategy, {})
cluster_arn = var.create_cluster ? module.ecs_cluster.arn : var.cluster_arn
cluster_arn = var.create_cluster && var.create ? module.ecs_cluster.arn : var.cluster_arn
deployment_controller = try(var.service.deployment_controller, {})
deployment_maximum_percent = try(var.service.deployment_maximum_percent, 200)
deployment_minimum_healthy_percent = try(var.service.deployment_minimum_healthy_percent, 66)
Expand All @@ -243,7 +243,7 @@ module "ecs_service" {
load_balancer = merge(
{
service = {
target_group_arn = var.create_alb ? module.alb.target_groups["atlantis"].arn : var.alb_target_group_arn
target_group_arn = var.create_alb && var.create ? module.alb.target_groups["atlantis"].arn : var.alb_target_group_arn
container_name = "atlantis"
container_port = local.atlantis_port
}
Expand Down Expand Up @@ -375,7 +375,7 @@ module "ecs_service" {
file_system_id = module.efs.id
transit_encryption = "ENABLED"
authorization_config = {
access_point_id = module.efs.access_points["atlantis"].id
access_point_id = try(module.efs.access_points["atlantis"].id, null)
iam = "ENABLED"
}
}
Expand Down

0 comments on commit 2a8d178

Please sign in to comment.