Skip to content

Commit f367bce

Browse files
committed
refactor: make the acm certificate specific to the sub domain
1 parent 2c51a23 commit f367bce

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ locals {
1919
ecs_task_assume_policy_actions = ["sts:AssumeRole"]
2020
ecs_task_assume_policy_principal_type = "Service"
2121
ecs_task_assume_policy_principal_identifiers = ["ecs-tasks.amazonaws.com"]
22-
acm_certificate_statuses = ["ISSUED"]
2322
default_desired_count = 1
2423
target_group_name = "atlantis-target-group"
24+
acm_certificate_name = "atlantis-domain"
2525
target_group_protocol = "HTTP"
2626
listener_protocol = "HTTPS"
2727
listener_port = 443

main.tf

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,13 @@ data "aws_iam_policy_document" "ecs_task_assume_policy" {
2121
}
2222
}
2323

24-
data "aws_acm_certificate" "base_domain_certificate" {
25-
domain = local.base_domain
26-
statuses = local.acm_certificate_statuses
27-
}
28-
2924
data "aws_route53_zone" "zone" {
3025
name = local.base_domain
3126
}
3227

3328
module "ecs_deployment" {
3429
source = "infraspecdev/ecs-deployment/aws"
35-
version = "3.0.1"
30+
version = "4.0.4"
3631

3732
cluster_name = data.aws_ecs_cluster.default.cluster_name
3833
vpc_id = var.vpc_id
@@ -82,7 +77,7 @@ module "ecs_deployment" {
8277
security_groups_ids = [aws_security_group.alb.id]
8378

8479
target_groups = {
85-
atlantis-target-group = {
80+
(local.target_group_name) = {
8681
name = format("%s-%s-ip", local.alb_system_name, terraform.workspace)
8782
port = local.container_port
8883
protocol = local.target_group_protocol
@@ -92,9 +87,9 @@ module "ecs_deployment" {
9287

9388
listeners = {
9489
https-listener = {
95-
protocol = local.listener_protocol
96-
port = local.listener_port
97-
certificate_arn = data.aws_acm_certificate.base_domain_certificate.arn
90+
protocol = local.listener_protocol
91+
port = local.listener_port
92+
certificate = local.acm_certificate_name
9893

9994
default_action = [
10095
{
@@ -178,4 +173,16 @@ module "ecs_deployment" {
178173
}
179174

180175
create_capacity_provider = local.create_capacity_provider
176+
177+
create_acm = true
178+
acm_certificates = {
179+
(local.acm_certificate_name) = {
180+
domain_name = var.atlantis_url
181+
validation_option = {
182+
domain_name = var.atlantis_url
183+
validation_domain = var.atlantis_url
184+
}
185+
record_zone_id = data.aws_route53_zone.zone.zone_id
186+
}
187+
}
181188
}

0 commit comments

Comments
 (0)