Skip to content

Commit

Permalink
Revert changes to the compute-vm module
Browse files Browse the repository at this point in the history
  • Loading branch information
kunzese committed Nov 15, 2022
1 parent b4041d6 commit 23c5757
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 64 deletions.
16 changes: 8 additions & 8 deletions blueprints/networking/filtering-proxy-psc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ module "cos-squid" {
}

module "squid-vm" {
source = "../../../modules/compute-vm"
project_id = module.project.project_id
zone = "${var.region}-b"
name = "squid-vm"
instance_type = "e2-medium"
create_template = true
enable_google_logging = true
source = "../../../modules/compute-vm"
project_id = module.project.project_id
zone = "${var.region}-b"
name = "squid-vm"
instance_type = "e2-medium"
create_template = true
network_interfaces = [{
network = module.vpc.self_link
subnetwork = module.vpc.subnet_self_links["${var.region}/proxy"]
Expand All @@ -152,7 +151,8 @@ module "squid-vm" {
service_account = module.service-account-squid.email
service_account_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
metadata = {
user-data = module.cos-squid.cloud_config
user-data = module.cos-squid.cloud_config
google-logging-enabled = true
}
}

Expand Down
16 changes: 8 additions & 8 deletions blueprints/networking/nginx-reverse-proxy-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,12 @@ module "mig-proxy" {
}

module "proxy-vm" {
source = "../../../modules/compute-vm"
project_id = module.project.project_id
zone = format("%s-c", var.region)
name = "nginx-test-vm"
instance_type = "e2-standard-2"
tags = ["proxy-cluster"]
enable_google_logging = true
source = "../../../modules/compute-vm"
project_id = module.project.project_id
zone = format("%s-c", var.region)
name = "nginx-test-vm"
instance_type = "e2-standard-2"
tags = ["proxy-cluster"]
network_interfaces = [{
network = module.vpc.self_link
subnetwork = module.vpc.subnet_self_links[format("%s/%s", var.region, var.subnetwork)]
Expand All @@ -305,7 +304,8 @@ module "proxy-vm" {
}
create_template = true
metadata = {
user-data = !var.tls ? module.cos-nginx.0.cloud_config : module.cos-nginx-tls.0.cloud_config
user-data = !var.tls ? module.cos-nginx.0.cloud_config : module.cos-nginx-tls.0.cloud_config
google-logging-enabled = true
}
service_account = module.service-account-proxy.email
service_account_create = false
Expand Down
6 changes: 3 additions & 3 deletions modules/cloud-config-container/coredns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module "cos-coredns" {
# use it as metadata in a compute instance or template
module "vm-coredns" {
source = "./fabric/modules/compute-vm"
enable_google_logging = true
source = "./fabric/modules/compute-vm"
metadata = {
user-data = module.cos-coredns.cloud_config
user-data = module.cos-coredns.cloud_config
google-logging-enabled = true
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module "vm-cos" {
project_id = local.project_id
zone = local.zone
name = "cos-envoy-td"
enable_google_logging = true
network_interfaces = [{
network = local.vpc.self_link,
subnetwork = local.vpc.subnet_self_link,
Expand All @@ -32,7 +31,8 @@ module "vm-cos" {
tags = ["ssh", "http"]
metadata = {
user-data = module.cos-envoy-td.cloud_config
user-data = module.cos-envoy-td.cloud_config
google-logging-enabled = true
}
boot_disk = {
Expand Down
6 changes: 3 additions & 3 deletions modules/cloud-config-container/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ module "cos-mysql" {
# use it as metadata in a compute instance or template
module "vm-mysql" {
source = "./fabric/modules/compute-vm"
enable_google_logging = true
source = "./fabric/modules/compute-vm"
metadata = {
user-data = module.cos-mysql.cloud_config
user-data = module.cos-mysql.cloud_config
google-logging-enabled = true
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions modules/cloud-config-container/nginx-tls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module "vm-nginx-tls" {
project_id = local.project_id
zone = local.zone
name = "cos-nginx-tls"
enable_google_logging = true
network_interfaces = [{
network = local.vpc.self_link,
subnetwork = local.vpc.subnet_self_link,
Expand All @@ -32,7 +31,8 @@ module "vm-nginx-tls" {
}]
metadata = {
user-data = module.cos-nginx-tls.cloud_config
user-data = module.cos-nginx-tls.cloud_config
google-logging-enabled = true
}
boot_disk = {
Expand Down
6 changes: 3 additions & 3 deletions modules/cloud-config-container/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module "cos-nginx" {
# use it as metadata in a compute instance or template
module "vm-nginx" {
source = "./fabric/modules/compute-vm"
enable_google_logging = true
source = "./fabric/modules/compute-vm"
metadata = {
user-data = module.cos-nginx.cloud_config
user-data = module.cos-nginx.cloud_config
google-logging-enabled = true
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions modules/cloud-config-container/squid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ module "cos-squid" {
# use it as metadata in a compute instance or template
module "vm-squid" {
source = "./fabric/modules/compute-vm"
enable_google_logging = true
source = "./fabric/modules/compute-vm"
metadata = {
user-data = module.cos-squid.cloud_config
user-data = module.cos-squid.cloud_config
google-logging-enabled = true
}
}
```
Expand Down
41 changes: 20 additions & 21 deletions modules/compute-vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ module "instance-group" {

| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [name](variables.tf#L186) | Instance name. | <code>string</code> || |
| [network_interfaces](variables.tf#L191) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code title="list&#40;object&#40;&#123;&#10; nat &#61; optional&#40;bool, false&#41;&#10; network &#61; string&#10; subnetwork &#61; string&#10; addresses &#61; optional&#40;object&#40;&#123;&#10; internal &#61; string&#10; external &#61; string&#10; &#125;&#41;, null&#41;&#10; alias_ips &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10; nic_type &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">list&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> || |
| [project_id](variables.tf#L228) | Project id. | <code>string</code> || |
| [zone](variables.tf#L287) | Compute zone. | <code>string</code> || |
| [name](variables.tf#L180) | Instance name. | <code>string</code> || |
| [network_interfaces](variables.tf#L185) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code title="list&#40;object&#40;&#123;&#10; nat &#61; optional&#40;bool, false&#41;&#10; network &#61; string&#10; subnetwork &#61; string&#10; addresses &#61; optional&#40;object&#40;&#123;&#10; internal &#61; string&#10; external &#61; string&#10; &#125;&#41;, null&#41;&#10; alias_ips &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10; nic_type &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">list&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> || |
| [project_id](variables.tf#L222) | Project id. | <code>string</code> || |
| [zone](variables.tf#L281) | Compute zone. | <code>string</code> || |
| [attached_disk_defaults](variables.tf#L17) | Defaults for attached disks options. | <code title="object&#40;&#123;&#10; auto_delete &#61; optional&#40;bool, false&#41;&#10; mode &#61; string&#10; replica_zone &#61; string&#10; type &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; auto_delete &#61; true&#10; mode &#61; &#34;READ_WRITE&#34;&#10; replica_zone &#61; null&#10; type &#61; &#34;pd-balanced&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [attached_disks](variables.tf#L38) | Additional disks, if options is null defaults will be used in its place. Source type is one of 'image' (zonal disks in vms and template), 'snapshot' (vm), 'existing', and null. | <code title="list&#40;object&#40;&#123;&#10; name &#61; string&#10; size &#61; string&#10; source &#61; optional&#40;string&#41;&#10; source_type &#61; optional&#40;string&#41;&#10; options &#61; optional&#40;&#10; object&#40;&#123;&#10; auto_delete &#61; optional&#40;bool, false&#41;&#10; mode &#61; optional&#40;string, &#34;READ_WRITE&#34;&#41;&#10; replica_zone &#61; optional&#40;string&#41;&#10; type &#61; optional&#40;string, &#34;pd-balanced&#34;&#41;&#10; &#125;&#41;,&#10; &#123;&#10; auto_delete &#61; true&#10; mode &#61; &#34;READ_WRITE&#34;&#10; replica_zone &#61; null&#10; type &#61; &#34;pd-balanced&#34;&#10; &#125;&#10; &#41;&#10;&#125;&#41;&#41;">list&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#91;&#93;</code> |
| [boot_disk](variables.tf#L81) | Boot disk properties. | <code title="object&#40;&#123;&#10; auto_delete &#61; optional&#40;bool, true&#41;&#10; image &#61; optional&#40;string, &#34;projects&#47;debian-cloud&#47;global&#47;images&#47;family&#47;debian-11&#34;&#41;&#10; size &#61; optional&#40;number, 10&#41;&#10; type &#61; optional&#40;string, &#34;pd-balanced&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; auto_delete &#61; true&#10; image &#61; &#34;projects&#47;debian-cloud&#47;global&#47;images&#47;family&#47;debian-11&#34;&#10; type &#61; &#34;pd-balanced&#34;&#10; size &#61; 10&#10;&#125;">&#123;&#8230;&#125;</code> |
Expand All @@ -290,23 +290,22 @@ module "instance-group" {
| [create_template](variables.tf#L109) | Create instance template instead of instances. | <code>bool</code> | | <code>false</code> |
| [description](variables.tf#L114) | Description of a Compute Instance. | <code>string</code> | | <code>&#34;Managed by the compute-vm Terraform module.&#34;</code> |
| [enable_display](variables.tf#L120) | Enable virtual display on the instances. | <code>bool</code> | | <code>false</code> |
| [enable_google_logging](variables.tf#L126) | Enable the logging agent included with the Container-Optimized OS. | <code>bool</code> | | <code>false</code> |
| [encryption](variables.tf#L132) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code title="object&#40;&#123;&#10; encrypt_boot &#61; optional&#40;bool, false&#41;&#10; disk_encryption_key_raw &#61; optional&#40;string&#41;&#10; kms_key_self_link &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [group](variables.tf#L142) | Define this variable to create an instance group for instances. Disabled for template use. | <code title="object&#40;&#123;&#10; named_ports &#61; map&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [hostname](variables.tf#L150) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
| [iam](variables.tf#L156) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [instance_type](variables.tf#L162) | Instance type. | <code>string</code> | | <code>&#34;f1-micro&#34;</code> |
| [labels](variables.tf#L168) | Instance labels. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [metadata](variables.tf#L174) | Instance metadata. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [min_cpu_platform](variables.tf#L180) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
| [options](variables.tf#L206) | Instance options. | <code title="object&#40;&#123;&#10; allow_stopping_for_update &#61; optional&#40;bool, true&#41;&#10; deletion_protection &#61; optional&#40;bool, false&#41;&#10; spot &#61; optional&#40;bool, false&#41;&#10; termination_action &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; allow_stopping_for_update &#61; true&#10; deletion_protection &#61; false&#10; spot &#61; false&#10; termination_action &#61; null&#10;&#125;">&#123;&#8230;&#125;</code> |
| [scratch_disks](variables.tf#L233) | Scratch disks configuration. | <code title="object&#40;&#123;&#10; count &#61; number&#10; interface &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; count &#61; 0&#10; interface &#61; &#34;NVME&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [service_account](variables.tf#L245) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L251) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [service_account_scopes](variables.tf#L259) | Scopes applied to service account. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [shielded_config](variables.tf#L265) | Shielded VM configuration of the instances. | <code title="object&#40;&#123;&#10; enable_secure_boot &#61; bool&#10; enable_vtpm &#61; bool&#10; enable_integrity_monitoring &#61; bool&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [tag_bindings](variables.tf#L275) | Tag bindings for this instance, in key => tag value id format. | <code>map&#40;string&#41;</code> | | <code>null</code> |
| [tags](variables.tf#L281) | Instance network tags for firewall rule targets. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [encryption](variables.tf#L126) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code title="object&#40;&#123;&#10; encrypt_boot &#61; optional&#40;bool, false&#41;&#10; disk_encryption_key_raw &#61; optional&#40;string&#41;&#10; kms_key_self_link &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [group](variables.tf#L136) | Define this variable to create an instance group for instances. Disabled for template use. | <code title="object&#40;&#123;&#10; named_ports &#61; map&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [hostname](variables.tf#L144) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
| [iam](variables.tf#L150) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [instance_type](variables.tf#L156) | Instance type. | <code>string</code> | | <code>&#34;f1-micro&#34;</code> |
| [labels](variables.tf#L162) | Instance labels. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [metadata](variables.tf#L168) | Instance metadata. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [min_cpu_platform](variables.tf#L174) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
| [options](variables.tf#L200) | Instance options. | <code title="object&#40;&#123;&#10; allow_stopping_for_update &#61; optional&#40;bool, true&#41;&#10; deletion_protection &#61; optional&#40;bool, false&#41;&#10; spot &#61; optional&#40;bool, false&#41;&#10; termination_action &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; allow_stopping_for_update &#61; true&#10; deletion_protection &#61; false&#10; spot &#61; false&#10; termination_action &#61; null&#10;&#125;">&#123;&#8230;&#125;</code> |
| [scratch_disks](variables.tf#L227) | Scratch disks configuration. | <code title="object&#40;&#123;&#10; count &#61; number&#10; interface &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; count &#61; 0&#10; interface &#61; &#34;NVME&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
| [service_account](variables.tf#L239) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L245) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [service_account_scopes](variables.tf#L253) | Scopes applied to service account. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
| [shielded_config](variables.tf#L259) | Shielded VM configuration of the instances. | <code title="object&#40;&#123;&#10; enable_secure_boot &#61; bool&#10; enable_vtpm &#61; bool&#10; enable_integrity_monitoring &#61; bool&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [tag_bindings](variables.tf#L269) | Tag bindings for this instance, in key => tag value id format. | <code>map&#40;string&#41;</code> | | <code>null</code> |
| [tags](variables.tf#L275) | Instance network tags for firewall rule targets. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |

## Outputs

Expand Down
7 changes: 2 additions & 5 deletions modules/compute-vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ locals {
)
)
termination_action = var.options.spot ? coalesce(var.options.termination_action, "STOP") : null
metadata = merge(var.metadata, var.enable_google_logging == true ? {
google-logging-enabled = true
} : null)
}

resource "google_compute_disk" "disks" {
Expand Down Expand Up @@ -135,7 +132,7 @@ resource "google_compute_instance" "default" {
deletion_protection = var.options.deletion_protection
enable_display = var.enable_display
labels = var.labels
metadata = local.metadata
metadata = var.metadata

dynamic "attached_disk" {
for_each = local.attached_disks_zonal
Expand Down Expand Up @@ -265,7 +262,7 @@ resource "google_compute_instance_template" "default" {
machine_type = var.instance_type
min_cpu_platform = var.min_cpu_platform
can_ip_forward = var.can_ip_forward
metadata = local.metadata
metadata = var.metadata
labels = var.labels

disk {
Expand Down
6 changes: 0 additions & 6 deletions modules/compute-vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ variable "enable_display" {
default = false
}

variable "enable_google_logging" {
description = "Enable the logging agent included with the Container-Optimized OS."
type = bool
default = false
}

variable "encryption" {
description = "Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk."
type = object({
Expand Down

0 comments on commit 23c5757

Please sign in to comment.