Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCM-5680 fix custom domain name and env vars #15

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading