Giter Club home page Giter Club logo

dwp.terraform-aws-waf's Introduction

terraform-aws-waf

A Terraform module to create an AWS Classic Regional WAF with consistent features

Usage

In its simplest form, this module will create a WAF with all default rules enabled and a Kinesis Firehose delivery stream to write logs to S3 and CloudWatch.

module waf {
  source = "dwp/waf/aws"

  name                  = "example"
  s3_log_bucket         = "example-bucket"
  whitelist_cidr_blocks = ["0.0.0.0/0"]

  tags = []
}

All IPs not included in whitelist_cidr_blocks will be blocked by the WAF.

The geo-match rule defaults to Country: GB, and can be overridden/extended using the geo_match_constraints variable.

This WAF applies size constraints on incoming requests, which can be set with the max_size_constraints variable. The default values are (in bytes):

Component Max allowed size
Body 8192
Cookie 4092
Query String 1024
URI 512

Individual rules can be disabled with the enabled_rules variable, and custom ones can be specified with custom_rules. Custom rules have higher priority than the default ones.

Complex example

resource "aws_wafregional_rule" "custom_rule" {
  name        = "custom_rule"
  metric_name = "custom_rule"

  predicate {
    data_id = ...
    negated = ...
    type    = ...
  }
}

module waf {
  source = "dwp/waf/aws"

  name                  = "example"
  s3_log_bucket         = "example-bucket"
  whitelist_cidr_blocks = ["0.0.0.0/0"]

  max_size_constraints = {
    body         = 1024
    cookie       = 512
    query_string = 256
    uri          = 512
  }

  enabled_rules = {
    xss               = true
    rfi_lfi_traversal = true
    enforce_csrf      = false
    sqli              = false
    ssi               = true
    bad_auth_tokens   = true
  }

  custom_rules = [
    {
        action  = "BLOCK"
        rule_id = aws_wafregional_rule.custom_rule.id
    }
  ]

  tags = []
}

dwp.terraform-aws-waf's People

Contributors

draagc-iw avatar dataworks-ci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.