Skip to content

Commit

Permalink
Merge pull request #13 from ingwarr/master
Browse files Browse the repository at this point in the history
Add support for Terraform 0.12 #11
  • Loading branch information
aaron-lane committed Aug 2, 2019
2 parents 028dd3d + de23d40 commit e900282
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 28 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- Supported version of Terraform is 0.12. [#11]

## [1.0.3] - 2018-08-21


## [1.0.2] - 2017-11-08


## [1.0.1] - 2017-19-09


## [1.0.0] - 2017-08-28


[Unreleased]: https://github.com/GoogleCloudPlatform/terraform-google-lb/compare/v1.0.3...HEAD
[1.0.3]: https://github.com/GoogleCloudPlatform/terraform-google-lb/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/GoogleCloudPlatform/terraform-google-lb/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/GoogleCloudPlatform/terraform-google-lb/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/GoogleCloudPlatform/terraform-google-lb/releases/tag/1.0.0
[#11]: https://github.com/terraform-google-modules/terraform-google-vm/pull/11
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Modular Regional TCP Load Balancer for GCE using target pool and forwarding rule
<a href="https://concourse-tf.gcp.solutions/teams/main/pipelines/tf-examples-lb-basic" target="_blank">
<img src="https://concourse-tf.gcp.solutions/api/v1/teams/main/pipelines/tf-examples-lb-basic/badge" /></a>

## Compatibility

This module is meant for use with Terraform 0.12. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-12.html)
and need a Terraform 0.11.x-compatible version of this module, the last released version intended for
Terraform 0.11.x is [1.0.3](https://github.com/GoogleCloudPlatform/terraform-google-lb/releases/tag/1.0.3)

## Usage

```ruby
Expand Down
4 changes: 4 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Note

This example should be updated to use with terraform-0.12 after the next release of terraform-google-modules/vm/google/mig

# TCP Forwarding Rule Example

[![button](http://gstatic.com/cloudssh/images/open-btn.png)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/terraform-google-lb&working_dir=examples/basic&page=shell&tutorial=README.md)
Expand Down
32 changes: 17 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,43 @@
*/

resource "google_compute_forwarding_rule" "default" {
project = "${var.project}"
name = "${var.name}"
target = "${google_compute_target_pool.default.self_link}"
project = var.project
name = var.name
target = google_compute_target_pool.default.self_link
load_balancing_scheme = "EXTERNAL"
port_range = "${var.service_port}"
port_range = var.service_port
region = var.region
}

resource "google_compute_target_pool" "default" {
project = "${var.project}"
name = "${var.name}"
region = "${var.region}"
session_affinity = "${var.session_affinity}"
project = var.project
name = var.name
region = var.region
session_affinity = var.session_affinity

health_checks = [
"${google_compute_http_health_check.default.name}",
google_compute_http_health_check.default.name,
]
}

resource "google_compute_http_health_check" "default" {
project = "${var.project}"
project = var.project
name = "${var.name}-hc"
request_path = "/"
port = "${var.service_port}"
port = var.service_port
}

resource "google_compute_firewall" "default-lb-fw" {
project = "${var.firewall_project == "" ? var.project : var.firewall_project}"
project = var.firewall_project == "" ? var.project : var.firewall_project
name = "${var.name}-vm-service"
network = "${var.network}"
network = var.network

allow {
protocol = "tcp"
ports = ["${var.service_port}"]
ports = [var.service_port]
}

source_ranges = ["0.0.0.0/0"]
target_tags = ["${var.target_tags}"]
target_tags = var.target_tags
}

9 changes: 5 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
* limitations under the License.
*/

output target_pool {
output "target_pool" {
description = "The `self_link` to the target pool resource created."
value = "${google_compute_target_pool.default.self_link}"
value = google_compute_target_pool.default.self_link
}

output external_ip {
output "external_ip" {
description = "The external ip address of the forwarding rule."
value = "${google_compute_forwarding_rule.default.ip_address}"
value = google_compute_forwarding_rule.default.ip_address
}

26 changes: 17 additions & 9 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,48 @@
* limitations under the License.
*/

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

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

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

variable firewall_project {
variable "firewall_project" {
type = string
description = "Name of the project to create the firewall rule in. Useful for shared VPC. Default is var.project."
default = ""
}

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

variable service_port {
variable "service_port" {
type = number
description = "TCP port your service is listening on."
}

variable target_tags {
variable "target_tags" {
description = "List of target tags to allow traffic using firewall rule."
type = "list"
type = list(string)
}

variable session_affinity {
variable "session_affinity" {
type = string
description = "How to distribute load. Options are `NONE`, `CLIENT_IP` and `CLIENT_IP_PROTO`"
default = "NONE"
}

19 changes: 19 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2019 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.
*/

terraform {
required_version = ">= 0.12"
}

0 comments on commit e900282

Please sign in to comment.