-
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.
Use the new Terraform module to create ACM certificates
- Loading branch information
1 parent
1c5038c
commit c9b2b7f
Showing
4 changed files
with
24 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ node_modules/ | |
|
||
# JetBrains IDEs | ||
.idea | ||
|
||
# Terraform | ||
*.plan |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 +1,23 @@ | ||
resource "aws_acm_certificate" "content_api" { | ||
locals { | ||
// This is not the same as the external hostname! | ||
// It should correspond to the origin domains in the CloudFront distribution: | ||
// https://github.com/wellcomecollection/platform-infrastructure/blob/main/cloudfront/api.wellcomecollection.org/main.tf | ||
domain_name = "content.api-${var.environment}.wellcomecollection.org" | ||
validation_method = "DNS" | ||
cert_domain_name = "content.api-${var.environment}.wellcomecollection.org" | ||
} | ||
|
||
module "cert" { | ||
source = "github.com/wellcomecollection/terraform-aws-acm-certificate?ref=v1.0.0" | ||
|
||
domain_name = local.cert_domain_name | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
zone_id = data.aws_route53_zone.dotorg.id | ||
|
||
providers = { | ||
aws.dns = aws.dns | ||
} | ||
} | ||
|
||
data "aws_route53_zone" "dotorg" { | ||
provider = aws.dns | ||
name = "wellcomecollection.org." | ||
} | ||
|
||
resource "aws_route53_record" "content_certificate_validation" { | ||
provider = aws.dns | ||
for_each = { | ||
for dvo in aws_acm_certificate.content_api.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] | ||
ttl = 60 | ||
type = each.value.type | ||
zone_id = data.aws_route53_zone.dotorg.zone_id | ||
} | ||
|
||
resource "aws_acm_certificate_validation" "content" { | ||
certificate_arn = aws_acm_certificate.content_api.arn | ||
validation_record_fqdns = [for record in aws_route53_record.content_certificate_validation : record.fqdn] | ||
} |