Skip to content

feat: fixed log config issue #7

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

Merged
merged 2 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions .github/workflows/tfchecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ on:
pull_request:
workflow_dispatch:
jobs:
tf-checks-example:
tf-checks-basic-example:
uses: clouddrove/github-shared-workflows/.github/workflows/[email protected]
with:
working_directory: './_example/'
working_directory: './example/basic'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folder name should be examples not and example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


tf-checks-complete-example:
uses: clouddrove/github-shared-workflows/.github/workflows/[email protected]
with:
working_directory: './example/complete'
30 changes: 20 additions & 10 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

# Name of this project
name : Terraform gcp subnet
name : Terraform GCP Subnet

# License of this project
license: "APACHE"
Expand All @@ -15,18 +15,28 @@ github_repo: clouddrove/terraform-gcp-subnet

# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v1.1.7-green"
url: "https://www.terraform.io"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"
- name: "Latest Release"
image: "https://img.shields.io/github/release/clouddrove/terraform-gcp-subnet.svg"
url: "https://github.com/clouddrove/terraform-gcp-subnet/releases/latest"
- name: "tfsec"
image: "https://github.com/clouddrove/terraform-gcp-subnet/actions/workflows/tfsec.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-gcp-subnet/actions/workflows/tfsec.yml"
- name: "static-checks"
image: "https://github.com/clouddrove/terraform-gcp-subnet/actions/workflows/terraform.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-gcp-subnet/actions/workflows/terraform.yml"
- name: "Licence"
image: "https://img.shields.io/badge/License-APACHE-blue.svg"
url: "LICENSE.md"
- name: "Changelog"
image: "https://img.shields.io/badge/Changelog-blue"
url: "CHANGELOG.md"

prerequesties:
- name: Terraform
url: https://learn.hashicorp.com/terraform/getting-started/install.html
version: ">= 1.4.6"

providers:
- name: gcp
url: https://cloud.google.com/
version: ">= 5.22.0"

# description of this project
description: |-
Expand Down
11 changes: 8 additions & 3 deletions _example/example.tf → example/basic/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ module "vpc" {
version = "1.0.0"

name = "vpc"
environment = "test"
environment = "test-1"
label_order = ["environment", "name"]
google_compute_network_enabled = true
}


module "subnet" {
source = "../"
source = "../../"

name = "dev"
environment = var.environment
Expand All @@ -31,7 +31,6 @@ module "subnet" {
network = module.vpc.vpc_id
project_id = "clouddrove"
private_ip_google_access = true
allow = [{ "protocol" : "tcp", "ports" : ["1-65535"] }]
source_ranges = ["10.10.0.0/16"]
asn = 64514
nat_ip_allocate_option = "MANUAL_ONLY"
Expand All @@ -51,4 +50,10 @@ module "subnet" {
"ip_cidr_range" : "10.3.0.0/16"
}
]
allow = [
{
"protocol" : "tcp",
"ports" : ["1-65535"]
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions example/complete/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
provider "google" {
project = var.gcp_project_id
region = var.gcp_region
zone = var.gcp_zone
}

module "vpc" {
source = "clouddrove/vpc/gcp"
version = "1.0.0"

name = "vpc"
environment = "test-1"
label_order = ["environment", "name"]
google_compute_network_enabled = true
}


module "subnet" {
source = "../../"

name = "dev"
environment = var.environment
label_order = var.label_order
gcp_region = "us-central1"

google_compute_subnetwork_enabled = true
google_compute_firewall_enabled = true
google_compute_router_nat_enabled = true
module_enabled = true
ipv6_access_type = "EXTERNAL"
network = module.vpc.vpc_id
project_id = "clouddrove"
private_ip_google_access = true
source_ranges = ["10.10.0.0/16"]
asn = 64514
nat_ip_allocate_option = "MANUAL_ONLY"
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
filter = "ERRORS_ONLY"
dest_range = "0.0.0.0/0"
next_hop_gateway = "default-internet-gateway"
priority = 1000
secondary_ip_ranges = [
{
"range_name" : "services",
"ip_cidr_range" : "10.1.0.0/16"
},

{
"range_name" : "pods",
"ip_cidr_range" : "10.3.0.0/16"
}
]
allow = [
{
"protocol" : "tcp",
"ports" : ["1-65535"]
}
]
log_config = {
aggregation_interval = "INTERVAL_15_MIN"
flow_sampling = 0
metadata = "EXCLUDE_ALL_METADATA"
}
}
4 changes: 4 additions & 0 deletions example/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
value = module.subnet[*].id
description = "The ID of the s3 bucket."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
29 changes: 29 additions & 0 deletions example/complete/varriables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "environment" {
type = string
default = "subnetwork"
description = "Environment name"
}

variable "label_order" {
type = list(any)
default = ["name", "environment"]
description = "Label order, e.g. `name`,`application`."
}

variable "gcp_project_id" {
type = string
default = "clouddrove"
description = "Google Cloud project ID"
}

variable "gcp_region" {
type = string
default = "europe-west3"
description = "Google Cloud region"
}

variable "gcp_zone" {
type = string
default = "Europe-west3-c"
description = "Google Cloud zone"
}
10 changes: 10 additions & 0 deletions example/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 0.14, < 2.0"

required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.50, < 5.0"
}
}
}
8 changes: 3 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ resource "google_compute_subnetwork" "subnetwork" {
for_each = var.log_config != null ? [var.log_config] : []

content {
aggregation_interval = try(log_config.value, "aggregation_interval", null)
flow_sampling = try(log_config.value, "flow_sampling", null)
metadata = try(log_config.value, "metadata", null)
metadata_fields = try(log_config.value, "metadata_fields", null)
filter_expr = try(log_config.value, "filter_expr", null)
aggregation_interval = log_config.value.aggregation_interval
flow_sampling = log_config.value.flow_sampling
metadata = log_config.value.metadata
}
}

Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ variable "secondary_ip_ranges" {
}

variable "log_config" {
type = any
default = true
description = "(Optional) Logging options for the subnetwork flow logs. Setting this value to 'null' will disable them. See https://www.terraform.io/docs/providers/google/r/compute_subnetwork.html for more information and examples."
type = map(any)
default = null
description = "VPC flow logging options for this subnetwork"
}

variable "google_compute_subnetwork_enabled" {
Expand Down
4 changes: 2 additions & 2 deletions version.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 1.6.6"
required_version = ">= 1.3"

required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.50, < 5.0"
version = ">= 4.64, < 6"
}
}
}