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 web application firewall #410

Merged
merged 20 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This module provisions an IBM Cloud Internet Services (CIS) instance and configu
* Domain
* DNS records
* Global load balancer (GLB) including load balancers, origin pools and health checks
* Web Application Firewall (WAF)

For more information see, [Getting started with IBM Cloud Internet Services](https://cloud.ibm.com/docs/cis?topic=cis-getting-started).

Expand All @@ -22,6 +23,7 @@ For more information see, [Getting started with IBM Cloud Internet Services](htt
* [dns](./modules/dns)
* [domain](./modules/domain)
* [glb](./modules/glb)
* [waf](./modules/waf)
* [Examples](./examples)
* [End-to-end example](./examples/complete)
* [Contributing](#contributing)
Expand Down
11 changes: 11 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ module "cis_glb" {
}
]
}

##############################################################################
# Enables web application firewall(WAF) to CIS instance
##############################################################################

module "cis_domain_settings" {
source = "../../modules/waf"
cis_instance_id = module.cis_instance.cis_instance_id
domain_id = module.cis_instance.cis_domain.domain_id
waf = "on"
}
5 changes: 5 additions & 0 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ output "cis_glb" {
description = "CIS Global Load Balancer"
value = module.cis_glb
}

output "cis_domain_settings" {
description = "CIS domain settings"
value = module.cis_domain_settings
}
38 changes: 38 additions & 0 deletions modules/waf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CIS web application firewall (WAF) module

This module enables/disables the web application firewall (WAF) of the domain.

> When the `waf` is enabled then the `min_tls_version` is automatically modified to `1.1`.
iamar7 marked this conversation as resolved.
Show resolved Hide resolved

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.6.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.49.0 |

### Modules

No modules.

### Resources

| Name | Type |
|------|------|
| [ibm_cis_domain_settings.domain_settings](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cis_domain_settings) | resource |

### Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cis_instance_id"></a> [cis\_instance\_id](#input\_cis\_instance\_id) | CRN of the existing CIS instance. | `string` | n/a | yes |
| <a name="input_domain_id"></a> [domain\_id](#input\_domain\_id) | ID of the existing domain to add a DNS record to the CIS instance. | `string` | n/a | yes |
| <a name="input_waf"></a> [waf](#input\_waf) | Enables/disables a web application firewall (WAF). Supported values are off and on. | `string` | n/a | yes |

### Outputs

| Name | Description |
|------|-------------|
| <a name="output_cis_domain_settings_details"></a> [cis\_domain\_settings\_details](#output\_cis\_domain\_settings\_details) | CIS Domain settings details |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
10 changes: 10 additions & 0 deletions modules/waf/main.tf
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##############################################################################
# To enable/disable Web Application Firewall(WAF) for a domain
##############################################################################

resource "ibm_cis_domain_settings" "domain_settings" {
cis_id = var.cis_instance_id
domain_id = var.domain_id
waf = var.waf
min_tls_version = "1.2" # The min_tls_version default value was getting modified to 1.1 while terraform apply. Provider issue is open here: https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4937
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions modules/waf/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

output "cis_domain_settings_details" {
description = "CIS Domain settings details"
value = ibm_cis_domain_settings.domain_settings
}
19 changes: 19 additions & 0 deletions modules/waf/variables.tf
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

variable "cis_instance_id" {
type = string
description = "CRN of the existing CIS instance."
}

variable "domain_id" {
type = string
description = "ID of the existing domain to add a DNS record to the CIS instance."
}

variable "waf" {
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
type = string
description = "Enables/disables a web application firewall (WAF). Supported values are off and on."
validation {
condition = contains(["on", "off"], var.waf)
error_message = "Provided value of waf is not allowed. Supported values are off and on."
}
}
10 changes: 10 additions & 0 deletions modules/waf/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

terraform {
required_version = ">= 1.3.0, <1.6.0"
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.49.0"
}
}
}