Skip to content

Commit

Permalink
fix: Shared VPC architecture deployment and make Autoscaling optional (
Browse files Browse the repository at this point in the history
  • Loading branch information
romancin authored Oct 26, 2023
1 parent 91ab019 commit 415b2fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion modules/tfc-agent-mig-container-vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>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 |
Expand Down
4 changes: 2 additions & 2 deletions modules/tfc-agent-mig-container-vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion modules/tfc-agent-mig-container-vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 415b2fc

Please sign in to comment.