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

feat: add CloudWatch Lambda function invocation alarms #706

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

patheard
Copy link
Member

Summary

Add CloudWatch alarms for the following three functions:

  1. form-archiver: expect 1 invocation per day.
  2. nagware: expect 1 invocation on Tuesday, Thursday and Sunday.
  3. response-archiver: expect 1 invocation per day

Related

Add CloudWatch alarms for the following three functions:

1. form-archiver: expect 1 invocation per day.
2. nagware: expect 1 invocation on Tuesday, Thursday and Sunday.
3. response-archiver: expect 1 invocation per day
@patheard patheard self-assigned this Jun 24, 2024
Copy link

⚠ Terrform update available

Terraform: 1.8.5 (using 1.6.6)
Terragrunt: 0.59.5 (using 0.54.8)

Copy link

Staging: lambdas

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

Plan: 0 to add, 0 to change, 0 to destroy
Show summary
CHANGE NAME
Show plan
Changes to Outputs:
  + lambda_form_archiver_function_name             = "form-archiver"
  + lambda_nagware_function_name                   = "nagware"
  + lambda_response_archiver_function_name         = "response-archiver"

You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.

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

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.audit_logs_archiver_lambda_trigger"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.form_archiver_lambda_trigger"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.nagware_lambda_trigger"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.reliability_dlq_lambda_trigger"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_event_rule.response_archiver_lambda_trigger"]
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.audit_logs_archiver"]
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_iam_policy.lambda_dynamodb"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_kms"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_logging"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_rds"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_s3"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_secrets"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_sns"]
WARN - plan.json - main - Missing Common Tags: ["aws_iam_policy.lambda_sqs"]
WARN -...

Copy link

Staging: alarms

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

Plan: 3 to add, 0 to change, 0 to destroy
Show summary
CHANGE NAME
add aws_cloudwatch_metric_alarm.healthcheck_lambda_form_archiver_invocations
aws_cloudwatch_metric_alarm.healthcheck_lambda_nagware_invocations_schedule
aws_cloudwatch_metric_alarm.healthcheck_lambda_response_archiver_invocations
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_cloudwatch_metric_alarm.healthcheck_lambda_form_archiver_invocations will be created
  + resource "aws_cloudwatch_metric_alarm" "healthcheck_lambda_form_archiver_invocations" {
      + actions_enabled                       = true
      + alarm_description                     = "HealthCheck - no `form-archiver` invocations in a day."
      + alarm_name                            = "FormArchiverLambdaNoInvocations"
      + arn                                   = (known after apply)
      + comparison_operator                   = "LessThanThreshold"
      + dimensions                            = {
          + "FunctionName" = "form-archiver"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "Invocations"
      + namespace                             = "AWS/Lambda"
      + period                                = 86400
      + statistic                             = "Sum"
      + tags_all                              = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + threshold                             = 1
      + treat_missing_data                    = "breaching"
    }

  # aws_cloudwatch_metric_alarm.healthcheck_lambda_nagware_invocations_schedule will be created
  + resource "aws_cloudwatch_metric_alarm" "healthcheck_lambda_nagware_invocations_schedule" {
      + actions_enabled                       = true
      + alarm_description                     = "HealthCheck - no `nagware` invocations on schedule."
      + alarm_name                            = "NagwareLambdaNoInvocationsSchedule"
      + arn                                   = (known after apply)
      + comparison_operator                   = "LessThanThreshold"
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + tags_all                              = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + threshold                             = 1
      + treat_missing_data                    = "breaching"

      + metric_query {
          + id          = "invocations"
          + return_data = false

          + metric {
              + dimensions  = {
                  + "FunctionName" = "nagware"
                }
              + metric_name = "Invocations"
              + namespace   = "AWS/Lambda"
              + period      = 86400
              + stat        = "Sum"
              + unit        = "Count"
            }
        }
      + metric_query {
          + expression  = "IF((DAY(invocations)==2 OR DAY(invocations)==4 OR DAY(invocations)==7),invocations,1)"
          + id          = "invocations_schedule"
          + label       = "Invocations (schedule)"
          + return_data = true
        }
    }

  # aws_cloudwatch_metric_alarm.healthcheck_lambda_response_archiver_invocations will be created
  + resource "aws_cloudwatch_metric_alarm" "healthcheck_lambda_response_archiver_invocations" {
      + actions_enabled                       = true
      + alarm_description                     = "HealthCheck - no `response-archiver` invocations in a day."
      + alarm_name                            = "ResponseArchiverLambdaNoInvocations"
      + arn                                   = (known after apply)
      + comparison_operator                   = "LessThanThreshold"
      + dimensions                            = {
          + "FunctionName" = "response-archiver"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "Invocations"
      + namespace                             = "AWS/Lambda"
      + period                                = 86400
      + statistic                             = "Sum"
      + tags_all                              = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + threshold                             = 1
      + treat_missing_data                    = "breaching"
    }

Plan: 3 to add, 0 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 3 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_event_rule.codedeploy_sns"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_log_group.notify_slack"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.ELB_5xx_error_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.UnHealthyHostCount-TargetGroup1"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.UnHealthyHostCount-TargetGroup2"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.alb_ddos"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.audit_log_dead_letter_queue_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.cognito_login_outside_canada_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.cognito_signin_exceeded"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.ddos_detected_forms_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.ddos_detected_route53_warn[0]"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.forms_cpu_utilization_high_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.forms_memory_utilization_high_warn"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.healthcheck_lambda_form_archiver_invocations"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.healthcheck_lambda_nagware_invocations_schedule"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.healthcheck_lambda_response_archiver_invocations"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.healthcheck_lambda_submission_invocations_anomaly"]
WARN - plan.json - main - Missing Common Tags: ["aws_cloudwatch_metric_alarm.healthcheck_lambda_submission_invocations_core_hours"]
WARN...

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.

Good stuff :)

@patheard patheard merged commit 24a6cd6 into develop Jun 24, 2024
10 checks passed
@patheard patheard deleted the feat/more-healthcheck-alarms branch June 24, 2024 14:15
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