Skip to content

Add support for disable default snat #2508

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 13 commits into from
Aug 21, 2024
2 changes: 1 addition & 1 deletion modules/gke-cluster-autopilot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ module "cluster-1" {
| [location](variables.tf#L113) | Autopilot clusters are always regional. | <code>string</code> | ✓ | |
| [name](variables.tf#L190) | Cluster name. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L226) | Cluster project ID. | <code>string</code> | ✓ | |
| [vpc_config](variables.tf#L242) | VPC-level configuration. | <code title="object&#40;&#123;&#10; network &#61; string&#10; subnetwork &#61; string&#10; master_ipv4_cidr_block &#61; optional&#40;string&#41;&#10; master_endpoint_subnetwork &#61; optional&#40;string&#41;&#10; secondary_range_blocks &#61; optional&#40;object&#40;&#123;&#10; pods &#61; string&#10; services &#61; string&#10; &#125;&#41;&#41;&#10; secondary_range_names &#61; optional&#40;object&#40;&#123;&#10; pods &#61; optional&#40;string&#41;&#10; services &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; additional_ranges &#61; optional&#40;list&#40;string&#41;&#41;&#10; master_authorized_ranges &#61; optional&#40;map&#40;string&#41;&#41;&#10; stack_type &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [vpc_config](variables.tf#L242) | VPC-level configuration. | <code title="object&#40;&#123;&#10; disable_default_snat &#61; optional&#40;bool&#41;&#10; network &#61; string&#10; subnetwork &#61; string&#10; master_ipv4_cidr_block &#61; optional&#40;string&#41;&#10; master_endpoint_subnetwork &#61; optional&#40;string&#41;&#10; secondary_range_blocks &#61; optional&#40;object&#40;&#123;&#10; pods &#61; string&#10; services &#61; string&#10; &#125;&#41;&#41;&#10; secondary_range_names &#61; optional&#40;object&#40;&#123;&#10; pods &#61; optional&#40;string&#41;&#10; services &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; additional_ranges &#61; optional&#40;list&#40;string&#41;&#41;&#10; master_authorized_ranges &#61; optional&#40;map&#40;string&#41;&#41;&#10; stack_type &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | <code title="object&#40;&#123;&#10; enable_backup_agent &#61; optional&#40;bool, false&#41;&#10; backup_plans &#61; optional&#40;map&#40;object&#40;&#123;&#10; encryption_key &#61; optional&#40;string&#41;&#10; include_secrets &#61; optional&#40;bool, true&#41;&#10; include_volume_data &#61; optional&#40;bool, true&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; namespaces &#61; optional&#40;list&#40;string&#41;&#41;&#10; region &#61; string&#10; schedule &#61; string&#10; retention_policy_days &#61; optional&#40;string&#41;&#10; retention_policy_lock &#61; optional&#40;bool, false&#41;&#10; retention_policy_delete_lock_days &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [deletion_protection](variables.tf#L38) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | <code>bool</code> | | <code>true</code> |
| [description](variables.tf#L45) | Cluster description. | <code>string</code> | | <code>null</code> |
Expand Down
7 changes: 7 additions & 0 deletions modules/gke-cluster-autopilot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ resource "google_container_cluster" "cluster" {
}
}

dynamic "default_snat_status" {
for_each = var.vpc_config.disable_default_snat == null ? [] : [""]
content {
disabled = var.vpc_config.disable_default_snat
}
}

dynamic "dns_config" {
for_each = var.enable_features.dns != null ? [""] : []
content {
Expand Down
1 change: 1 addition & 0 deletions modules/gke-cluster-autopilot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ variable "release_channel" {
variable "vpc_config" {
description = "VPC-level configuration."
type = object({
disable_default_snat = optional(bool)
network = string
subnetwork = string
master_ipv4_cidr_block = optional(string)
Expand Down
Loading