-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
57 lines (47 loc) · 2.16 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
52
53
54
55
56
57
# ---------------------------------------------------------------------------------------------------------------------
# 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" {
count = var.module_enabled ? 1 : 0
project = var.project
network = var.network
region = var.region
name = var.name
description = var.description
ip_cidr_range = cidrsubnet(var.ip_cidr_range, 0, 0)
purpose = try(var.purpose, null)
role = try(var.role, null)
private_ip_google_access = var.private_ip_google_access
private_ipv6_google_access = try(var.private_ipv6_google_access, null)
stack_type = try(var.stack_type, null)
ipv6_access_type = try(var.ipv6_access_type, null)
external_ipv6_prefix = try(var.external_ipv6_prefix, null)
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]
}