Skip to content

Commit

Permalink
fix: fixes lint issues and generates metadata (#110)
Browse files Browse the repository at this point in the history
Co-authored-by: Awais Malik <awmalik@google.com>
  • Loading branch information
g-awmalik and g-awmalik authored Dec 27, 2022
1 parent c4bdf78 commit d899925
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 11 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ suites:
name: terraform
command_timeout: 1800
root_module_directory: test/fixtures/minimal
verify_version: false
verifier:
name: terraform
color: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,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'
2 changes: 1 addition & 1 deletion examples/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "random_string" "suffix" {
length = 8
upper = false
lower = true
number = true
numeric = true
special = false
}

Expand Down
181 changes: 181 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# 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-lb-internal
annotations:
config.kubernetes.io/local-config: "true"
spec:
title: Internal Load Balancer Terraform Module
source:
repo: https://github.com/terraform-google-modules/terraform-google-lb-internal
sourceType: git
version: 5.0.0
actuationTool:
type: Terraform
version: '>= 0.13'
examples:
- name: minimal
location: examples/minimal
- name: simple
location: examples/simple
variables:
- name: all_ports
description: Boolean for all_ports setting on forwarding rule.
type: bool
required: false
- name: backends
description: List of backends, should be a map of key-value pairs for each backend, must have the 'group' key.
type: list(any)
required: true
- name: connection_draining_timeout_sec
description: Time for which instance will be drained
type: number
required: false
- name: create_backend_firewall
description: Controls if firewall rules for the backends will be created or not. Health-check firewall rules are controlled separately.
type: bool
default: true
required: false
- name: create_health_check_firewall
description: Controls if firewall rules for the health check will be created or not. If this rule is not present backend healthcheck will fail.
type: bool
default: true
required: false
- name: firewall_enable_logging
description: Controls if firewall rules that are created are to have logging configured. This will be ignored for firewall rules that are not created.
type: bool
default: false
required: false
- name: global_access
description: Allow all regions on the same VPC network access.
type: bool
default: false
required: false
- name: health_check
description: Health check to determine whether instances are responsive and able to do work
type: |-
object({
type = string
check_interval_sec = number
healthy_threshold = number
timeout_sec = number
unhealthy_threshold = number
response = string
proxy_header = string
port = number
port_name = string
request = string
request_path = string
host = string
enable_log = bool
})
required: true
- name: ip_address
description: IP address of the internal load balancer, if empty one will be assigned. Default is empty.
type: string
required: false
- name: ip_protocol
description: The IP protocol for the backend and frontend forwarding rule. TCP or UDP.
type: string
default: TCP
required: false
- name: labels
description: The labels to attach to resources created by this module.
type: map(string)
default: {}
required: false
- name: name
description: Name for the forwarding rule and prefix for supporting resources.
type: string
required: true
- name: network
description: Name of the network to create resources in.
type: string
default: default
required: false
- name: network_project
description: Name of the project for the network. Useful for shared VPC. Default is var.project.
type: string
default: ""
required: false
- name: ports
description: List of ports range to forward to backend services. Max is 5.
type: list(string)
required: true
- name: project
description: The project to deploy to, if not set the default provider project is used.
type: string
default: ""
required: false
- name: region
description: Region for cloud resources.
type: string
default: us-central1
required: false
- name: service_label
description: Service label is used to create internal DNS name
type: string
required: false
- name: session_affinity
description: 'The session affinity for the backends example: NONE, CLIENT_IP. Default is `NONE`.'
type: string
default: NONE
required: false
- name: source_ip_ranges
description: List of source ip ranges for traffic between the internal load balancer.
type: list(string)
required: false
- name: source_service_accounts
description: List of source service accounts for traffic between the internal load balancer.
type: list(string)
required: false
- name: source_tags
description: List of source tags for traffic between the internal load balancer.
type: list(string)
required: true
- name: subnetwork
description: Name of the subnetwork to create resources in.
type: string
default: default
required: false
- name: target_service_accounts
description: List of target service accounts for traffic between the internal load balancer.
type: list(string)
required: false
- name: target_tags
description: List of target tags for traffic between the internal load balancer.
type: list(string)
required: true
outputs:
- name: forwarding_rule
description: The forwarding rule self_link.
- name: forwarding_rule_id
description: The forwarding rule id.
- name: ip_address
description: The internal IP assigned to the regional forwarding rule.
roles:
- level: Project
roles:
- roles/owner
- roles/compute.networkAdmin
- roles/compute.loadBalancerAdmin
- roles/compute.securityAdmin
services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
- serviceusage.googleapis.com
- compute.googleapis.com
17 changes: 10 additions & 7 deletions test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

terraform {
required_version = ">= 0.13"
}

provider "google" {
version = "~> 4.26"
}

provider "google-beta" {
version = "~> 4.26"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.26"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 4.26"
}
}
}
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

variable "project" {
description = "The project to deploy to, if not set the default provider project is used."
type = string
default = ""
}

variable "region" {
description = "Region for cloud resources."
type = string
default = "us-central1"
}

Expand All @@ -32,21 +34,25 @@ variable "global_access" {

variable "network" {
description = "Name of the network to create resources in."
type = string
default = "default"
}

variable "subnetwork" {
description = "Name of the subnetwork to create resources in."
type = string
default = "default"
}

variable "network_project" {
description = "Name of the project for the network. Useful for shared VPC. Default is var.project."
type = string
default = ""
}

variable "name" {
description = "Name for the forwarding rule and prefix for supporting resources."
type = string
}

variable "backends" {
Expand All @@ -56,6 +62,7 @@ variable "backends" {

variable "session_affinity" {
description = "The session affinity for the backends example: NONE, CLIENT_IP. Default is `NONE`."
type = string
default = "NONE"
}

Expand Down Expand Up @@ -119,11 +126,13 @@ variable "target_service_accounts" {

variable "ip_address" {
description = "IP address of the internal load balancer, if empty one will be assigned. Default is empty."
type = string
default = null
}

variable "ip_protocol" {
description = "The IP protocol for the backend and frontend forwarding rule. TCP or UDP."
type = string
default = "TCP"
}

Expand Down

0 comments on commit d899925

Please sign in to comment.