diff --git a/Makefile b/Makefile index 01d12c4d..a307dfe1 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ docker_generate_docs: -e ENABLE_BPMETADATA \ -v "$(CURDIR)":/workspace \ $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ - /bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs' + /bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display' # Generate files from autogen .PHONY: docker_generate_modules diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index c5f470b8..2baf02d4 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -22,10 +22,9 @@ variable "project_id" { default = null } -variable "hostname" { - description = "Hostname prefix for instances" +variable "region" { + description = "The Google Cloud region where the managed instance group resides." type = string - default = "default" } variable "mig_name" { @@ -34,9 +33,16 @@ variable "mig_name" { default = "" } -variable "region" { - description = "The Google Cloud region where the managed instance group resides." +variable "hostname" { + description = "Hostname prefix for instances" type = string + default = "default" +} + +variable "target_size" { + description = "The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set." + type = number + default = 1 } {% if mig %} @@ -62,11 +68,6 @@ variable "next_version_percent" { } {% endif %} -variable "target_size" { - description = "The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set." - type = number - default = 1 -} variable "target_pools" { description = "The target load balancing pools to assign this group to." diff --git a/modules/instance_template/metadata.display.yaml b/modules/instance_template/metadata.display.yaml index 0811efe2..ffccf925 100644 --- a/modules/instance_template/metadata.display.yaml +++ b/modules/instance_template/metadata.display.yaml @@ -60,6 +60,7 @@ spec: description: name: description title: Description + invisible: false disk_encryption_key: name: disk_encryption_key title: Disk Encryption Key @@ -90,6 +91,7 @@ spec: instance_description: name: instance_description title: Instance Description + invisible: false ipv6_access_config: name: ipv6_access_config title: Ipv6 Access Config @@ -99,6 +101,7 @@ spec: machine_type: name: machine_type title: Machine Type + invisible: false maintenance_interval: name: maintenance_interval title: Maintenance Interval @@ -111,6 +114,9 @@ spec: name_prefix: name: name_prefix title: Name Prefix + invisible: false + regexValidation: ^[a-z][a-z0-9-]{0,51}[a-z0-9]$ + validation: Use lowercase letters, numbers, and hyphens. Start with a letter and end with letter/number. Must be 53 characters or fewer. network: name: network title: Network @@ -129,9 +135,11 @@ spec: project_id: name: project_id title: Project Id + invisible: false region: name: region title: Region + invisible: false resource_policies: name: resource_policies title: Resource Policies @@ -153,6 +161,7 @@ spec: spot: name: spot title: Spot + invisible: false spot_instance_termination_action: name: spot_instance_termination_action title: Spot Instance Termination Action @@ -177,4 +186,3 @@ spec: total_egress_bandwidth_tier: name: total_egress_bandwidth_tier title: Total Egress Bandwidth Tier - diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index c5bb6436..f2bd5acf 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -83,10 +83,21 @@ spec: - name: project_id description: The GCP project ID varType: string + - name: region + description: Region where the instance template should be created. + varType: string - name: name_prefix description: Name prefix for the instance template varType: string defaultValue: default-instance-template + - name: machine_type + description: Machine type to create, e.g. n1-standard-1 + varType: string + defaultValue: n1-standard-1 + - name: spot + description: Provision a SPOT instance + varType: bool + defaultValue: false - name: description description: The template's description varType: string @@ -95,10 +106,6 @@ spec: description: Description of the generated instances varType: string defaultValue: "" - - name: machine_type - description: Machine type to create, e.g. n1-standard-1 - varType: string - defaultValue: n1-standard-1 - name: min_cpu_platform description: "Specifies a minimum CPU platform. Applicable values are the friendly names of CPU platforms, such as Intel Haswell or Intel Skylake. See the complete list: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform" varType: string @@ -118,10 +125,6 @@ spec: description: Allow the instance to be preempted varType: bool defaultValue: false - - name: spot - description: Provision a SPOT instance - varType: bool - defaultValue: false - name: automatic_restart description: (Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). varType: bool @@ -137,9 +140,6 @@ spec: description: Action to take when Compute Engine preempts a Spot VM. varType: string defaultValue: STOP - - name: region - description: Region where the instance template should be created. - varType: string - name: enable_nested_virtualization description: Defines whether the instance should have nested virtualization enabled. varType: bool @@ -265,24 +265,24 @@ spec: connections: - source: source: github.com/terraform-google-modules/terraform-google-memorystore - version: ~> 10.0 + version: ~> 12.0 spec: - outputExpr: env_vars + outputExpr: "{\"REDIS_HOST\": host, \"REDIS_PORT\": port}" - source: - source: github.com/terraform-google-modules/terraform-google-sql-db//modules/postgresql - version: ~> 21.0 + source: github.com/q2w/terraform-google-sql-db//modules/postgresql + version: ~> 23.0 spec: - outputExpr: env_vars + outputExpr: "{\"CLOUD_SQL_DATABASE_HOST\" : instance_first_ip_address, \"CLOUD_SQL_DATABASE_CONNECTION_NAME\" : instance_connection_name, \"CLOUD_SQL_DATABASE_NAME\" : env_vars.CLOUD_SQL_DATABASE_NAME}" - source: - source: github.com/terraform-google-modules/terraform-google-sql-db//modules/mysql - version: ~> 22.0 + source: github.com/q2w/terraform-google-sql-db//modules/mysql + version: ~> 23.0 spec: - outputExpr: env_vars + outputExpr: "{\"CLOUD_SQL_DATABASE_HOST\" : instance_first_ip_address, \"CLOUD_SQL_DATABASE_CONNECTION_NAME\" : instance_connection_name, \"CLOUD_SQL_DATABASE_NAME\" : env_vars.CLOUD_SQL_DATABASE_NAME}" - source: source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa - version: ~> 4.3 + version: ~> 4.4 spec: - outputExpr: env_vars + outputExpr: "{\"SERVICE_ACCOUNT_EMAIL\" : email, \"SERVICE_ACCOUNT_IAM_EMAIL\" : iam_email}" - name: service_account description: Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. varType: |- @@ -294,7 +294,7 @@ spec: connections: - source: source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa - version: ~> 4.3 + version: ~> 4.4 spec: outputExpr: email inputPath: email diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index 0a64a80d..a7162fcb 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -20,12 +20,30 @@ variable "project_id" { default = null } +variable "region" { + type = string + description = "Region where the instance template should be created." + default = null +} + variable "name_prefix" { description = "Name prefix for the instance template" type = string default = "default-instance-template" } +variable "machine_type" { + description = "Machine type to create, e.g. n1-standard-1" + type = string + default = "n1-standard-1" +} + +variable "spot" { + type = bool + description = "Provision a SPOT instance" + default = false +} + variable "description" { description = "The template's description" type = string @@ -38,12 +56,6 @@ variable "instance_description" { default = "" } -variable "machine_type" { - description = "Machine type to create, e.g. n1-standard-1" - type = string - default = "n1-standard-1" -} - variable "min_cpu_platform" { description = "Specifies a minimum CPU platform. Applicable values are the friendly names of CPU platforms, such as Intel Haswell or Intel Skylake. See the complete list: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform" type = string @@ -74,12 +86,6 @@ variable "preemptible" { default = false } -variable "spot" { - type = bool - description = "Provision a SPOT instance" - default = false -} - variable "automatic_restart" { type = bool description = "(Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user)." @@ -113,12 +119,6 @@ variable "spot_instance_termination_action" { } } -variable "region" { - type = string - description = "Region where the instance template should be created." - default = null -} - variable "enable_nested_virtualization" { type = bool description = "Defines whether the instance should have nested virtualization enabled." diff --git a/modules/mig/metadata.display.yaml b/modules/mig/metadata.display.yaml index e6dc52a2..17fddfc3 100644 --- a/modules/mig/metadata.display.yaml +++ b/modules/mig/metadata.display.yaml @@ -67,6 +67,7 @@ spec: hostname: name: hostname title: Hostname + invisible: false instance_template: name: instance_template title: Instance Template @@ -79,6 +80,9 @@ spec: mig_name: name: mig_name title: Mig Name + invisible: false + regexValidation: ^[a-z][a-z0-9-]{0,61}[a-z0-9]$ + validation: Use lowercase letters, numbers, and hyphens. Start with a letter and end with letter/number. Must be 63 characters or fewer. mig_timeouts: name: mig_timeouts title: Mig Timeouts @@ -91,6 +95,7 @@ spec: project_id: name: project_id title: Project Id + invisible: false region: name: region title: Region @@ -109,6 +114,7 @@ spec: target_size: name: target_size title: Target Size + invisible: false update_policy: name: update_policy title: Update Policy diff --git a/modules/mig/metadata.yaml b/modules/mig/metadata.yaml index 0982991b..4be2b82e 100644 --- a/modules/mig/metadata.yaml +++ b/modules/mig/metadata.yaml @@ -83,18 +83,22 @@ spec: - name: project_id description: The Google Cloud project ID varType: string - - name: hostname - description: Hostname prefix for instances + - name: region + description: The Google Cloud region where the managed instance group resides. varType: string - defaultValue: default + required: true - name: mig_name description: Managed instance group name. When variable is empty, name will be derived from var.hostname. varType: string defaultValue: "" - - name: region - description: The Google Cloud region where the managed instance group resides. + - name: hostname + description: Hostname prefix for instances varType: string - required: true + defaultValue: default + - name: target_size + description: The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. + varType: number + defaultValue: 1 - name: instance_template description: Instance template self_link used to create compute instances varType: string @@ -105,10 +109,6 @@ spec: version: ~> 12.0 spec: outputExpr: self_link - - name: target_size - description: The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. - varType: number - defaultValue: 1 - name: target_pools description: The target load balancing pools to assign this group to. varType: list(string) diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf index a4de8132..2c093049 100644 --- a/modules/mig/variables.tf +++ b/modules/mig/variables.tf @@ -22,10 +22,9 @@ variable "project_id" { default = null } -variable "hostname" { - description = "Hostname prefix for instances" +variable "region" { + description = "The Google Cloud region where the managed instance group resides." type = string - default = "default" } variable "mig_name" { @@ -34,14 +33,10 @@ variable "mig_name" { default = "" } -variable "region" { - description = "The Google Cloud region where the managed instance group resides." - type = string -} - -variable "instance_template" { - description = "Instance template self_link used to create compute instances" +variable "hostname" { + description = "Hostname prefix for instances" type = string + default = "default" } variable "target_size" { @@ -50,6 +45,11 @@ variable "target_size" { default = 1 } +variable "instance_template" { + description = "Instance template self_link used to create compute instances" + type = string +} + variable "target_pools" { description = "The target load balancing pools to assign this group to." type = list(string)