Skip to content

Commit 8b063c6

Browse files
authored
CCM-7357: Disable automatic build for main branch and provide TF output for post-deployment hook (#199)
1 parent d410246 commit 8b063c6

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

infrastructure/terraform/components/app/amplify_domain_association.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# enable_auto_sub_domain = true
55

66
# sub_domain {
7-
# branch_name = module.amplify_branch.name
7+
# branch_name = var.branch_name
88
# prefix = ""
99
# }
1010

1111
# sub_domain {
12-
# branch_name = module.amplify_branch.name
13-
# prefix = "main"
12+
# branch_name = var.branch_name
13+
# prefix = var.url_prefix
1414
# }
1515
# }
1616

@@ -19,13 +19,14 @@
1919
resource "null_resource" "amplify_domain_association" {
2020
triggers = {
2121
amplify_app_id = aws_amplify_app.main.id
22-
amplify_branch_name = module.amplify_branch.name
22+
amplify_branch_name = var.branch_name
23+
amplify_url_prefix = var.url_prefix
2324
amplify_domain_name = local.root_domain_name
2425
}
2526

2627
provisioner "local-exec" {
2728
when = create
28-
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*\""
29+
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_url_prefix}\",branchName=\"${self.triggers.amplify_branch_name}\" --enable-auto-sub-domain --auto-sub-domain-creation-patterns \"*,*/*,pr*\""
2930
}
3031

3132
provisioner "local-exec" {

infrastructure/terraform/components/app/module_amplify_branch.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module "amplify_branch" {
22
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/amp_branch?ref=v1.0.0"
33

44
name = "main"
5-
display_name = "main"
5+
display_name = var.url_prefix
66
aws_account_id = var.aws_account_id
77
component = var.component
88
environment = var.environment
@@ -13,7 +13,7 @@ module "amplify_branch" {
1313
amplify_app_id = aws_amplify_app.main.id
1414
branch = var.branch_name
1515
stage = "PRODUCTION"
16-
enable_auto_build = true
16+
enable_auto_build = false
1717

1818
environment_variables = {
1919
NOTIFY_SUBDOMAIN = var.environment

infrastructure/terraform/components/app/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ output "amplify" {
22
value = {
33
id = aws_amplify_app.main.id
44
domain_name = local.root_domain_name
5+
branch_name = var.branch_name
6+
}
7+
}
8+
9+
output "deployment" {
10+
description = "Deployment details used for post-deployment scripts"
11+
value = {
12+
aws_region = var.region
13+
aws_account_id = var.aws_account_id
14+
project = var.project
15+
environment = var.environment
16+
group = var.group
17+
component = var.component
18+
commit_id = var.commit_id
519
}
620
}
721

infrastructure/terraform/components/app/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ variable "branch_name" {
9999
default = "main"
100100
}
101101

102+
variable "url_prefix" {
103+
type = string
104+
description = "The url prefix to use for the deployed branch"
105+
default = "main"
106+
}
107+
108+
variable "commit_id" {
109+
type = string
110+
description = "The commit to deploy. Must be in the tree for branch_name"
111+
default = "HEAD"
112+
}
113+
102114
variable "disable_content" {
103115
type = string
104116
description = "Value for turning switching disable conten true/false"

0 commit comments

Comments
 (0)