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 DDoS protection to ALB and hosted zone #150

Merged
merged 2 commits into from
Dec 8, 2021

Conversation

patheard
Copy link
Member

@patheard patheard commented Dec 8, 2021

Summary

Adds the ALB and Route53 hosted zone to AWS Shield Advanced's
DDoS protection.

Also creates DDoS CloudWatch alarms and the SNS topics,
subscriptions and KMS keys required for the us-east-1
hosted zone alarm.

Related

Adds the ALB and Route53 hosted zone to AWS Shield Advanced's
DDoS protection.

Also creates DDoS CloudWatch alarms and the SNS topics,
subscriptions and KMS keys required for the us-east-1
hosted zone alarm.
@patheard patheard self-assigned this Dec 8, 2021
@github-actions
Copy link

github-actions bot commented Dec 8, 2021

⚠ Terrform update available

Terraform: 1.0.11 (using 1.0.10)
Terragrunt: 0.35.13 (using 0.35.6)

@github-actions
Copy link

github-actions bot commented Dec 8, 2021

Staging: kms

✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 1 to add, 0 to change, 0 to destroy
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_kms_key.cloudwatch_us_east will be created
  + resource "aws_kms_key" "cloudwatch_us_east" {
      + arn                                = (known after apply)
      + bypass_policy_lockout_safety_check = false
      + customer_master_key_spec           = "SYMMETRIC_DEFAULT"
      + description                        = "CloudWatch Log Group Key"
      + enable_key_rotation                = true
      + id                                 = (known after apply)
      + is_enabled                         = true
      + key_id                             = (known after apply)
      + key_usage                          = "ENCRYPT_DECRYPT"
      + policy                             = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = "kms:*"
                      + Effect    = "Allow"
                      + Principal = {
                          + AWS = "arn:aws:iam::687401027353:root"
                        }
                      + Resource  = "*"
                      + Sid       = "Enable IAM User Permissions"
                    },
                  + {
                      + Action    = [
                          + "kms:ReEncrypt*",
                          + "kms:GenerateDataKey*",
                          + "kms:Encrypt*",
                          + "kms:Describe*",
                          + "kms:Decrypt*",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "logs.ca-central-1.amazonaws.com"
                        }
                      + Resource  = "*"
                      + Sid       = ""
                    },
                  + {
                      + Action    = [
                          + "kms:GenerateDataKey*",
                          + "kms:Decrypt",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "cloudwatch.amazonaws.com"
                        }
                      + Resource  = "*"
                      + Sid       = "Allow_CloudWatch_for_CMK"
                    },
                  + {
                      + Action    = [
                          + "kms:ReEncrypt*",
                          + "kms:GenerateDataKey*",
                          + "kms:Encrypt*",
                          + "kms:Describe*",
                          + "kms:Decrypt*",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = "events.amazonaws.com"
                        }
                      + Resource  = "*"
                      + Sid       = "CloudwatchEvents"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + tags                               = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + tags_all                           = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
    }

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

Changes to Outputs:
  + kms_key_cloudwatch_us_east_arn = (known after apply)

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

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Releasing state lock. This may take a few moments...
Show Conftest results
9 tests, 9 passed, 0 warnings, 0 failures, 0 exceptions

@github-actions
Copy link

github-actions bot commented Dec 8, 2021

Staging: load_balancer

✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 2 to add, 0 to change, 0 to destroy
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_shield_protection.alb will be created
  + resource "aws_shield_protection" "alb" {
      + arn          = (known after apply)
      + id           = (known after apply)
      + name         = "LoadBalancer"
      + resource_arn = "arn:aws:elasticloadbalancing:ca-central-1:687401027353:loadbalancer/app/form-viewer/5e6bc2d9ab810b68"
      + tags         = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + tags_all     = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
    }

  # aws_shield_protection.route53_hosted_zone will be created
  + resource "aws_shield_protection" "route53_hosted_zone" {
      + arn          = (known after apply)
      + id           = (known after apply)
      + name         = "Route53HostedZone"
      + resource_arn = "arn:aws:route53:::hostedzone/Z05990652HOQ0SGHD81ZC"
      + tags         = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + tags_all     = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
    }

Plan: 2 to add, 0 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"
Releasing state lock. This may take a few moments...
Show Conftest results
9 tests, 9 passed, 0 warnings, 0 failures, 0 exceptions

@github-actions
Copy link

github-actions bot commented Dec 8, 2021

Staging: alarms

✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 6 to add, 0 to change, 0 to destroy
Show plan
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_cloudwatch_metric_alarm.alb_ddos will be created
  + resource "aws_cloudwatch_metric_alarm" "alb_ddos" {
      + actions_enabled                       = true
      + alarm_actions                         = [
          + "arn:aws:sns:ca-central-1:687401027353:alert-warning",
        ]
      + alarm_description                     = "DDoS detection for ALB"
      + alarm_name                            = "ALBDDoS"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanThreshold"
      + dimensions                            = {
          + "ResourceArn" = "arn:aws:elasticloadbalancing:ca-central-1:687401027353:loadbalancer/app/form-viewer/5e6bc2d9ab810b68"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "DDoSDetected"
      + namespace                             = "AWS/DDoSProtection"
      + ok_actions                            = [
          + "arn:aws:sns:ca-central-1:687401027353:alert-ok",
        ]
      + period                                = 60
      + statistic                             = "Sum"
      + tags_all                              = (known after apply)
      + threshold                             = 0
      + treat_missing_data                    = "notBreaching"
    }

  # aws_cloudwatch_metric_alarm.route53_ddos will be created
  + resource "aws_cloudwatch_metric_alarm" "route53_ddos" {
      + actions_enabled                       = true
      + alarm_actions                         = (known after apply)
      + alarm_description                     = "DDoS detection for Route53"
      + alarm_name                            = "Route53DDoS"
      + arn                                   = (known after apply)
      + comparison_operator                   = "GreaterThanThreshold"
      + dimensions                            = {
          + "ResourceArn" = "arn:aws:route53:::hostedzone/Z05990652HOQ0SGHD81ZC"
        }
      + evaluate_low_sample_count_percentiles = (known after apply)
      + evaluation_periods                    = 1
      + id                                    = (known after apply)
      + metric_name                           = "DDoSDetected"
      + namespace                             = "AWS/DDoSProtection"
      + ok_actions                            = (known after apply)
      + period                                = 60
      + statistic                             = "Sum"
      + tags_all                              = (known after apply)
      + threshold                             = 0
      + treat_missing_data                    = "notBreaching"
    }

  # aws_sns_topic.alert_ok_us_east will be created
  + resource "aws_sns_topic" "alert_ok_us_east" {
      + arn                         = (known after apply)
      + content_based_deduplication = false
      + fifo_topic                  = false
      + id                          = (known after apply)
      + name                        = "alert-ok"
      + name_prefix                 = (known after apply)
      + owner                       = (known after apply)
      + policy                      = (known after apply)
      + tags                        = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + tags_all                    = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
    }

  # aws_sns_topic.alert_warning_us_east will be created
  + resource "aws_sns_topic" "alert_warning_us_east" {
      + arn                         = (known after apply)
      + content_based_deduplication = false
      + fifo_topic                  = false
      + id                          = (known after apply)
      + name                        = "alert-warning"
      + name_prefix                 = (known after apply)
      + owner                       = (known after apply)
      + policy                      = (known after apply)
      + tags                        = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
      + tags_all                    = {
          + "CostCentre" = "forms-platform-staging"
          + "Terraform"  = "true"
        }
    }

  # aws_sns_topic_subscription.topic_ok_us_east will be created
  + resource "aws_sns_topic_subscription" "topic_ok_us_east" {
      + arn                             = (known after apply)
      + confirmation_timeout_in_minutes = 1
      + confirmation_was_authenticated  = (known after apply)
      + endpoint                        = "arn:aws:lambda:ca-central-1:687401027353:function:NotifySlackSNS"
      + endpoint_auto_confirms          = false
      + id                              = (known after apply)
      + owner_id                        = (known after apply)
      + pending_confirmation            = (known after apply)
      + protocol                        = "lambda"
      + raw_message_delivery            = false
      + topic_arn                       = (known after apply)
    }

  # aws_sns_topic_subscription.topic_warning_us_east will be created
  + resource "aws_sns_topic_subscription" "topic_warning_us_east" {
      + arn                             = (known after apply)
      + confirmation_timeout_in_minutes = 1
      + confirmation_was_authenticated  = (known after apply)
      + endpoint                        = "arn:aws:lambda:ca-central-1:687401027353:function:NotifySlackSNS"
      + endpoint_auto_confirms          = false
      + id                              = (known after apply)
      + owner_id                        = (known after apply)
      + pending_confirmation            = (known after apply)
      + protocol                        = "lambda"
      + raw_message_delivery            = false
      + topic_arn                       = (known after apply)
    }

Plan: 6 to add, 0 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"
Releasing state lock. This may take a few moments...
Show Conftest results
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"]

10 tests, 8 passed, 2 warnings, 0 failures, 0 exceptions

@github-actions
Copy link

github-actions bot commented Dec 8, 2021

Staging: load_testing

✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 0 to add, 1 to change, 0 to destroy
Show plan
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_lambda_function.load_testing will be updated in-place
  ~ resource "aws_lambda_function" "load_testing" {
        id                             = "LoadTesting"
      ~ last_modified                  = "2021-11-19T19:07:39.547+0000" -> (known after apply)
      ~ source_code_hash               = "idSfcJlONg/Yf7s88bf66oe5XaZaNLpI0x10yS/k7YQ=" -> "UXXWYoeI//NeJZn1fjs5KQvR7BmCZ1ydd0FpCE3EOv0="
        tags                           = {
            "CostCentre" = "forms-platform-staging"
            "Terraform"  = "true"
        }
        # (19 unchanged attributes hidden)


        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 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"
Releasing state lock. This may take a few moments...
Show Conftest results
9 tests, 9 passed, 0 warnings, 0 failures, 0 exceptions

@patheard patheard marked this pull request as ready for review December 8, 2021 18:53
@patheard patheard merged commit 865430e into main Dec 8, 2021
@patheard patheard deleted the feat/aws-shield-advanced branch December 8, 2021 21:10
craigzour pushed a commit that referenced this pull request Dec 15, 2021
Adds the ALB and Route53 hosted zone to AWS Shield Advanced's
DDoS protection.

Also creates DDoS CloudWatch alarms and the SNS topics,
subscriptions and KMS keys required for the us-east-1
hosted zone alarm.
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