Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

refactor(module/appgw): Refactor module Application Gateway and adjust examples #345

Merged
merged 94 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
819869f
Add header, update min TF version, refactor variables, removes try
sebastianczech Oct 6, 2023
cdcddc1
Fix README
sebastianczech Oct 6, 2023
a0c071f
Fix types for local network gateway
sebastianczech Oct 6, 2023
a5266eb
Fix issues after tests
sebastianczech Oct 6, 2023
abd0a90
Change default values after additional tests
sebastianczech Oct 6, 2023
041ee6f
Simplify code by removing not needed variable
sebastianczech Oct 6, 2023
a459546
Remove prefix, sufix. All resources have own name attribute.
sebastianczech Oct 6, 2023
f9e7d17
Adjust variables order for VNG
sebastianczech Oct 11, 2023
2e5dc37
Name on the top in variables
sebastianczech Oct 11, 2023
aed1c74
Add example for VNG module
sebastianczech Oct 12, 2023
d2b13b4
Adjust example for VNG
sebastianczech Oct 12, 2023
b4e7513
Merge branch '307-refactor-modules' into 333-virtual_network_gateway
sebastianczech Oct 16, 2023
11a131d
Merge branch '307-refactor-modules' into 333-virtual_network_gateway
sebastianczech Oct 18, 2023
8ded949
Refactor application gateway
sebastianczech Oct 18, 2023
3defc38
Extract rewrites from rules
sebastianczech Oct 19, 2023
fd69af1
Remove not required can()
sebastianczech Oct 19, 2023
46112f9
Adjust redirect configuration
sebastianczech Oct 19, 2023
225a2ff
Rebuild redirects and URL path maps
sebastianczech Oct 19, 2023
e46823a
Add simple HTTP APP GW
sebastianczech Oct 19, 2023
0eec55d
Extend validation and variables description
sebastianczech Oct 19, 2023
c350765
Simplify module main.tf, add default values in example
sebastianczech Oct 19, 2023
7b1b90b
Adjust all examples for application gateway
sebastianczech Oct 19, 2023
eef24c9
Add Terratest for APPGW and VNG examples
sebastianczech Oct 20, 2023
86f134e
Comment APPGW with SSL as certs and keys are not stored in the repo
sebastianczech Oct 20, 2023
ee4c155
Increase apply timeout from default 30 to 60 minutes
sebastianczech Oct 20, 2023
c3ea28f
Extend validation
sebastianczech Oct 23, 2023
de107ef
Fix location description and use EOF for descriptions with mutli lines
sebastianczech Oct 27, 2023
b1778b4
Add nullable=false, update descriptions
sebastianczech Oct 30, 2023
cb8f75a
Replave avzone by zones
sebastianczech Oct 30, 2023
238ebf9
Replace checking if null by coalesce() function
sebastianczech Oct 30, 2023
a141cbf
Move tags at the end of the resources
sebastianczech Oct 30, 2023
25d11b7
Move public IP on top
sebastianczech Oct 30, 2023
b63b16d
Improve description, lengths of the lines and coalesce in main.tf
sebastianczech Oct 30, 2023
6c3045f
Merge branch '307-refactor-modules' into 333-virtual_network_gateway
sebastianczech Oct 30, 2023
5a2afe2
Update README
sebastianczech Oct 30, 2023
85471a4
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Oct 30, 2023
e0f9cc3
Change ip_configuration and add validations for name
sebastianczech Oct 30, 2023
3158e49
Set public_ip_name as required
sebastianczech Oct 30, 2023
5df41f7
Added default type for address_space in local_network_gateways
sebastianczech Oct 30, 2023
86ce41c
Add default values for attributes in local_network_gateways
sebastianczech Oct 30, 2023
81da651
Extend validations
sebastianczech Oct 30, 2023
b963523
Split lines
sebastianczech Oct 30, 2023
7753f36
Add zones validation
sebastianczech Oct 30, 2023
7ed98dd
Fix local BGP settings
sebastianczech Oct 30, 2023
42d92e3
Add precondition for public IP
sebastianczech Oct 30, 2023
f802570
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Oct 30, 2023
037d0c4
Update example
sebastianczech Oct 30, 2023
c785507
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Oct 30, 2023
df4f155
Update descriptions about EOF, add nullable, remove coalesce if not r…
sebastianczech Oct 31, 2023
b8fc907
Define allocation method for public IP as Static and SKU Standard
sebastianczech Oct 31, 2023
fd88f82
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Oct 31, 2023
4571bab
Simplify code
sebastianczech Nov 3, 2023
57722c3
Merge branch '307-refactor-modules' into 333-virtual_network_gateway
sebastianczech Nov 3, 2023
39ca27d
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Nov 3, 2023
666c203
Fix line wrapping
sebastianczech Nov 3, 2023
f5a43d1
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Nov 3, 2023
55555ea
Add link to Terraform registry
sebastianczech Nov 3, 2023
e28d54b
Fix variables descriptions and validations according to review
sebastianczech Nov 7, 2023
86eea2b
Fix variables descriptions and validations according to review
sebastianczech Nov 7, 2023
9dc0a80
Fix variables descriptions and validations according to review
sebastianczech Nov 7, 2023
0eb9da3
Update README
sebastianczech Nov 7, 2023
808a3a7
Change default values
sebastianczech Nov 7, 2023
e93360b
Change default values
sebastianczech Nov 7, 2023
d75c01e
Change default values
sebastianczech Nov 7, 2023
fce9469
Remove default backend in rules
sebastianczech Nov 7, 2023
4493bb4
Rebuild capacity configuration for static and autoscaling
sebastianczech Nov 7, 2023
b03355c
Define global SSL settings, instead of 4 variables
sebastianczech Nov 7, 2023
a51fa63
Update README
sebastianczech Nov 7, 2023
556a1ac
Update examples
sebastianczech Nov 7, 2023
4398de1
Merge branch '307-refactor-modules' into 333-virtual_network_gateway
sebastianczech Nov 7, 2023
7e854d7
Merge branch '333-virtual_network_gateway' into 325-appgw
sebastianczech Nov 7, 2023
dc8b668
Merge branch '307-refactor-modules' into 325-appgw
sebastianczech Nov 7, 2023
d5bf5e3
Update README for examples
sebastianczech Nov 7, 2023
6e9362f
Merge branch '307-refactor-modules' into 325-appgw
sebastianczech Nov 17, 2023
f9c1b6f
Add WAF support for APP GW
sebastianczech Nov 21, 2023
df1b919
Add validation and documentation
sebastianczech Nov 22, 2023
0178500
Remove advanced WAF configuration, leave basic settings and SKU
sebastianczech Nov 22, 2023
a282c0b
Adjust all examples to changes in WAF
sebastianczech Nov 22, 2023
02926d2
Update modules/appgw/.header.md
sebastianczech Dec 6, 2023
efdcbaa
Update modules/appgw/main.tf
sebastianczech Dec 6, 2023
4bbb29a
Update modules/appgw/variables.tf
sebastianczech Dec 6, 2023
586e7fd
Update modules/appgw/variables.tf
sebastianczech Dec 6, 2023
24c0d3b
Update README
sebastianczech Dec 6, 2023
91cc21a
Add support for existing public IP
sebastianczech Dec 6, 2023
fb493ee
Validate rule - Either , or is required
sebastianczech Dec 6, 2023
f2d2cb5
Line wrapping at 130 column
sebastianczech Dec 6, 2023
d049195
Simplify WAF object definition
sebastianczech Dec 7, 2023
e526846
Define prevention mode (instead of firewall mode) for WAF
sebastianczech Dec 7, 2023
4a3cc67
Update README
sebastianczech Dec 7, 2023
04316a7
Adjust examples with changes in Application Gateway
sebastianczech Dec 7, 2023
ff80929
Fix backend description
sebastianczech Dec 7, 2023
249642e
Lifecycle precondition to check if there is host for probe or host na…
sebastianczech Dec 7, 2023
e78e0d9
In precondition validate additionally if pick host name from backend …
sebastianczech Dec 8, 2023
5148133
Update README about rules
sebastianczech Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ terraform.tfvars.json
*.tfplan
# **/
*bootstrap.xml

