Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixes lint issues and generates metadata #288

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.10
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
31 changes: 14 additions & 17 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ variable "project_id" {

variable "hostname" {
description = "Hostname prefix for instances"
type = string
default = "default"
}

Expand All @@ -35,29 +36,35 @@ variable "mig_name" {

variable "region" {
description = "The GCP region where the managed instance group resides."
type = string
}

{% if mig %}
variable "instance_template" {
description = "Instance template self_link used to create compute instances"
type = string
}

{% else %}
variable "instance_template_initial_version" {
description = "Instance template self_link used to create compute instances for the initial version"
type = string
}

variable "instance_template_next_version" {
description = "Instance template self_link used to create compute instances for the second version"
type = string
}

variable "next_version_percent" {
description = "Percentage of instances defined in the second version"
type = number
}

{% 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
}

Expand Down Expand Up @@ -161,21 +168,25 @@ variable "autoscaler_name" {
variable "autoscaling_enabled" {
description = "Creates an autoscaler for the managed instance group"
default = "false"
type = string
}

variable "max_replicas" {
description = "The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas."
default = 10
type = number
}

variable "min_replicas" {
description = "The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0."
default = 2
type = number
}

variable "cooldown_period" {
description = "The number of seconds that the autoscaler should wait before it starts collecting information from a new instance."
default = 60
type = number
}

variable "autoscaling_mode" {
Expand All @@ -186,11 +197,11 @@ variable "autoscaling_mode" {

variable "autoscaling_cpu" {
description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#cpu_utilization"
type = list(object({
type = list(object({
target = number
predictive_method = string
}))
default = []
default = []
}

variable "autoscaling_metric" {
Expand Down Expand Up @@ -238,21 +249,6 @@ variable "autoscaling_scale_in_control" {

##########################

variable "network" {
description = "Network to deploy to. Only one of network or subnetwork should be specified."
default = ""
}

variable "subnetwork" {
description = "Subnet to deploy to. Only one of network or subnetwork should be specified."
default = ""
}

variable "subnetwork_project" {
description = "The project that subnetwork belongs to"
default = ""
}

variable "named_ports" {
description = "Named name and named port. https://cloud.google.com/load-balancing/docs/backend-service#named_ports"
type = list(object({
Expand All @@ -264,6 +260,7 @@ variable "named_ports" {

variable "wait_for_instances" {
description = "Whether to wait for all instances to be created/updated before returning. Note that if this is set to true and the operation does not succeed, Terraform will continue trying until it times out."
type = string
default = "false"
}

Expand Down
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.10'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.10'
1 change: 0 additions & 1 deletion examples/compute_instance/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This is a simple, minimal example of how to use the compute_instance module

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| deletion\_protection | Enable deletion protection on this instance. Note: you must disable deletion protection before removing the resource, or the instance cannot be deleted and the Terraform run will not complete successfully. | `bool` | `false` | no |
| nat\_ip | Public ip address | `any` | `null` | no |
| network\_tier | Network network\_tier | `string` | `"PREMIUM"` | no |
| num\_instances | Number of instances to create | `any` | n/a | yes |
Expand Down
6 changes: 0 additions & 6 deletions examples/compute_instance/simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ variable "network_tier" {
default = "PREMIUM"
}

variable "deletion_protection" {
type = bool
description = "Enable deletion protection on this instance. Note: you must disable deletion protection before removing the resource, or the instance cannot be deleted and the Terraform run will not complete successfully."
default = false
}

variable "service_account" {
default = null
type = object({
Expand Down
6 changes: 2 additions & 4 deletions examples/mig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ module "instance_template" {
service_account = var.service_account

/* network */
network = var.network
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
can_ip_forward = var.can_ip_forward
subnetwork = var.subnetwork
can_ip_forward = var.can_ip_forward

/* image */
source_image = var.source_image
Expand Down
17 changes: 0 additions & 17 deletions examples/mig/full/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ variable "region" {
default = "us-central1"
}

variable "network" {
description = "Network to deploy to. Only one of network or subnetwork should be specified."
default = ""
}

variable "subnetwork" {
description = "Subnet to deploy to. Only one of network or subnetwork should be specified."
default = ""
Expand All @@ -44,13 +39,6 @@ variable "project_id" {
type = string
}



variable "subnetwork_project" {
description = "The project that subnetwork belongs to"
default = ""
}

variable "named_ports" {
description = "Named name and named port"
type = list(object({
Expand All @@ -63,11 +51,6 @@ variable "named_ports" {
####################
# Instance Template
####################
variable "name_prefix" {
description = "Name prefix for the instance template"
default = "default-instance-template"
}

variable "machine_type" {
description = "Machine type to create, e.g. n1-standard-1"
default = "n1-standard-1"
Expand Down
28 changes: 12 additions & 16 deletions examples/umig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ module "instance_template" {
service_account = var.service_account

/* network */
network = var.network
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
can_ip_forward = var.can_ip_forward
subnetwork = var.subnetwork
can_ip_forward = var.can_ip_forward

/* image */
source_image = var.source_image
Expand All @@ -61,16 +59,14 @@ module "instance_template" {
}

module "umig" {
source = "../../../modules/umig"
project_id = var.project_id
network = var.network
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
hostname = var.hostname
static_ips = var.static_ips
num_instances = var.target_size
instance_template = module.instance_template.self_link
named_ports = var.named_ports
region = var.region
access_config = [[local.access_config]]
source = "../../../modules/umig"
project_id = var.project_id
subnetwork = var.subnetwork
hostname = var.hostname
static_ips = var.static_ips
num_instances = var.target_size
instance_template = module.instance_template.self_link
named_ports = var.named_ports
region = var.region
access_config = [[local.access_config]]
}
15 changes: 0 additions & 15 deletions examples/umig/full/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,11 @@ variable "region" {
default = "us-central1"
}

variable "network" {
description = "Network to deploy to. Only one of network or subnetwork should be specified."
default = ""
}

variable "subnetwork" {
description = "Subnet to deploy to. Only one of network or subnetwork should be specified."
default = ""
}

variable "subnetwork_project" {
description = "The project that subnetwork belongs to"
default = ""
}

variable "named_ports" {
description = "Named name and named port"
type = list(object({
Expand All @@ -63,11 +53,6 @@ variable "named_ports" {
####################
# Instance Template
####################
variable "name_prefix" {
description = "Name prefix for the instance template"
default = "default-instance-template"
}

variable "machine_type" {
description = "Machine type to create, e.g. n1-standard-1"
default = "n1-standard-1"
Expand Down
93 changes: 93 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2022 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
annotations:
config.kubernetes.io/local-config: "true"
spec:
title: terraform-google-vm
source:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
subBlueprints:
- name: compute_disk_snapshot
location: modules/compute_disk_snapshot
- name: compute_instance
location: modules/compute_instance
- name: instance_template
location: modules/instance_template
- name: mig
location: modules/mig
- name: mig_with_percent
location: modules/mig_with_percent
- name: preemptible_and_regular_instance_templates
location: modules/preemptible_and_regular_instance_templates
- name: umig
location: modules/umig
examples:
- name: additional_disks
location: examples/instance_template/additional_disks
- name: alias_ip_range
location: examples/instance_template/alias_ip_range
- name: autoscaler
location: examples/mig/autoscaler
- name: disk_snapshot
location: examples/compute_instance/disk_snapshot
- name: encrypted_disks
location: examples/instance_template/encrypted_disks
- name: full
location: examples/mig/full
- name: full
location: examples/umig/full
- name: healthcheck
location: examples/mig/healthcheck
- name: multiple_interfaces
location: examples/compute_instance/multiple_interfaces
- name: named_ports
location: examples/umig/named_ports
- name: next_hop
location: examples/compute_instance/next_hop
- name: simple
location: examples/compute_instance/simple
- name: simple
location: examples/instance_template/simple
- name: simple
location: examples/mig/simple
- name: simple
location: examples/mig_with_percent/simple
- name: simple
location: examples/preemptible_and_regular_instance_templates/simple
- name: simple
location: examples/umig/simple
- name: static_ips
location: examples/umig/static_ips
- name: tags
location: examples/compute_instance/tags
roles:
- level: Project
roles:
- roles/owner
- roles/compute.admin
- roles/compute.networkAdmin
- roles/iam.serviceAccountUser
- roles/compute.instanceAdmin
services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
- serviceusage.googleapis.com
- compute.googleapis.com
- iam.googleapis.com
Loading