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

fix: ACM cert not being recreated on domain name addition #518

Merged
merged 8 commits into from
Oct 24, 2023

Conversation

bryan-robitaille
Copy link
Contributor

Summary | Résumé

ACM certificate not being lifecycled to include new domain names.

@github-actions
Copy link

⚠ Terrform update available

Terraform: 1.6.2 (using 1.4.2)
Terragrunt: 0.52.4 (using 0.46.3)

@bryan-robitaille bryan-robitaille marked this pull request as ready for review October 24, 2023 17:53
@github-actions
Copy link

Staging: load_balancer

✅   Terraform Init: success
✅   Terraform Validate: success
✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

⚠️   Warning: resources will be destroyed by this change!

Plan: 3 to add, 1 to change, 3 to destroy
Show summary
CHANGE NAME
add aws_route53_record.form_viewer_certificate_validation["forms-formulaires.canada.ca"]
aws_route53_record.form_viewer_certificate_validation["forms-staging.cdssandbox.xyz"]
delete aws_route53_record.form_viewer_certificate_validation["0"]
aws_route53_record.form_viewer_certificate_validation["1"]
update aws_lb_listener.form_viewer_https
recreate aws_acm_certificate.form_viewer
Show plan
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
  - destroy
+/- create replacement and then destroy

Terraform will perform the following actions:

  # aws_acm_certificate.form_viewer must be replaced