examples/appgw/files/*
6 changes: 3 additions & 3 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ content: |-
{{ range .Module.Inputs }}
{{ if .Required -}}
#### {{ .Name }}

{{ .Description }}

Type: {{ if lt (len (split "\n" .Type.Raw)) 2 }}{{ .Type }}{{ else }}

```hcl
{{ .Type }}
```
{{ end }}

<sup>[back to list](#modules-required-inputs)</sup>
{{ end }}
{{- end }}
Expand Down
5 changes: 5 additions & 0 deletions examples/appgw/.header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# APP GW module sample

A sample of using a APP GW module with the new variables layout and usage of `optional` keyword.

The `README` is also in new, document-style format.
358 changes: 358 additions & 0 deletions examples/appgw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
<!-- BEGIN_TF_DOCS -->
# APP GW module sample

A sample of using a APP GW module with the new variables layout and usage of `optional` keyword.

The `README` is also in new, document-style format.

## Module's Required Inputs

Name | Type | Description
--- | --- | ---
[`location`](#location) | `string` | The Azure region to use.
[`resource_group_name`](#resource_group_name) | `string` | Name of the Resource Group.
[`vnets`](#vnets) | `map` | A map defining VNETs.
[`appgws`](#appgws) | `map` | A map defining all Application Gateways in the current deployment.


## Module's Optional Inputs

Name | Type | Description
--- | --- | ---
[`tags`](#tags) | `map` | Map of tags to assign to the created resources.
[`name_prefix`](#name_prefix) | `string` | A prefix that will be added to all created resources.
[`create_resource_group`](#create_resource_group) | `bool` | When set to `true` it will cause a Resource Group creation.




## Module's Nameplate


Requirements needed by this module:

- `terraform`, version: >= 1.2, < 2.0


Providers used in this module:

- `azurerm`


Modules used in this module:
Name | Version | Source | Description
--- | --- | --- | ---
`vnet` | - | ../../modules/vnet | Manage the network required for the topology.
`appgw` | - | ../../modules/appgw | Create Application Gateay


Resources used in this module:

- `resource_group` (managed)
- `resource_group` (data)

## Inputs/Outpus details

### Required Inputs



#### location

The Azure region to use.

Type: string

<sup>[back to list](#modules-required-inputs)</sup>



#### resource_group_name

Name of the Resource Group.

Type: string

<sup>[back to list](#modules-required-inputs)</sup>

#### vnets

A map defining VNETs.

For detailed documentation on each property refer to [module documentation](../../modules/vnet/README.md)

- `create_virtual_network` - (`bool`, optional, defaults to `false`) when set to `true` will create a VNET, `false` will source an existing VNET.
- `name` - (`string`, required) a name of a VNET. In case `create_virtual_network = false` this should be a full resource name, including prefixes.
- `address_space` - (`list(string)`, required when `create_virtual_network = false`) a list of CIDRs for a newly created VNET
- `resource_group_name` - (`string`, optional, defaults to current RG) a name of an existing Resource Group in which the VNET will reside or is sourced from

- `create_subnets` - (`bool`, optinoal, defaults to `true`) if `true`, create Subnets inside the Virtual Network, otherwise use source existing subnets
- `subnets` - (`map`, optional) map of Subnets to create or source, for details see [VNET module documentation](../../modules/vnet/README.md#subnets)

- `network_security_groups` - (`map`, optional) map of Network Security Groups to create, for details see [VNET module documentation](../../modules/vnet/README.md#network_security_groups)
- `route_tables` - (`map`, optional) map of Route Tables to create, for details see [VNET module documentation](../../modules/vnet/README.md#route_tables)


Type:

```hcl
map(object({
name = string
create_virtual_network = optional(bool, true)
address_space = optional(list(string), [])
resource_group_name = optional(string)
network_security_groups = optional(map(object({
name = string
location = optional(string)
rules = optional(map(object({
name = string
priority = number
direction = string
access = string
protocol = string
source_port_range = optional(string)
source_port_ranges = optional(list(string))
destination_port_range = optional(string)
destination_port_ranges = optional(list(string))
source_address_prefix = optional(string)
source_address_prefixes = optional(list(string))
destination_address_prefix = optional(string)
destination_address_prefixes = optional(list(string))
})), {})
})), {})
route_tables = optional(map(object({
name = string
location = optional(string)
routes = map(object({
name = string
address_prefix = string
next_hop_type = string
next_hop_in_ip_address = optional(string)
}))
})), {})
create_subnets = optional(bool, true)
subnets = optional(map(object({
name = string
address_prefixes = optional(list(string), [])
network_security_group_key = optional(string)
route_table_key = optional(string)
enable_storage_service_endpoint = optional(bool, false)
})), {})
}))
```


<sup>[back to list](#modules-required-inputs)</sup>

#### appgws

A map defining all Application Gateways in the current deployment.

For detailed documentation on how to configure this resource, for available properties, especially for the defaults, refer to [module documentation](../../modules/appgw/README.md).

Following properties are supported:
- `name` - (`string`, required) name of the Application Gateway.
- `public_ip_name` - (`string`, required) name for the public IP address.
- `vnet_key` - (`string`, required) a key of a VNET defined in the `var.vnets` map.
- `subnet_key` - (`string`, required) a key of a subnet as defined in `var.vnets`. This has to be a subnet dedicated to Application Gateways v2.
- `managed_identities` - (`list`, optional) a list of existing User-Assigned Managed Identities, which Application Gateway uses to retrieve certificates from Key Vault.
- `capacity` - (`number`, object) capacity configuration for Application Gateway (refer to [module documentation](../../modules/appgw/README.md) for details)
- `waf` - (`object`, required) WAF basic configuration, defining WAF rules is not supported
- `enable_http2` - (`bool`, optional) enable HTTP2 support on the Application Gateway
- `zones` - (`list`, required) for zonal deployment this is a list of all zones in a region - this property is used by both: the Application Gateway and the Public IP created in front of the AppGW.
- `frontend_ip_configuration_name` - (`string`, optional) frontend IP configuration name
- `vmseries_public_nic_name` - (`string`, optional) VM-Series NIC name, for which IP address will be used in backend pool
- `listeners` - (`map`, required) map of listeners (refer to [module documentation](../../modules/appgw/README.md) for details)
- `backend_pool` - (`object`, optional) backend pool (refer to [module documentation](../../modules/appgw/README.md) for details)
- `backends` - (`map`, optional) map of backends (refer to [module documentation](../../modules/appgw/README.md) for details)
- `probes` - (`map`, optional) map of probes (refer to [module documentation](../../modules/appgw/README.md) for details)
- `rewrites` - (`map`, optional) map of rewrites (refer to [module documentation](../../modules/appgw/README.md) for details)
- `rules` - (`map`, required) map of rules (refer to [module documentation](../../modules/appgw/README.md) for details)
- `redirects` - (`map`, optional) map of redirects (refer to [module documentation](../../modules/appgw/README.md) for details)
- `url_path_maps` - (`map`, optional) map of URL path maps (refer to [module documentation](../../modules/appgw/README.md) for details)
- `ssl_policy_type` - (`string`, optional) type of an SSL policy, defaults to `Predefined`
- `ssl_policy_name` - (`string`, optional) name of an SSL policy, for `ssl_policy_type` set to `Predefined`
- `ssl_policy_min_protocol_version` - (`string`, optional) minimum version of the TLS protocol for SSL Policy, for `ssl_policy_type` set to `Custom`
- `ssl_policy_cipher_suites` - (`list`, optional) a list of accepted cipher suites, for `ssl_policy_type` set to `Custom`
- `ssl_profiles` - (`map`, optional) a map of SSL profiles that can be later on referenced in HTTPS listeners by providing a name of the profile in the `ssl_profile_name` property


Type:

```hcl
map(object({
name = string
public_ip_name = string
vnet_key = string
subnet_key = string
managed_identities = optional(list(string))
capacity = object({
static = optional(number)
autoscale = optional(object({
min = optional(number)
max = optional(number)
}))
})
waf = optional(object({
enabled = bool
firewall_mode = optional(string)
rule_set_type = optional(string, "OWASP")
rule_set_version = optional(string)
}))
enable_http2 = optional(bool)
zones = list(string)
frontend_ip_configuration_name = optional(string, "public_ipconfig")
vmseries_public_nic_name = optional(string, "public")
listeners = map(object({
name = string
port = number
protocol = optional(string, "Http")
host_names = optional(list(string))
ssl_profile_name = optional(string)
ssl_certificate_path = optional(string)
ssl_certificate_pass = optional(string)
ssl_certificate_vault_id = optional(string)
custom_error_pages = optional(map(string), {})
}))
backend_pool = optional(object({
name = string
vmseries_ips = optional(list(string), [])
}))
backends = optional(map(object({
name = string
path = optional(string)
hostname_from_backend = optional(string)
hostname = optional(string)
port = optional(number, 80)
protocol = optional(string, "Http")
timeout = optional(number, 60)
cookie_based_affinity = optional(string, "Enabled")
affinity_cookie_name = optional(string)
probe = optional(string)
root_certs = optional(map(object({
name = string
path = string
})), {})
})))
probes = optional(map(object({
name = string
path = string
host = optional(string)
port = optional(number)
protocol = optional(string, "Http")
interval = optional(number, 5)
timeout = optional(number, 30)
threshold = optional(number, 2)
match_code = optional(list(number))
match_body = optional(string)
})), {})
rewrites = optional(map(object({
name = optional(string)
rules = optional(map(object({
name = string
sequence = number
conditions = optional(map(object({
pattern = string
ignore_case = optional(bool, false)
negate = optional(bool, false)
})), {})
request_headers = optional(map(string), {})
response_headers = optional(map(string), {})
})))
})), {})
rules = map(object({
name = string
priority = number
backend = optional(string)
listener = string
rewrite = optional(string)
url_path_map = optional(string)
redirect = optional(string)
}))
redirects = optional(map(object({
name = string
type = string
target_listener = optional(string)
target_url = optional(string)
include_path = optional(bool, false)
include_query_string = optional(bool, false)
})), {})
url_path_maps = optional(map(object({
name = string
backend = string
path_rules = optional(map(object({
paths = list(string)
backend = optional(string)
redirect = optional(string)
})))
})), {})
ssl_global = optional(object({
ssl_policy_type = string
ssl_policy_name = optional(string)
ssl_policy_min_protocol_version = optional(string)
ssl_policy_cipher_suites = optional(list(string))
}))
ssl_profiles = optional(map(object({
name = string
ssl_policy_name = optional(string)
ssl_policy_min_protocol_version = optional(string)
ssl_policy_cipher_suites = optional(list(string))
})), {})
}))
```


<sup>[back to list](#modules-required-inputs)</sup>



### Optional Inputs


#### tags

Map of tags to assign to the created resources.

Type: map(string)

Default value: `map[]`

<sup>[back to list](#modules-optional-inputs)</sup>


#### name_prefix

A prefix that will be added to all created resources.
There is no default delimiter applied between the prefix and the resource name. Please include the delimiter in the actual prefix.

Example:
```hcl
name_prefix = "test-"
```

NOTICE. This prefix is not applied to existing resources. If you plan to reuse i.e. a VNET please specify it's full name, even if it is also prefixed with the same value as the one in this property.


Type: string

Default value: ``

<sup>[back to list](#modules-optional-inputs)</sup>

#### create_resource_group

When set to `true` it will cause a Resource Group creation. Name of the newly specified RG is controlled by `resource_group_name`.
When set to `false` the `resource_group_name` parameter is used to specify a name of an existing Resource Group.


Type: bool

Default value: `true`

<sup>[back to list](#modules-optional-inputs)</sup>





<!-- END_TF_DOCS -->
Loading