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: GC Notify API Key is not properly passed to Nagware and Reliability lambdas #553

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

craigzour
Copy link
Contributor

@craigzour craigzour commented Dec 13, 2023

Summary | Résumé

  • Fixed GC Notify API key not being properly passed (string instead of ARN) to Nagware and Reliability lambdas
  • Removed token_secret from lambda module as it was not used

What happened:
With the new infra rework we did not take into account the fact that two of our lambdas were using the string value of the GC Notify API key secret. We converted it to an ARN value but the code does not know how to handle such value.

Note: We could definitely rework that at some point by adding an extra request to go get the secret value using the ARN.

@craigzour craigzour self-assigned this Dec 13, 2023
Copy link

⚠ Terrform update available

Terragrunt: 0.54.2 (using 0.53.8)

Copy link

Staging: secrets

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

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

Plan: 1 to add, 0 to change, 1 to destroy
Show summary
CHANGE NAME
recreate aws_secretsmanager_secret_version.notify_callback_bearer_token
Show plan
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_secretsmanager_secret_version.notify_callback_bearer_token must be replaced
-/+ resource "aws_secretsmanager_secret_version" "notify_callback_bearer_token" {
      ~ arn            = "arn:aws:secretsmanager:ca-central-1:687401027353:secret:notify_callback_bearer_token-aXJPLs" -> (known after apply)
      ~ id             = "arn:aws:secretsmanager:ca-central-1:687401027353:secret:notify_callback_bearer_token-aXJPLs|4A43D97C-2937-4E91-A924-ADF60955E459" -> (known after apply)
      ~ secret_string  = (sensitive value) # forces replacement
      ~ version_id     = "4A43D97C-2937-4E91-A924-ADF60955E459" -> (known after apply)
      ~ version_stages = [
          - "AWSCURRENT",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

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

Changes to Outputs:
  + notify_api_key_secret_value             = (sensitive value)

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

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Show Conftest results
20 tests, 20 passed, 0 warnings, 0 failures, 0 exceptions

Copy link

Staging: lambdas

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

Plan: 0 to add, 4 to change, 0 to destroy
Show summary
CHANGE NAME
update aws_iam_policy.lambda_secrets
aws_lambda_function.nagware
aws_lambda_function.reliability
aws_lambda_function.vault_integrity
Show plan
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_iam_policy.lambda_secrets will be updated in-place
  ~ resource "aws_iam_policy" "lambda_secrets" {
        id          = "arn:aws:iam::687401027353:policy/lambda_secrets"
        name        = "lambda_secrets"
      ~ policy      = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Resource = [
                          - "arn:aws:secretsmanager:ca-central-1:687401027353:secret:token_secret-n5Doyu",
                          - "arn:aws:secretsmanager:ca-central-1:687401027353:secret:notify_api_key-eR3nNp",
                          - "arn:aws:secretsmanager:ca-central-1:687401027353:secret:database-secret-vHJuTe",
                        ] -> "arn:aws:secretsmanager:ca-central-1:687401027353:secret:database-secret-vHJuTe"
                        # (3 unchanged attributes hidden)
                    },
                ]
                # (1 unchanged attribute hidden)
            }
        )
        tags        = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (5 unchanged attributes hidden)
    }

  # aws_lambda_function.nagware will be updated in-place
  ~ resource "aws_lambda_function" "nagware" {
        id                             = "Nagware"
        tags                           = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (22 unchanged attributes hidden)

      ~ environment {
          ~ variables = {
              # Warning: this attribute value will be marked as sensitive and will not
              # display in UI output after applying this change.
              ~ "NOTIFY_API_KEY"            = (sensitive value)
                # (10 unchanged elements hidden)
            }
        }

        # (1 unchanged block hidden)
    }

  # aws_lambda_function.reliability will be updated in-place
  ~ resource "aws_lambda_function" "reliability" {
        id                             = "Reliability"
        tags                           = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (22 unchanged attributes hidden)

      ~ environment {
          ~ variables = {
              # Warning: this attribute value will be marked as sensitive and will not
              # display in UI output after applying this change.
              ~ "NOTIFY_API_KEY" = (sensitive value)
                # (7 unchanged elements hidden)
            }
        }

        # (1 unchanged block hidden)
    }

  # aws_lambda_function.vault_integrity will be updated in-place
  ~ resource "aws_lambda_function" "vault_integrity" {
        id                             = "Vault_Data_Integrity_Check"
      ~ last_modified                  = "2023-12-11T15:10:23.000+0000" -> (known after apply)
      ~ source_code_hash               = "9opCvMNrZA+BCLvHUGkHDweCXfVwLgP5jcHfkTPLySc=" -> "TowbMcppnki+0a5fq50Oral3CqleiwGw7U1igvFz0Ws="
        tags                           = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (22 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

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

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

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_event_rule.cron_2am_every_day"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.cron_3am_every_day"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.cron_4am_every_day"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.cron_5am_every_business_day"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.archive_form_templates"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.audit_logs"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.dead_letter_queue_consumer"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.nagware"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.reliability"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.response_archiver"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.submission"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.vault_integrity"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.audit_logs_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.form_archiver_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.nagware_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.reliability_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.reliability_dlq_consumer_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.response_archiver_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.submission_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_s3_bucket_object.vault_integrity_code"]
WARN - plan.json - main - Missing Common Tags: ["aws_signer_signing_profile.lambda_signing_profile[0]"]

40 tests, 19 passed, 21 warnings, 0...

@craigzour craigzour merged commit 0c9bfaa into develop Dec 13, 2023
4 checks passed
@craigzour craigzour deleted the fix/gc-notify-api-key branch December 13, 2023 19:26
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.

2 participants