Skip to content

Commit

Permalink
fix: update count variable and fix description for ingress rule
Browse files Browse the repository at this point in the history
  • Loading branch information
themaheshyadav committed Jun 20, 2023
1 parent 42a4f97 commit e86f494
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
11 changes: 6 additions & 5 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ usage : |-
Here is an example of how you can use this module in your inventory structure:
```hcl
module "firewall" {
source = "terraform-do-modules/firewall/digitalocean"
version = "0.15.0"
name = local.name
environment = local.environment
database_cluster_id = ""
source = "terraform-do-modules/firewall/digitalocean"
version = "0.15.0"
name = local.name
environment = local.environment
database_firewall_enabled = true
database_cluster_id = ""
rules = [
{
type = "ip_addr"
Expand Down
17 changes: 9 additions & 8 deletions _examples/basic/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ locals {
## Firewall module call
##------------------------------------------------
module "firewall" {
source = "./../../"
name = local.name
environment = local.environment
allowed_ip = ["0.0.0.0/0"]
allowed_ports = [22, 80]
droplet_ids = [] #### Add droplet ids
kubernetes_ids = [] #### Add kubernetes ids
load_balancer_uids = [] #### Add load balancer uids
source = "./../../"
name = local.name
environment = local.environment
allowed_ip = ["0.0.0.0/0"]
allowed_ports = [22, 80]
## we can use all them need to pass value accordingly for droplet , kubernetes and load balancer.
// droplet_ids = []
// kubernetes_ids = []
// load_balancer_uids = []
}
9 changes: 5 additions & 4 deletions _examples/database_firewall/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ locals {
## database Firewall module call
##------------------------------------------------
module "firewall" {
source = "./../../"
name = local.name
environment = local.environment
database_cluster_id = "" ## add database cluster id
source = "./../../"
name = local.name
environment = local.environment
database_firewall_enabled = true
database_cluster_id = "" ## add database cluster id
rules = [
{
type = "ip_addr"
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module "labels" {
#Description : Provides a DigitalOcean Cloud Firewall resource. This can be used to create, modify, and delete Firewalls.
##-------------------------------------------------------------------------------------------------------------------------

#tfsec:ignore:digitalocean-compute-no-public-ingress ## because by default we use ["0.0.0.0/0"], do not use on prod env.
#tfsec:ignore:digitalocean-compute-no-public-egress ## The port is exposed for ingress from the internet, by default we use ["0.0.0.0/0", "::/0"].
#tfsec:ignore:digitalocean-compute-no-public-ingress ## The port is exposed for ingress from the internet, by default ["0.0.0.0/0", "::/0"] we use for http and https.
#tfsec:ignore:digitalocean-compute-no-public-egress ## because by default we use ["0.0.0.0/0"], do not use on prod env.
resource "digitalocean_firewall" "default" {
count = var.enabled == true ? 1 : 0
count = var.enabled == true && var.database_cluster_id == null ? 1 : 0
name = format("%s-firewall", module.labels.id)
droplet_ids = var.droplet_ids
dynamic "inbound_rule" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ variable "enabled" {
description = "Flag to control the firewall creation."
}

variable "database_firewall_enabled" {

Check warning on line 34 in variables.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

variable "database_firewall_enabled" is declared but not used
type = bool
default = false
description = "Flag to control the firewall creation."
}

variable "allowed_ip" {
type = list(any)
default = []
Expand Down

0 comments on commit e86f494

Please sign in to comment.