Skip to content

Commit c2f2e05

Browse files
committed
Add: optional ACM certificate SANs
1 parent 10d4c56 commit c2f2e05

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ the AppConfig Agent is enabled.
213213
| create_endpoint | Create an Application Load Balancer for the service. Required to serve traffic. | `bool` | `true` | no |
214214
| create_repository | Create an ECR repository to host the container image. | `bool` | `true` | no |
215215
| create_version_parameter | Create an SSM parameter to store the active version for the image tag. | `bool` | `false` | no |
216+
| certificate_sans | Additional ACM subject alternative names such as `["*.example.org"]` for hostnames beyond the primary FQDN. Duplicates of the primary name are ignored. | `list(string)` | `[]` | no |
216217
| cpu | CPU unit for this task. | `number` | `512` | no |
217218
| desired_containers | Desired number of running containers for the service. | `number` | `1` | no |
218219
| [enable_appconfig_agent] | Enable an AWS AppConfig Agent sidecar container for live configuration updates. | `bool` | `false` | no |

alb.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ module "alb" {
7474
resource "aws_acm_certificate" "endpoint" {
7575
for_each = var.create_endpoint ? toset(["this"]) : toset([])
7676

77-
domain_name = local.fqdn
78-
validation_method = "DNS"
77+
domain_name = local.fqdn
78+
subject_alternative_names = local.certificate_sans
79+
validation_method = "DNS"
7980

8081
lifecycle {
8182
create_before_destroy = true

local.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
locals {
22
fqdn = var.subdomain != "" ? "${var.subdomain}.${var.domain}" : var.domain
3+
# Drop SANs that duplicate the primary certificate name; ACM rejects that.
4+
certificate_sans = [
5+
for name in var.certificate_sans : name if name != local.fqdn
6+
]
37
hosted_zone_id = (!var.create_endpoint
48
? null
59
: (var.hosted_zone_id == null ? data.aws_route53_zone.domain["this"].zone_id : var.hosted_zone_id)

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ variable "container_port" {
5050
default = 80
5151
}
5252

53+
variable "certificate_sans" {
54+
type = list(string)
55+
description = <<-EOT
56+
Additional subject alternative names for the ACM certificate. Use this for
57+
wildcard names such as `*.example.org` when the ALB must terminate TLS for
58+
hostnames beyond the primary `subdomain.domain` FQDN. Names that match the
59+
primary FQDN are ignored. Existing DNS validation records cover SANs
60+
automatically.
61+
EOT
62+
default = []
63+
}
64+
5365
variable "create_endpoint" {
5466
type = bool
5567
description = "Create an Application Load Balancer for the service."

0 commit comments

Comments
 (0)