From 44791a1f0d21087194ab3f53e6fa96ca1e4f0856 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 28 Aug 2019 21:16:29 +0300 Subject: [PATCH] feat: bump to terraform v12 (#4) --- .github/main.workflow | 6 +++--- README.md | 10 +++++----- main.tf | 37 ++++++++++++++++++------------------- outputs.tf | 4 ++-- variables.tf | 38 ++++++++++++++++++++------------------ 5 files changed, 48 insertions(+), 47 deletions(-) diff --git a/.github/main.workflow b/.github/main.workflow index 6d5df01..009ce5b 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -14,7 +14,7 @@ action "filter-to-pr-open-synced" { } action "terraform-fmt" { - uses = "hashicorp/terraform-github-actions/fmt@v0.1.3" + uses = "hashicorp/terraform-github-actions/fmt@v0.3.5" needs = "filter-to-pr-open-synced" secrets = ["GITHUB_TOKEN"] @@ -24,7 +24,7 @@ action "terraform-fmt" { } action "terraform-init" { - uses = "hashicorp/terraform-github-actions/init@v0.1.3" + uses = "hashicorp/terraform-github-actions/init@v0.3.5" needs = "terraform-fmt" secrets = ["GITHUB_TOKEN"] @@ -34,7 +34,7 @@ action "terraform-init" { } action "terraform-validate" { - uses = "hashicorp/terraform-github-actions/validate@v0.1.3" + uses = "hashicorp/terraform-github-actions/validate@v0.3.5" needs = "terraform-init" secrets = ["GITHUB_TOKEN"] diff --git a/README.md b/README.md index efb0833..c81c350 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,11 @@ The terraform module for creation and management of a GCP project with normalize ```hcl module "my_awesome_project" { - source = "git::https://github.com/SweetOps/terraform-google-project.git?ref=master" - name = "awesome" - stage = "production" - namespace = "sweetops" + source = "git::https://github.com/SweetOps/terraform-google-project.git?ref=master" + name = "awesome" + stage = "production" + namespace = "sweetops" + billing_account_id = "21C1F0-PKL92E-E25235" } ``` @@ -23,7 +24,6 @@ module "my_awesome_project" { | attributes | Additional attributes (e.g. `1`) | list | `` | no | | auto_create_network | Create the 'default' network automatically | string | `"true"` | no | | billing_account_id | The alphanumeric ID of the billing account this project belongs to | string | `""` | no | -| context | Default context to use for passing state between label invocations | map | `` | no | | delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `"-"` | no | | enable_deletion_protection | If true, the Terraform resource can be deleted without deleting the Project via the Google API. | string | `"false"` | no | | enabled | Set to false to prevent the module from creating any resources | string | `"true"` | no | diff --git a/main.tf b/main.tf index afe8bc9..c6e3f9b 100644 --- a/main.tf +++ b/main.tf @@ -1,24 +1,23 @@ module "label" { - source = "git::https://github.com/SweetOps/terraform-null-label.git?ref=tags/0.6.1" - enabled = "${var.enabled}" - namespace = "${var.namespace}" - name = "${var.name}" - stage = "${var.stage}" - environment = "${var.environment}" - delimiter = "${var.delimiter}" - attributes = "${var.attributes}" - context = "${var.context}" - tags = "${var.tags}" + source = "git::https://github.com/SweetOps/terraform-null-label.git?ref=tags/0.7.0" + enabled = var.enabled + namespace = var.namespace + name = var.name + stage = var.stage + environment = var.environment + delimiter = var.delimiter + attributes = var.attributes + tags = var.tags } resource "google_project" "default" { - count = "${var.enabled == "true" ? 1 : 0}" - name = "${module.label.id}" - project_id = "${module.label.id}" - labels = "${module.label.gcp_labels}" - org_id = "${var.org_id}" - folder_id = "${var.folder_id}" - skip_delete = "${var.enable_deletion_protection}" - auto_create_network = "${var.auto_create_network}" - billing_account = "${var.billing_account_id}" + count = var.enabled ? 1 : 0 + name = module.label.id + project_id = module.label.id + labels = module.label.gcp_labels + org_id = var.org_id + folder_id = var.folder_id + skip_delete = var.enable_deletion_protection + auto_create_network = var.auto_create_network + billing_account = var.billing_account_id } diff --git a/outputs.tf b/outputs.tf index 9c9bc35..03fb28e 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,9 +1,9 @@ output "number" { - value = "${join("", google_project.default.*.number)}" + value = join("", google_project.default.*.number) description = "The numeric identifier of the project" } output "name" { - value = "${join("", google_project.default.*.name)}" + value = join("", google_project.default.*.name) description = "The project ID" } diff --git a/variables.tf b/variables.tf index e54e9e6..93d8a76 100644 --- a/variables.tf +++ b/variables.tf @@ -1,75 +1,77 @@ variable "namespace" { - type = "string" + type = string + default = "" description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'" } variable "environment" { - type = "string" + type = string default = "" description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" } variable "stage" { - type = "string" + type = string + default = "" description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'" } variable "name" { - type = "string" + type = string + default = "" description = "Solution name, e.g. 'app' or 'jenkins'" } variable "enabled" { - type = "string" - default = "true" + type = bool + default = true description = "Set to false to prevent the module from creating any resources" } variable "delimiter" { - type = "string" + type = string default = "-" description = "Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`" } variable "attributes" { - type = "list" + type = list(string) default = [] description = "Additional attributes (e.g. `1`)" } variable "tags" { - type = "map" + type = map(string) default = {} description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`" } -variable "context" { - type = "map" - default = {} - description = "Default context to use for passing state between label invocations" -} - variable "org_id" { + type = string default = "" description = "The numeric ID of the organization this project belongs to" } variable "folder_id" { + type = string default = "" description = "The numeric ID of the folder this project should be created under" } variable "enable_deletion_protection" { - default = "false" + type = bool + default = false description = "If true, the Terraform resource can be deleted without deleting the Project via the Google API." } variable "auto_create_network" { - default = "true" + type = bool + default = true description = "Create the 'default' network automatically" } variable "billing_account_id" { - description = "The alphanumeric ID of the billing account this project belongs to" + type = string default = "" + description = "The alphanumeric ID of the billing account this project belongs to" }