From c08f0035e9f1120f869c979bb41f24492c88b070 Mon Sep 17 00:00:00 2001 From: Karol Gorczyk Date: Mon, 7 Oct 2024 11:14:13 +0200 Subject: [PATCH 1/3] add IAM resources to instance_template --- mmv1/products/compute/InstanceTemplate.yaml | 30 +++++++++++++++++++ .../examples/instance_template_basic.tf.tmpl | 12 ++++++++ 2 files changed, 42 insertions(+) create mode 100644 mmv1/products/compute/InstanceTemplate.yaml create mode 100644 mmv1/templates/terraform/examples/instance_template_basic.tf.tmpl diff --git a/mmv1/products/compute/InstanceTemplate.yaml b/mmv1/products/compute/InstanceTemplate.yaml new file mode 100644 index 000000000000..b0305d5b8f57 --- /dev/null +++ b/mmv1/products/compute/InstanceTemplate.yaml @@ -0,0 +1,30 @@ +--- +name: 'InstanceTemplate' +kind: 'compute#instanceTemplate' +description: | + Resource that enables a convenient way to save a virtual machine (VM) instance's configuration + that includes all of its properties and allows you to create a new instance from it. +base_url: 'projects/{{project}}/global/instanceTemplates' +has_self_link: true +exclude_resource: true +properties: + - name: 'name' + type: String + description: | + Name of the resource. + required: true + immutable: true +iam_policy: + parent_resource_attribute: 'name' + base_url: 'projects/{{project}}/global/instanceTemplates/{{name}}' + example_config_body: 'templates/terraform/iam/iam_attributes.go.tmpl' + import_format: + - 'projects/{{project}}/global/instanceTemplates/{{name}}' + - '{{name}}' +custom_code: +examples: + - name: 'instance_template_basic' + primary_resource_id: 'default' + primary_resource_name: 'fmt.Sprintf("tf-test-my-instance-template%s", context["random_suffix"])' + vars: + instance_name: 'my-instance-template' \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/instance_template_basic.tf.tmpl b/mmv1/templates/terraform/examples/instance_template_basic.tf.tmpl new file mode 100644 index 000000000000..e1ff42773207 --- /dev/null +++ b/mmv1/templates/terraform/examples/instance_template_basic.tf.tmpl @@ -0,0 +1,12 @@ +resource "google_compute_instance_template" "{{$.PrimaryResourceId}}" { + name = "{{index $.Vars "instance_name"}}" + machine_type = "e2-medium" + + disk { + source_image = "debian-cloud/debian-11" + } + + network_interface { + network = "default" + } +} \ No newline at end of file From c815bc855aa575d9736c7df83be72632268d50f5 Mon Sep 17 00:00:00 2001 From: Karol Gorczyk Date: Mon, 7 Oct 2024 11:28:02 +0200 Subject: [PATCH 2/3] fix lint check for yaml file --- mmv1/products/compute/InstanceTemplate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/compute/InstanceTemplate.yaml b/mmv1/products/compute/InstanceTemplate.yaml index b0305d5b8f57..569380783c6b 100644 --- a/mmv1/products/compute/InstanceTemplate.yaml +++ b/mmv1/products/compute/InstanceTemplate.yaml @@ -27,4 +27,4 @@ examples: primary_resource_id: 'default' primary_resource_name: 'fmt.Sprintf("tf-test-my-instance-template%s", context["random_suffix"])' vars: - instance_name: 'my-instance-template' \ No newline at end of file + instance_name: 'my-instance-template' From 5c811d09a1b496e26d55966e9727a62001695f60 Mon Sep 17 00:00:00 2001 From: karolgorc Date: Fri, 10 Jan 2025 12:20:59 +0100 Subject: [PATCH 3/3] Fix generating condition tests --- mmv1/products/compute/InstanceTemplate.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mmv1/products/compute/InstanceTemplate.yaml b/mmv1/products/compute/InstanceTemplate.yaml index 569380783c6b..9188c5b3f4f1 100644 --- a/mmv1/products/compute/InstanceTemplate.yaml +++ b/mmv1/products/compute/InstanceTemplate.yaml @@ -18,9 +18,8 @@ iam_policy: parent_resource_attribute: 'name' base_url: 'projects/{{project}}/global/instanceTemplates/{{name}}' example_config_body: 'templates/terraform/iam/iam_attributes.go.tmpl' - import_format: - - 'projects/{{project}}/global/instanceTemplates/{{name}}' - - '{{name}}' + iam_conditions_request_type: 'QUERY_PARAM' + allowed_iam_role: 'roles/compute.instanceAdmin' custom_code: examples: - name: 'instance_template_basic'