This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
forked from mineiros-io/terraform-google-subnetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
51 lines (41 loc) · 1.8 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# ---------------------------------------------------------------------------------------------------------------------
# Subnetwork Config
# The default gateway automatically configures public internet access for instances with addresses for 0.0.0.0/0
# External access is configured with Cloud NAT, which serves egress traffic for instances without external addresses
# ---------------------------------------------------------------------------------------------------------------------
resource "google_compute_subnetwork" "subnetwork" {
for_each = var.module_enabled ? 1 : 0
project = var.project
network = var.network
region = var.region
name = var.name
description = var.description
private_ip_google_access = var.private_ip_google_access
ip_cidr_range = cidrsubnet(var.ip_cidr_range, 0, 0)
dynamic "secondary_ip_range" {
for_each = var.secondary_ip_ranges
content {
range_name = secondary_ip_range.value.range_name
ip_cidr_range = secondary_ip_range.value.ip_cidr_range
}
}
dynamic "log_config" {
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)
}
}
dynamic "timeouts" {
for_each = try([var.module_timeouts.google_compute_subnetwork], [])
content {
create = try(timeouts.value.create, null)
update = try(timeouts.value.update, null)
delete = try(timeouts.value.delete, null)
}
}
depends_on = [var.module_depends_on]
}