Skip to content

Commit

Permalink
New certificate settings element in domains var and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
socketbox committed Feb 26, 2025
1 parent 019c764 commit 1acd3c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions domains.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ resource "aws_amplify_domain_association" "domain" {
prefix = sub_domain.value.prefix
}
}

certificate_settings {
type = var.domains[count.index].certificate_settings.type
custom_certificate_arn = var.domains[count.index].certificate_settings.custom_certificate_arn
}

lifecycle {
ignore_changes = [
sub_domain
Expand Down
10 changes: 9 additions & 1 deletion optional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ variable "branches" {
variable "domains" {
description = "Domains for an Amplify app."
type = list(object({
domain_name = string
domain_name = string
certificate_settings = optional(object({
custom_certificate_arn = string
type = string
}))
enable_auto_sub_domain = optional(bool)
wait_for_verification = optional(bool)
sub_domains = list(object({
Expand All @@ -152,6 +156,10 @@ variable "domains" {
}))
}))
default = []
validation {
condition = [for d in var.domains : can(d.certificate_settings.type == "AMPLIFY_MANAGED" || (d.certificate_settings.type == "CUSTOM" && d.certificate_settings.custom_certificate_arn != ""))]
error_message = "Either specify that your domain certificate is Amplify-managed or provide a custom certificate ARN."
}
}

variable "backend_environments" {
Expand Down

0 comments on commit 1acd3c3

Please sign in to comment.