Skip to content

Commit

Permalink
feat(tmp): temporary changes to the module to allow cloudfront distri…
Browse files Browse the repository at this point in the history
…bution migration
  • Loading branch information
jindraj committed Jul 25, 2024
1 parent 2c3e625 commit 962a893
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 22 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,30 @@ module "certificate" {

validation_method = "DNS"
wait_for_validation = true
create_route53_records = false # TODO: revert before merge

tags = local.tags
}

module "tmp_route53_record" { # TODO revert before merge
source = "terraform-aws-modules/acm/aws"
version = "~> 4.0"

providers = {
aws = aws.us_east_1
}

create_certificate = false
create_route53_records_only = true

validation_method = "DNS"

distinct_domain_names = [local.main_domain]
zone_id = var.domain_zone_id

acm_certificate_domain_validation_options = module.certificate.acm_certificate_domain_validation_options
}

resource "aws_cloudfront_origin_access_control" "this" {
name = "Access from CF to S3 - ${local.main_domain}"
description = "Access from CF to S3 - ${local.main_domain}"
Expand Down Expand Up @@ -64,7 +84,7 @@ data "aws_iam_policy_document" "bucket_policy" {
condition {
test = "StringEquals"
variable = "AWS:SourceArn"
values = [aws_cloudfront_distribution.this.arn]
values = [aws_cloudfront_distribution.this.arn,var.tmp_additional_cloudfront_distribution_arn] #TODO: revert before mege
}

}
Expand Down Expand Up @@ -254,7 +274,7 @@ resource "aws_cloudfront_distribution" "this" {
}

resource "aws_route53_record" "this" {
for_each = toset(var.domains)
for_each = toset([local.main_domain]) # TODO: revert before merge

zone_id = var.domain_zone_id
name = each.value
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ variable "kms_deletion_window_in_days" {
default = 30
description = "The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key"
}

variable "tmp_additional_cloudfront_distribution_arn" {
type = string
description = "Temporary variable to pass additional cloudfront distribution to s3 bucket policy"
}

0 comments on commit 962a893

Please sign in to comment.