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 9 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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" {
}
]
}

##############################################################################
# Add web application firewall to CIS instance
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
##############################################################################

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"
}
36 changes: 36 additions & 0 deletions modules/waf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# CIS web application firewall (WAF) module

This module enable/disable the web application firewall of the domain.
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) | Enable/disable 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 -->
9 changes: 9 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,9 @@
##############################################################################
# Enable Web Application Firewall for a domain
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
##############################################################################

resource "ibm_cis_domain_settings" "domain_settings" {
cis_id = var.cis_instance_id
domain_id = var.domain_id
waf = var.waf
}
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 = "Enable/disable a web application firewall (WAF). Supported values are off and on."
iamar7 marked this conversation as resolved.
Show resolved Hide resolved
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"
}
}
}