Skip to content

Commit

Permalink
CCM-7357: Associate domain name with url prefix not branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
m-houston committed Nov 13, 2024
1 parent cd36578 commit 18136ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# enable_auto_sub_domain = true

# sub_domain {
# branch_name = module.amplify_branch.name
# branch_name = var.url_prefix
# prefix = ""
# }

# sub_domain {
# branch_name = module.amplify_branch.name
# branch_name = var.url_prefix
# prefix = "main"
# }
# }
Expand All @@ -19,13 +19,13 @@
resource "null_resource" "amplify_domain_association" {
triggers = {
amplify_app_id = aws_amplify_app.main.id
amplify_branch_name = module.amplify_branch.name
amplify_branch_name = var.url_prefix # module.amplify_branch.display_name
amplify_domain_name = local.root_domain_name
}

provisioner "local-exec" {
when = create
command = "aws amplify create-domain-association --app-id ${self.triggers.amplify_app_id} --domain-name ${self.triggers.amplify_domain_name} --sub-domain-settings prefix=\"\",branchName=\"${self.triggers.amplify_branch_name}\" prefix=\"${self.triggers.amplify_branch_name}\",branchName=\"${self.triggers.amplify_branch_name}\" --enable-auto-sub-domain --auto-sub-domain-creation-patterns \"*,*/*,pr*\""
command = "aws amplify create-domain-association --app-id ${self.triggers.amplify_app_id} --domain-name ${self.triggers.amplify_domain_name} --sub-domain-settings prefix=\"\",branchName=\"${self.triggers.amplify_branch_name}\" prefix=\"main\",branchName=\"${self.triggers.amplify_branch_name}\" --enable-auto-sub-domain --auto-sub-domain-creation-patterns \"*,*/*,pr*\""
}

provisioner "local-exec" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "amplify_branch" {
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/amp_branch?ref=v1.0.0"
name = "main"
display_name = "main"
display_name = var.url_prefix
aws_account_id = var.aws_account_id
component = var.component
environment = var.environment
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/terraform/components/app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ variable "branch_name" {
default = "main"
}

variable "url_prefix" {
type = string
description = "The url prefix to use for the deployed branch"
default = "main"
}

variable "commit_id" {
type = string
description = "The commit to deploy. Must be in the tree for branch_name"
Expand Down

0 comments on commit 18136ab

Please sign in to comment.