Skip to content

Commit

Permalink
CCM-5680 fix custom domain name and env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenvaines-bjss committed Aug 2, 2024
1 parent 1a6fd80 commit 95c9ecd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module "amplify_branch" {
region = var.region
group = var.group

cognito_user_pool_client_id = local.iam.cognito_user_pool["id"]
cognito_user_pool_client_id = local.iam.cognito_user_pool_client["id"]
cognito_user_pool_identity_provider_names = local.iam.cognito_user_pool["identity_providers"]
amplify_app_id = local.iam.amplify["id"]
branch = var.branch_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
resource "aws_amplify_domain_association" "domain" {
app_id = aws_amplify_app.main.id
domain_name = local.acct.dns_zone["name"]
enable_auto_sub_domain = false

sub_domain {
branch_name = module.amplify_branch.name
prefix = ""
# resource "aws_amplify_domain_association" "domain" {
# app_id = aws_amplify_app.main.id
# domain_name = local.acct.dns_zone["name"]
# enable_auto_sub_domain = true

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

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

# TODO CCM-6078 Revert to above amplify_domain_association resource on closure of https://github.com/hashicorp/terraform-provider-aws/issues/37498
# Provider does not correctly set autoSubDomainCreationPatterns when enable_auto_sub_domain is set
resource "null_resource" "amplify_domain_association" {
triggers = {
amplify_app_id = aws_amplify_app.main.id
amplify_branch_name = module.amplify_branch.name
amplify_domain_name = local.acct.dns_zone["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*\""
}

provisioner "local-exec" {
when = destroy
command = "aws amplify delete-domain-association --app-id ${self.triggers.amplify_app_id} --domain-name ${self.triggers.amplify_domain_name}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module "amplify_branch" {
region = var.region
group = var.group

cognito_user_pool_client_id = aws_cognito_user_pool_client.main.user_pool_id
cognito_user_pool_client_id = aws_cognito_user_pool_client.main.id
cognito_user_pool_identity_provider_names = aws_cognito_user_pool_client.main.supported_identity_providers
amplify_app_id = aws_amplify_app.main.id
branch = "main"
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/terraform/components/iam/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ output "cognito_user_pool" {
}
}

output "cognito_user_pool_client" {
value = {
id = aws_cognito_user_pool_client.main.id
}
}

output "amplify" {
value = {
id = aws_amplify_app.main.id
Expand Down

0 comments on commit 95c9ecd

Please sign in to comment.