+/- resource "aws_acm_certificate" "form_viewer" {
      ~ arn                       = "arn:aws:acm:ca-central-1:687401027353:certificate/06cc7e5e-6aac-4477-bae5-b0409d6da2f6" -> (known after apply)
      ~ domain_validation_options = [
          - {
              - domain_name           = "forms-staging.cdssandbox.xyz"
              - resource_record_name  = "_42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz."
              - resource_record_type  = "CNAME"
              - resource_record_value = "_daaca6a8062fb25ab6d88dcde571d1a3.rlltrpyzyf.acm-validations.aws."
            },
          + {
              + domain_name           = "forms-formulaires.canada.ca"
              + resource_record_name  = (known after apply)
              + resource_record_type  = (known after apply)
              + resource_record_value = (known after apply)
            },
          + {
              + domain_name           = "forms-staging.cdssandbox.xyz"
              + resource_record_name  = (known after apply)
              + resource_record_type  = (known after apply)
              + resource_record_value = (known after apply)
            },
        ]
      ~ id                        = "arn:aws:acm:ca-central-1:687401027353:certificate/06cc7e5e-6aac-4477-bae5-b0409d6da2f6" -> (known after apply)
      ~ status                    = "ISSUED" -> (known after apply)
      ~ subject_alternative_names = [ # forces replacement
          + "forms-formulaires.canada.ca",
        ]
        tags                      = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
      ~ validation_emails         = [] -> (known after apply)
        # (3 unchanged attributes hidden)

      - options {
          - certificate_transparency_logging_preference = "ENABLED" -> null
        }
    }

  # aws_lb_listener.form_viewer_https will be updated in-place
  ~ resource "aws_lb_listener" "form_viewer_https" {
      ~ certificate_arn   = "arn:aws:acm:ca-central-1:687401027353:certificate/06cc7e5e-6aac-4477-bae5-b0409d6da2f6" -> (known after apply)
        id                = "arn:aws:elasticloadbalancing:ca-central-1:687401027353:listener/app/form-viewer/5e6bc2d9ab810b68/028e8eeeed9c3a34"
        tags              = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (6 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

  # aws_route53_record.form_viewer_certificate_validation["0"] will be destroyed
  # (because key ["0"] is not in for_each map)
  - resource "aws_route53_record" "form_viewer_certificate_validation" {
      - allow_overwrite = true -> null
      - fqdn            = "_42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz" -> null
      - id              = "Z05990652HOQ0SGHD81ZC__42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz._CNAME" -> null
      - name            = "_42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz" -> null
      - records         = [
          - "_daaca6a8062fb25ab6d88dcde571d1a3.rlltrpyzyf.acm-validations.aws.",
        ] -> null
      - ttl             = 60 -> null
      - type            = "CNAME" -> null
      - zone_id         = "Z05990652HOQ0SGHD81ZC" -> null
    }

  # aws_route53_record.form_viewer_certificate_validation["1"] will be destroyed
  # (because key ["1"] is not in for_each map)
  - resource "aws_route53_record" "form_viewer_certificate_validation" {
      - allow_overwrite = true -> null
      - fqdn            = "_42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz.forms-formulaires.canada.ca" -> null
      - id              = "Z10455362UNR7HEX7QJTL__42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz._CNAME" -> null
      - name            = "_42cd5dd49f1c1123566280c716149b50.forms-staging.cdssandbox.xyz" -> null
      - records         = [
          - "_daaca6a8062fb25ab6d88dcde571d1a3.rlltrpyzyf.acm-validations.aws.",
        ] -> null
      - ttl             = 60 -> null
      - type            = "CNAME" -> null
      - zone_id         = "Z10455362UNR7HEX7QJTL" -> null
    }

  # aws_route53_record.form_viewer_certificate_validation["forms-formulaires.canada.ca"] will be created
  + resource "aws_route53_record" "form_viewer_certificate_validation" {
      + allow_overwrite = true
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = (known after apply)
      + records         = (known after apply)
      + ttl             = 60
      + type            = (known after apply)
      + zone_id         = "Z10455362UNR7HEX7QJTL"
    }

  # aws_route53_record.form_viewer_certificate_validation["forms-staging.cdssandbox.xyz"] will be created
  + resource "aws_route53_record" "form_viewer_certificate_validation" {
      + allow_overwrite = true
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = (known after apply)
      + records         = (known after apply)
      + ttl             = 60
      + type            = (known after apply)
      + zone_id         = "Z05990652HOQ0SGHD81ZC"
    }

Plan: 3 to add, 1 to change, 3 to destroy.

Warning: Argument is deprecated

  with aws_s3_bucket.firehose_waf_logs,
  on kinesis.tf line 30, in resource "aws_s3_bucket" "firehose_waf_logs":
  30: resource "aws_s3_bucket" "firehose_waf_logs" {

Use the aws_s3_bucket_server_side_encryption_configuration resource instead

(and 5 more similar warnings elsewhere)

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_wafv2_regex_pattern_set.forms_base_url"]
WARN - plan.json - main - Missing Common Tags: ["aws_wafv2_regex_pattern_set.valid_app_uri_paths"]

19 tests, 17 passed, 2 warnings, 0 failures, 0 exceptions

@github-actions
Copy link

Staging: alarms

✅   Terraform Init: success
✅   Terraform Validate: success
✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 0 to add, 2 to change, 0 to destroy
Show summary
CHANGE NAME
update aws_cloudwatch_metric_alarm.ddos_detected_route53_warn[1]
aws_cloudwatch_metric_alarm.route53_ddos[1]
Show plan
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_cloudwatch_metric_alarm.ddos_detected_route53_warn[1] will be updated in-place
  ~ resource "aws_cloudwatch_metric_alarm" "ddos_detected_route53_warn" {
      ~ dimensions                = {
          ~ "ResourceArn" = "Z05990652HOQ0SGHD81ZC" -> "Z10455362UNR7HEX7QJTL"
        }
        id                        = "DDoSDetectedRoute53Warn"
        tags                      = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (17 unchanged attributes hidden)
    }

  # aws_cloudwatch_metric_alarm.route53_ddos[1] will be updated in-place
  ~ resource "aws_cloudwatch_metric_alarm" "route53_ddos" {
      ~ dimensions                = {
          ~ "ResourceArn" = "Z05990652HOQ0SGHD81ZC" -> "Z10455362UNR7HEX7QJTL"
        }
        id                        = "Route53DDoS"
        tags                      = {}
        # (17 unchanged attributes hidden)
    }

Plan: 0 to add, 2 to change, 0 to destroy.

Warning: Argument is deprecated

  with module.athena_bucket.aws_s3_bucket.this,
  on .terraform/modules/athena_bucket/S3/main.tf line 8, in resource "aws_s3_bucket" "this":
   8: resource "aws_s3_bucket" "this" {

Use the aws_s3_bucket_lifecycle_configuration resource instead

(and 8 more similar warnings elsewhere)

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Show Conftest results
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.notify_slack"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.alb_ddos"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.route53_ddos[0]"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.route53_ddos[1]"]

21 tests, 17 passed, 4 warnings, 0 failures, 0 exceptions

Copy link
Contributor

@craigzour craigzour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bryan-robitaille bryan-robitaille merged commit 2ba215d into develop Oct 24, 2023
4 checks passed
@bryan-robitaille bryan-robitaille deleted the fix/acm_certificate branch October 24, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants