generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from NHSDigital/aiva2/CCM-5950_CognitoCustomAuth
Aiva2/ccm 5950 cognito custom auth
- Loading branch information
Showing
11 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
infrastructure/terraform/components/acct/route_53_record_root.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Record to support Cognito Hosted UIs per https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html | ||
resource "aws_route53_record" "root" { | ||
name = "" | ||
zone_id = aws_route53_zone.main.id | ||
type = "A" | ||
ttl = 300 | ||
records = ["127.0.0.1"] | ||
} |
16 changes: 16 additions & 0 deletions
16
infrastructure/terraform/components/iam/acm_certificate_cognito.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "aws_acm_certificate" "cognito" { | ||
provider = aws.us-east-1 | ||
|
||
domain_name = local.auth_domain_name | ||
validation_method = "DNS" | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_acm_certificate_validation" "cognito" { | ||
provider = aws.us-east-1 | ||
|
||
certificate_arn = aws_acm_certificate.cognito.arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
locals { | ||
root_domain_name = "${var.environment}.${local.acct.dns_zone["name"]}" | ||
auth_domain_name = "auth.${local.root_domain_name}" | ||
} |
25 changes: 25 additions & 0 deletions
25
infrastructure/terraform/components/iam/route53_record_cognito.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource "aws_route53_record" "cognito_alias" { | ||
name = aws_cognito_user_pool_domain.custom.domain | ||
zone_id = local.acct.dns_zone["id"] | ||
type = "A" | ||
|
||
alias { | ||
evaluate_target_health = false | ||
|
||
name = aws_cognito_user_pool_domain.main.cloudfront_distribution | ||
zone_id = aws_cognito_user_pool_domain.main.cloudfront_distribution_zone_id | ||
} | ||
} | ||
|
||
resource "aws_route53_record" "cognito_ipv6_alias" { | ||
name = aws_cognito_user_pool_domain.custom.domain | ||
zone_id = local.acct.dns_zone["id"] | ||
type = "AAAA" | ||
|
||
alias { | ||
evaluate_target_health = false | ||
|
||
name = aws_cognito_user_pool_domain.main.cloudfront_distribution | ||
zone_id = aws_cognito_user_pool_domain.main.cloudfront_distribution_zone_id | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
infrastructure/terraform/components/iam/route53_record_cognito_acm_validation.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
resource "aws_route53_record" "cognito_acm_validation" { | ||
for_each = { | ||
for dvo in aws_acm_certificate.cognito.domain_validation_options : | ||
dvo.domain_name => { | ||
name = dvo.resource_record_name | ||
record = dvo.resource_record_value | ||
type = dvo.resource_record_type | ||
} | ||
} | ||
|
||
allow_overwrite = true | ||
name = each.value.name | ||
records = [each.value.record] | ||
type = each.value.type | ||
zone_id = local.acct.dns_zone["id"] | ||
ttl = 60 | ||
} |
8 changes: 8 additions & 0 deletions
8
infrastructure/terraform/components/iam/route53_record_root.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Record to support Cognito Hosted UIs per https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html | ||
resource "aws_route53_record" "root" { | ||
name = local.root_domain_name | ||
zone_id = local.acct.dns_zone["id"] | ||
type = "A" | ||
ttl = 300 | ||
records = ["127.0.0.1"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.tfvars |