Code Monkey home page Code Monkey logo

terraform-azurerm-application-gateway's Introduction

Application Gateway

This template is not optimal at the moment due to missing azurerm provider features. Will be fixed as soon as there is an updated provider

This module deploys a simplified version of Application Gateway v2, it does not support v1 of Application Gateway. It is a slim down version that is meant to be configured by an external application, in this case https://github.com/Azure/application-gateway-kubernetes-ingress. It will create some endpoints and backends because that is required, but will ignore any changes to them on later deployments. That way any changes done by external application will be kept.

Although it is slimmed down there are some options to configure the security policies, private ip and waf configurations. It will however always use sku Standard_v2 or WAF_v2 based on if waf is enabled.

Usage

To create a simple application gateway.

module "simple" {
  source  = "avinor/application-gateway/azurerm"
  version = "1.0.0"

  resource_group_name = "appgw-rg"
  location            = "westeurope"
  subnet_id           = "/subscriptions/...."

  private_ip_address = "10.0.0.100"

  capacity = {
    min = 1
    max = 2
  }

  zones = ["1", "2", "3"]
}

Diagnostics

Diagnostics settings can be sent to either storage account, event hub or Log Analytics workspace. The variable diagnostics.destination is the id of receiver, ie. storage account id, event namespace authorization rule id or log analytics resource id. Depending on what id is it will detect where to send. Unless using event namespace the eventhub_name is not required, just set to null for storage account and log analytics workspace.

Setting all in logs and metrics will send all possible diagnostics to destination. If not using all type name of categories to send.

WAF

To enable WAF set waf_enabled to true and it will automatically deploy sku WAF_v2 (this required redeploy if it was disabled). To configure WAF settings set the waf_configuration variable. It will default to resonable values.

Rewrite rules

Rewrite rules can be specified and should be linked to routes outside this module.

Custom policies

In addition to the default policies in firewall it is also possible to add custom policies. These can be additional security rules or exceptions to allow traffic. Using the custom_policies variable it is possible to customize the firewall rules. It will create a custom policy and associate it with the firewall.

custom_policies variable follow similar structure as the terraform resource. Priority will be set according to order in list, higher priority for elements early in the list.

Example of policy:

custom_policies = [
  {
    name             = "AllowRefererBeginWithExample"
    rule_type        = "MatchRule"
    action           = "Allow"
    match_conditions = [
      {
        match_variables = [
          {
            match_variable = "RequestHeaders"
            selector       = "referer"
          }
        ]
        operator           = "BeginsWith"
        negation_condition = false
        match_values       = ["https://example.com"]
      }
    ]
  }
]

For details how to write custom policies see the Microsoft documentation.

Managed rules

It is possible to add waf policies for managed rules to disable rules.

managed_policies_override = [
  {
    rule_group_name = "REQUEST-920-PROTOCOL-ENFORCEMENT"
    disabled_rules  = ["920300", "920440"]
  },
  {
    rule_group_name = "REQUEST-930-APPLICATION-ATTACK-LFI"
    disabled_rules  = ["930100"]
  },
]

for details for managed rules se the Microsoft documentation

Managed Identity

Since this module was created to be used together with AKS it also creates a managed identity that have access to modify the Application Gateway. Id and client_id of managed identity is part of output and can be used by external application to control configurations.

terraform-azurerm-application-gateway's People

Contributors

bassoflion avatar dependabot[bot] avatar emilkor1-avinor avatar hansinor avatar hbauge avatar insulaventus avatar larschri avatar nicholbs avatar tesharp avatar yngveh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

terraform-azurerm-application-gateway's Issues

Waf policy conflict

I am getting a waf policy conflict during the apply.

The WAF Policy has the following conflicts with the existing WAF Configuration: Disabled Rule Groups (Config has 0; Policy has 2. ), Exclusions ( Config has 0; Policy has 1. ). To override the existing WAF Configuration with the settings in the WAF Policy, please visit https://aka.ms/wafforcepolicy for more details." Details=[]

Plan is basically same as https://github.com/avinor/terraform-azurerm-application-gateway/blob/master/examples/waf/main.tf

If remove managed_policies_override rules and managed_policies_exclusions rules it deploys as expected

I don't see anything in the terraform doc about this force policy option that seems to be available in powershell any ideas?

azurerm 2.85.0
tf 0.13.6

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.