Skip to content

Commit

Permalink
Updated vars
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfox675 committed Apr 19, 2021
1 parent 58818ce commit 47fd3ef
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
data "aws_route53_zone" "parent_zone" {
data "aws_route53_zone" "this" {
zone_id = var.r53_zone_id
private_zone = false
}

resource "aws_acm_certificate" "primary" {
domain_name = "${var.tenant_name}.${data.aws_route53_zone.parent_zone.name}"
resource "aws_acm_certificate" "this" {
domain_name = var.domain_name
validation_method = "DNS"

subject_alternative_names = ["origin.${var.tenant_name}.${data.aws_route53_zone.parent_zone.name}"]
subject_alternative_names = var.subject_alternative_names

options {
certificate_transparency_logging_preference = "ENABLED"
Expand All @@ -17,19 +17,12 @@ resource "aws_acm_certificate" "primary" {
create_before_destroy = true
}

tags = merge(
var.tags,
{
Name = "${var.tenant_name}-primary",
SaaSResoure = true,
DedicatedToTenant = true,
},
)
tags = var.tags
}

resource "aws_route53_record" "acm_validation" {
resource "aws_route53_record" "this" {
for_each = {
for dvo in aws_acm_certificate.primary.domain_validation_options : dvo.domain_name => {
for dvo in aws_acm_certificate.this.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
Expand All @@ -39,14 +32,14 @@ resource "aws_route53_record" "acm_validation" {
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
ttl = var.ttl
type = each.value.type
zone_id = var.r53_zone_id
}

resource "aws_acm_certificate_validation" "primary" {
certificate_arn = aws_acm_certificate.primary.arn
validation_record_fqdns = [for record in aws_route53_record.acm_validation : record.fqdn]
resource "aws_acm_certificate_validation" "this" {
certificate_arn = aws_acm_certificate.this.arn
validation_record_fqdns = [for record in aws_route53_record.this : record.fqdn]

timeouts {
create = "60m"
Expand Down

0 comments on commit 47fd3ef

Please sign in to comment.