From bb3aec668eef6d834ca4ff082590f531c6ef3a33 Mon Sep 17 00:00:00 2001 From: mahesh yadav Date: Wed, 26 Jul 2023 17:02:29 +0530 Subject: [PATCH] fix: update source version and readme.yml file and dependabot.yml file --- .github/dependabot.yml | 12 +----- .github/workflows/tf-checks.yml | 2 +- README.yaml | 4 +- _examples/basic/outputs.tf | 3 ++ _examples/complete/example.tf | 6 ++- _examples/complete/outputs.tf | 3 ++ .../example.tf | 0 _examples/database-firewall/outputs.tf | 7 ++++ .../versions.tf | 0 _examples/database_firewall/outputs.tf | 4 -- main.tf | 37 +++++++------------ outputs.tf | 10 ++--- variables.tf | 28 +++++++++++++- 13 files changed, 64 insertions(+), 52 deletions(-) rename _examples/{database_firewall => database-firewall}/example.tf (100%) create mode 100644 _examples/database-firewall/outputs.tf rename _examples/{database_firewall => database-firewall}/versions.tf (100%) delete mode 100644 _examples/database_firewall/outputs.tf diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7ad4f1e..690585b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,16 +5,6 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - open-pull-requests-limit: 3 - assignees: - - "clouddrove-ci" - reviewers: - - "approvers" - - package-ecosystem: "github-actions" directory: "/" schedule: @@ -65,7 +55,7 @@ updates: open-pull-requests-limit: 3 - package-ecosystem: "terraform" # See documentation for possible values - directory: "/_examples/database_firewall" # Location of package manifests + directory: "/_examples/database-firewall" # Location of package manifests schedule: interval: "weekly" # Add assignees diff --git a/.github/workflows/tf-checks.yml b/.github/workflows/tf-checks.yml index dbfbb19..d975317 100644 --- a/.github/workflows/tf-checks.yml +++ b/.github/workflows/tf-checks.yml @@ -18,4 +18,4 @@ jobs: tf-database-firewall-example: uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master with: - working_directory: './_examples/database_firewall/' \ No newline at end of file + working_directory: './_examples/database-firewall/' \ No newline at end of file diff --git a/README.yaml b/README.yaml index 57eefec..d7f9021 100644 --- a/README.yaml +++ b/README.yaml @@ -37,7 +37,7 @@ usage : |- ```hcl module "firewall" { source = "terraform-do-modules/firewall/digitalocean" - version = "0.15.0" + version = "1.0.0" name = "app" environment = "test" allowed_ip = ["0.0.0.0/0"] @@ -53,7 +53,7 @@ usage : |- ```hcl module "firewall" { source = "terraform-do-modules/firewall/digitalocean" - version = "0.15.0" + version = "1.0.0" name = local.name environment = local.environment database_firewall_enabled = true diff --git a/_examples/basic/outputs.tf b/_examples/basic/outputs.tf index fac0534..244f77f 100644 --- a/_examples/basic/outputs.tf +++ b/_examples/basic/outputs.tf @@ -1,3 +1,6 @@ +# ------------------------------------------------------------------------------ +# Outputs +# ------------------------------------------------------------------------------ output "name" { value = module.firewall[*].name description = "The name of the Firewall." diff --git a/_examples/complete/example.tf b/_examples/complete/example.tf index 3cbedd0..c838f58 100644 --- a/_examples/complete/example.tf +++ b/_examples/complete/example.tf @@ -10,7 +10,8 @@ locals { ## VPC module call ##------------------------------------------------ module "vpc" { - source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-vpc.git?ref=internal-423" + source = "terraform-do-modules/vpc/digitalocean" + version = "1.0.0" name = local.name environment = local.environment region = local.region @@ -21,7 +22,8 @@ module "vpc" { ## Droplet module call ##------------------------------------------------ module "droplet" { - source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-droplet.git?ref=internal-425" + source = "terraform-do-modules/droplet/digitalocean" + version = "1.0.0" name = local.name environment = local.environment region = local.region diff --git a/_examples/complete/outputs.tf b/_examples/complete/outputs.tf index fac0534..244f77f 100644 --- a/_examples/complete/outputs.tf +++ b/_examples/complete/outputs.tf @@ -1,3 +1,6 @@ +# ------------------------------------------------------------------------------ +# Outputs +# ------------------------------------------------------------------------------ output "name" { value = module.firewall[*].name description = "The name of the Firewall." diff --git a/_examples/database_firewall/example.tf b/_examples/database-firewall/example.tf similarity index 100% rename from _examples/database_firewall/example.tf rename to _examples/database-firewall/example.tf diff --git a/_examples/database-firewall/outputs.tf b/_examples/database-firewall/outputs.tf new file mode 100644 index 0000000..4c3e6a4 --- /dev/null +++ b/_examples/database-firewall/outputs.tf @@ -0,0 +1,7 @@ +# ------------------------------------------------------------------------------ +# Outputs +# ------------------------------------------------------------------------------ +output "uuid" { + value = module.firewall[*].database_uuid + description = "A unique identifier for the firewall rule." +} diff --git a/_examples/database_firewall/versions.tf b/_examples/database-firewall/versions.tf similarity index 100% rename from _examples/database_firewall/versions.tf rename to _examples/database-firewall/versions.tf diff --git a/_examples/database_firewall/outputs.tf b/_examples/database_firewall/outputs.tf deleted file mode 100644 index 68d95e0..0000000 --- a/_examples/database_firewall/outputs.tf +++ /dev/null @@ -1,4 +0,0 @@ -output "uuid" { - value = module.firewall[*].database_uuid - description = "A unique identifier for the firewall rule." -} diff --git a/main.tf b/main.tf index 3663190..970a7c2 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,8 @@ ## Labels module callled that will be used for naming and tags. ##----------------------------------------------------------------------------- module "labels" { - source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-labels.git?ref=internal-426m" + source = "terraform-do-modules/labels/digitalocean" + version = "1.0.0" name = var.name environment = var.environment managedby = var.managedby @@ -32,25 +33,17 @@ resource "digitalocean_firewall" "default" { source_tags = var.tags } } - - outbound_rule { - protocol = "tcp" - port_range = "1-65535" - destination_addresses = ["0.0.0.0/0", "::/0"] - destination_droplet_ids = var.droplet_ids - destination_kubernetes_ids = var.kubernetes_ids - destination_load_balancer_uids = var.load_balancer_uids - destination_tags = var.tags - } - - outbound_rule { - protocol = "udp" - port_range = "1-65535" - destination_addresses = ["0.0.0.0/0", "::/0"] - destination_droplet_ids = var.droplet_ids - destination_kubernetes_ids = var.kubernetes_ids - destination_load_balancer_uids = var.load_balancer_uids - destination_tags = var.tags + dynamic "outbound_rule" { + for_each = var.outbound_rule + content { + protocol = outbound_rule.value.protocol + port_range = outbound_rule.value.port_range + destination_addresses = outbound_rule.value.destination_addresses + destination_droplet_ids = var.droplet_ids + destination_kubernetes_ids = var.kubernetes_ids + destination_load_balancer_uids = var.load_balancer_uids + destination_tags = var.tags + } } tags = [ @@ -64,10 +57,8 @@ resource "digitalocean_firewall" "default" { #Description : Provides a DigitalOcean database firewall resource allowing you to restrict connections to your database to trusted sources. ##------------------------------------------------------------------------------------------------------------------------------------------ resource "digitalocean_database_firewall" "default" { - count = var.enabled == true && var.database_cluster_id != null ? 1 : 0 - + count = var.enabled == true && var.database_cluster_id != null ? 1 : 0 cluster_id = var.database_cluster_id - dynamic "rule" { for_each = var.rules content { diff --git a/outputs.tf b/outputs.tf index fa5919c..ed45d56 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,30 +1,26 @@ -#Module : Firewall -#Description : Provides a DigitalOcean Cloud Firewall resource. This can be used to create, modify, and delete Firewalls. +# ------------------------------------------------------------------------------ +# Outputs +# ------------------------------------------------------------------------------ output "id" { value = digitalocean_firewall.default[*].id description = "A unique ID that can be used to identify and reference a Firewall." } - output "name" { value = digitalocean_firewall.default[*].name description = "The name of the Firewall." } - output "droplet_ids" { value = digitalocean_firewall.default[*].droplet_ids description = "The list of the IDs of the Droplets assigned to the Firewall." } - output "inbound_rule" { value = digitalocean_firewall.default[*].inbound_rule description = "The inbound access rule block for the Firewall." } - output "outbound_rule" { value = digitalocean_firewall.default[*].outbound_rule description = "The name of the Firewall." } - output "database_uuid" { value = digitalocean_database_firewall.default[*].id description = "A unique identifier for the firewall rule." diff --git a/variables.tf b/variables.tf index 8a68e4b..e745229 100644 --- a/variables.tf +++ b/variables.tf @@ -6,7 +6,6 @@ variable "name" { description = "Name (e.g. `app` or `cluster`)." } - variable "environment" { type = string default = "" @@ -31,7 +30,6 @@ variable "enabled" { description = "Flag to control the firewall creation." } - variable "allowed_ip" { type = list(any) default = [] @@ -84,4 +82,30 @@ variable "rules" { type = any default = [] description = "List of objects that represent the configuration of each inbound rule." +} + +variable "outbound_rule" { + type = list(object({ + protocol = string + port_range = string + destination_addresses = list(string) + })) + default = [ + { + protocol = "tcp" + port_range = "1-65535" + destination_addresses = [ + "0.0.0.0/0", + "::/0"] + destination_droplet_ids = [] + }, + { + protocol = "udp" + port_range = "1-65535" + destination_addresses = [ + "0.0.0.0/0", + "::/0"] + } + ] + description = "List of objects that represent the configuration of each outbound rule." } \ No newline at end of file