From 8cc5f65cfe281a250f2dca46078f39849cb1cbf7 Mon Sep 17 00:00:00 2001 From: abhishek kumar tiwari Date: Tue, 22 Oct 2024 11:18:04 +0000 Subject: [PATCH] chore: Add connection metadata, metadata.display.yaml (#439) --- modules/instance_template/README.md | 2 +- .../instance_template/metadata.display.yaml | 180 ++++++++++++++++++ modules/instance_template/metadata.yaml | 36 +++- modules/instance_template/variables.tf | 2 +- modules/mig/metadata.display.yaml | 117 ++++++++++++ modules/mig/metadata.yaml | 11 ++ 6 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 modules/instance_template/metadata.display.yaml create mode 100644 modules/mig/metadata.display.yaml diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index ea16fde5..0127382c 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -47,7 +47,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | project\_id | The GCP project ID | `string` | `null` | no | | region | Region where the instance template should be created. | `string` | `null` | no | | resource\_policies | A list of self\_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. | `list(string)` | `[]` | no | -| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = set(string)
})
| n/a | yes | +| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({
email = string
scopes = optional(set(string), ["cloud-platform"])
})
| n/a | yes | | shielded\_instance\_config | Not used unless enable\_shielded\_vm is true. Shielded VM configuration for the instance. |
object({
enable_secure_boot = bool
enable_vtpm = bool
enable_integrity_monitoring = bool
})
|
{
"enable_integrity_monitoring": true,
"enable_secure_boot": true,
"enable_vtpm": true
}
| no | | source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `""` | no | | source\_image\_family | Source image family. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `"rocky-linux-9-optimized-gcp"` | no | diff --git a/modules/instance_template/metadata.display.yaml b/modules/instance_template/metadata.display.yaml new file mode 100644 index 00000000..0811efe2 --- /dev/null +++ b/modules/instance_template/metadata.display.yaml @@ -0,0 +1,180 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: blueprints.cloud.google.com/v1alpha1 +kind: BlueprintMetadata +metadata: + name: terraform-google-vm-instance-template-display + annotations: + config.kubernetes.io/local-config: "true" +spec: + info: + title: instance_template + source: + repo: https://github.com/terraform-google-modules/terraform-google-vm + sourceType: git + dir: /modules/instance_template + ui: + input: + variables: + access_config: + name: access_config + title: Access Config + altDefaults: + - type: ALTERNATE_TYPE_DC + value: + nat_ip: null + network_tier: PREMIUM + additional_disks: + name: additional_disks + title: Additional Disks + additional_networks: + name: additional_networks + title: Additional Networks + alias_ip_range: + name: alias_ip_range + title: Alias Ip Range + auto_delete: + name: auto_delete + title: Auto Delete + automatic_restart: + name: automatic_restart + title: Automatic Restart + can_ip_forward: + name: can_ip_forward + title: Can Ip Forward + confidential_instance_type: + name: confidential_instance_type + title: Confidential Instance Type + description: + name: description + title: Description + disk_encryption_key: + name: disk_encryption_key + title: Disk Encryption Key + disk_labels: + name: disk_labels + title: Disk Labels + disk_resource_policies: + name: disk_resource_policies + title: Disk Resource Policies + disk_size_gb: + name: disk_size_gb + title: Disk Size Gb + disk_type: + name: disk_type + title: Disk Type + enable_confidential_vm: + name: enable_confidential_vm + title: Enable Confidential Vm + enable_nested_virtualization: + name: enable_nested_virtualization + title: Enable Nested Virtualization + enable_shielded_vm: + name: enable_shielded_vm + title: Enable Shielded Vm + gpu: + name: gpu + title: Gpu + instance_description: + name: instance_description + title: Instance Description + ipv6_access_config: + name: ipv6_access_config + title: Ipv6 Access Config + labels: + name: labels + title: Labels + machine_type: + name: machine_type + title: Machine Type + maintenance_interval: + name: maintenance_interval + title: Maintenance Interval + metadata: + name: metadata + title: Metadata + min_cpu_platform: + name: min_cpu_platform + title: Min Cpu Platform + name_prefix: + name: name_prefix + title: Name Prefix + network: + name: network + title: Network + network_ip: + name: network_ip + title: Network Ip + nic_type: + name: nic_type + title: Nic Type + on_host_maintenance: + name: on_host_maintenance + title: On Host Maintenance + preemptible: + name: preemptible + title: Preemptible + project_id: + name: project_id + title: Project Id + region: + name: region + title: Region + resource_policies: + name: resource_policies + title: Resource Policies + service_account: + name: service_account + title: Service Account + shielded_instance_config: + name: shielded_instance_config + title: Shielded Instance Config + source_image: + name: source_image + title: Source Image + source_image_family: + name: source_image_family + title: Source Image Family + source_image_project: + name: source_image_project + title: Source Image Project + spot: + name: spot + title: Spot + spot_instance_termination_action: + name: spot_instance_termination_action + title: Spot Instance Termination Action + stack_type: + name: stack_type + title: Stack Type + startup_script: + name: startup_script + title: Startup Script + subnetwork: + name: subnetwork + title: Subnetwork + subnetwork_project: + name: subnetwork_project + title: Subnetwork Project + tags: + name: tags + title: Tags + threads_per_core: + name: threads_per_core + title: Threads Per Core + 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 666a02ee..7fbe0985 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -223,6 +223,27 @@ spec: description: Metadata, provided as a map varType: map(string) defaultValue: {} + connections: + - source: + source: github.com/terraform-google-modules/terraform-google-memorystore + version: ~> 10.0 + spec: + outputExpr: env_vars + - source: + source: github.com/terraform-google-modules/terraform-google-sql-db//modules/postgresql + version: ~> 21.0 + spec: + outputExpr: env_vars + - source: + source: github.com/terraform-google-modules/terraform-google-sql-db//modules/mysql + version: ~> 22.0 + spec: + outputExpr: env_vars + - source: + source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa + version: ~> 4.3 + spec: + outputExpr: env_vars - 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 @@ -264,9 +285,16 @@ spec: varType: |- object({ email = string - scopes = set(string) + scopes = optional(set(string), ["cloud-platform"]) }) required: true + connections: + - source: + source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa + version: ~> 4.3 + spec: + outputExpr: email + inputPath: email - name: shielded_instance_config description: Not used unless enable_shielded_vm is true. Shielded VM configuration for the instance. varType: |- @@ -328,12 +356,18 @@ spec: outputs: - name: name description: Name of instance template + type: string - name: self_link description: Self-link of instance template + type: string - name: self_link_unique description: Unique self-link of instance template (recommended output to use instead of self_link) + type: string - name: tags description: Tags that will be associated with instance(s) + type: + - list + - string requirements: roles: - level: Project diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index 5fe65be0..0a64a80d 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -327,7 +327,7 @@ variable "metadata" { variable "service_account" { type = object({ email = string - scopes = set(string) + scopes = optional(set(string), ["cloud-platform"]) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account." } diff --git a/modules/mig/metadata.display.yaml b/modules/mig/metadata.display.yaml new file mode 100644 index 00000000..e6dc52a2 --- /dev/null +++ b/modules/mig/metadata.display.yaml @@ -0,0 +1,117 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: blueprints.cloud.google.com/v1alpha1 +kind: BlueprintMetadata +metadata: + name: terraform-google-vm-mig-display + annotations: + config.kubernetes.io/local-config: "true" +spec: + info: + title: Managed Instance Group (MIG) + source: + repo: https://github.com/terraform-google-modules/terraform-google-vm + sourceType: git + dir: /modules/mig + ui: + input: + variables: + autoscaler_name: + name: autoscaler_name + title: Autoscaler Name + autoscaling_cpu: + name: autoscaling_cpu + title: Autoscaling Cpu + autoscaling_enabled: + name: autoscaling_enabled + title: Autoscaling Enabled + autoscaling_lb: + name: autoscaling_lb + title: Autoscaling Lb + autoscaling_metric: + name: autoscaling_metric + title: Autoscaling Metric + autoscaling_mode: + name: autoscaling_mode + title: Autoscaling Mode + autoscaling_scale_in_control: + name: autoscaling_scale_in_control + title: Autoscaling Scale In Control + cooldown_period: + name: cooldown_period + title: Cooldown Period + distribution_policy_target_shape: + name: distribution_policy_target_shape + title: Distribution Policy Target Shape + distribution_policy_zones: + name: distribution_policy_zones + title: Distribution Policy Zones + health_check: + name: health_check + title: Health Check + health_check_name: + name: health_check_name + title: Health Check Name + hostname: + name: hostname + title: Hostname + instance_template: + name: instance_template + title: Instance Template + labels: + name: labels + title: Labels + max_replicas: + name: max_replicas + title: Max Replicas + mig_name: + name: mig_name + title: Mig Name + mig_timeouts: + name: mig_timeouts + title: Mig Timeouts + min_replicas: + name: min_replicas + title: Min Replicas + named_ports: + name: named_ports + title: Named Ports + project_id: + name: project_id + title: Project Id + region: + name: region + title: Region + scaling_schedules: + name: scaling_schedules + title: Scaling Schedules + stateful_disks: + name: stateful_disks + title: Stateful Disks + stateful_ips: + name: stateful_ips + title: Stateful Ips + target_pools: + name: target_pools + title: Target Pools + target_size: + name: target_size + title: Target Size + update_policy: + name: update_policy + title: Update Policy + wait_for_instances: + name: wait_for_instances + title: Wait For Instances diff --git a/modules/mig/metadata.yaml b/modules/mig/metadata.yaml index 1f64aae0..e0951c75 100644 --- a/modules/mig/metadata.yaml +++ b/modules/mig/metadata.yaml @@ -179,6 +179,12 @@ spec: description: Instance template self_link used to create compute instances varType: string required: true + connections: + - source: + source: github.com/terraform-google-modules/terraform-google-vm//modules/instance_template + version: ~> 12.0 + spec: + outputExpr: self_link - name: labels description: Labels, provided as a map varType: map(string) @@ -282,12 +288,17 @@ spec: outputs: - name: health_check_self_links description: All self_links of healthchecks created for the instance group. + type: + - list + - string - name: instance_group description: Instance-group url of managed instance group + type: string - name: instance_group_manager description: An instance of google_compute_region_instance_group_manager of the instance group. - name: self_link description: Self-link of managed instance group + type: string requirements: roles: - level: Project