diff --git a/modules/tfc-agent-mig-container-vm/README.md b/modules/tfc-agent-mig-container-vm/README.md index b463a96..e13a409 100644 --- a/modules/tfc-agent-mig-container-vm/README.md +++ b/modules/tfc-agent-mig-container-vm/README.md @@ -23,12 +23,13 @@ This example shows how to deploy a self hosted Terraform Cloud agent on MIG Cont | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | additional\_metadata | Additional metadata to attach to the instance | `map(any)` | `{}` | no | +| autoscaling\_enabled | Set to true to enable autoscaling in the MIG | `bool` | `true` | no | | cooldown\_period | The number of seconds that the autoscaler should wait before it
starts collecting information from a new instance. | `number` | `60` | no | | create\_network | When set to true, VPC, router and NAT will be auto created | `bool` | `true` | no | | create\_service\_account | Set to true to create a new service account, false to use an existing one | `bool` | `true` | no | | dind | Flag to determine whether to expose dockersock | `bool` | `false` | no | | image | The Terraform Cloud agent image | `string` | `"hashicorp/tfc-agent:latest"` | no | -| network\_name | Name for the VPC network | `string` | `"tfc-agent-network"` | no | +| network\_name | Name for the VPC network. Only used if subnetwork\_project and subnet\_name are not specified | `string` | `"tfc-agent-network"` | no | | project\_id | The Google Cloud Platform project ID to deploy Terraform Cloud agent | `string` | n/a | yes | | region | The GCP region to use when deploying resources | `string` | `"us-central1"` | no | | restart\_policy | The desired Docker restart policy for the agent image | `string` | `"Always"` | no | diff --git a/modules/tfc-agent-mig-container-vm/main.tf b/modules/tfc-agent-mig-container-vm/main.tf index 29f8244..493c9b5 100644 --- a/modules/tfc-agent-mig-container-vm/main.tf +++ b/modules/tfc-agent-mig-container-vm/main.tf @@ -28,7 +28,7 @@ locals { path = "/var/run/docker.sock" } }] : [] - network_name = var.create_network ? google_compute_network.tfc_agent_network[0].self_link : var.network_name + network_name = var.create_network ? google_compute_network.tfc_agent_network[0].self_link : (var.subnet_name != "" ? null : var.network_name) subnet_name = var.create_network ? google_compute_subnetwork.tfc_agent_subnetwork[0].self_link : var.subnet_name service_account_email = var.create_service_account ? google_service_account.tfc_agent_service_account[0].email : var.service_account_email instance_name = "${var.tfc_agent_name_prefix}-${random_string.suffix.result}" @@ -203,6 +203,6 @@ module "mig" { instance_template = module.mig_template.self_link /* autoscaler */ - autoscaling_enabled = true + autoscaling_enabled = var.autoscaling_enabled cooldown_period = var.cooldown_period } diff --git a/modules/tfc-agent-mig-container-vm/variables.tf b/modules/tfc-agent-mig-container-vm/variables.tf index 3354971..7266084 100644 --- a/modules/tfc-agent-mig-container-vm/variables.tf +++ b/modules/tfc-agent-mig-container-vm/variables.tf @@ -33,7 +33,7 @@ variable "create_network" { variable "network_name" { type = string - description = "Name for the VPC network" + description = "Name for the VPC network. Only used if subnetwork_project and subnet_name are not specified" default = "tfc-agent-network" } @@ -76,6 +76,12 @@ variable "target_size" { default = 2 } +variable "autoscaling_enabled" { + description = "Set to true to enable autoscaling in the MIG" + type = bool + default = true +} + variable "create_service_account" { description = "Set to true to create a new service account, false to use an existing one" type = bool