diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c33710..23c6549 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,11 +40,16 @@ jobs: go-version: 1.17.6 - name: Set up Terramate - # for security reasons we pin commit ids and not tags. - # mineiros-io/terramate@v0.1.1 -> bea6836fa912c982f39a2965a327476b15d06b45 - run: go install github.com/mineiros-io/terramate/cmd/terramate@bea6836fa912c982f39a2965a327476b15d06b45 - env: - GOPROXY: direct + uses: giantswarm/install-binary-action@e97402b0aa95939ddba5b36aa77f8abc58a37fd5 + with: + binary: terramate + version: 0.1.41 + # https://github.com/mineiros-io/terramate/releases/download/v${version}/terramate_${version}_${os}_${arch}.tar.gz + download_url: "https://github.com/mineiros-io/${binary}/releases/download/v${version}/terramate_${version}_linux_x86_64.tar.gz" + tarball_binary_path: "${binary}" + + - name: Clean Up Terramate Install Artifacts + run: rm -rf terramate - name: Set up Terradoc # for security reasons we pin commit ids and not tags. @@ -58,7 +63,7 @@ jobs: # hashicorp/setup-terraform@v2.0.0 -> 17d4c9b8043b238f6f35641cdd8433da1e6f3867 uses: hashicorp/setup-terraform@17d4c9b8043b238f6f35641cdd8433da1e6f3867 with: - terraform_version: 1.2.1 + terraform_version: 1.3.0 terraform_wrapper: false - name: Setup TFLint @@ -66,7 +71,7 @@ jobs: # terraform-linters/setup-tflint@v2.0.0 -> 9e653e0f7de0839150e03280e0981e0c25eaf10a uses: terraform-linters/setup-tflint@9e653e0f7de0839150e03280e0981e0c25eaf10a with: - tflint_version: v0.29.0 + tflint_version: v0.41.0 - name: Setup and run pre-commit # for security reasons we pin commit ids and not tags. diff --git a/.terramate/manifest.tm.hcl b/.terramate/manifest.tm.hcl new file mode 100644 index 0000000..4a2ccc5 --- /dev/null +++ b/.terramate/manifest.tm.hcl @@ -0,0 +1,11 @@ +vendor { + manifest { + default { + files = [ + "/*.tf", + "/README.md", + "/LICENSE", + ] + } + } +} diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..a7e3d5d --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,7 @@ +rule "terraform_unused_declarations" { + enabled = false +} + +rule "terraform_required_providers" { + enabled = false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9228633..e419b23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## Added + - Validation added for `database_version` string input variable ## [0.0.5] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6f071a6..b774be4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,7 +59,7 @@ tests locally. At this point, make your code changes and constantly test again your new test case to make sure that everything working properly. Do [commit] early and often and make useful commit messages. -If a backwards incompatible change cannot be avoided, please make sure to call that out when you submit a pull request, +If a backward incompatible change cannot be avoided, please make sure to call that out when you submit a pull request, explaining why the change is absolutely necessary. ## Create a pull request @@ -68,7 +68,7 @@ explaining why the change is absolutely necessary. Please make sure to include the following: 1. A description of the change, including a link to your GitHub issue. -1. Any notes on backwards incompatibility or downtime. +1. Any notes on backward incompatibility or downtime. ## Merge and release @@ -77,14 +77,14 @@ If everything looks good, they will merge the code and release a new version whi <!-- References --> +[github flow]: https://docs.github.com/en/get-started/quickstart/github-flow +[codeowners]: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners +[fork]: https://docs.github.com/en/get-started/quickstart/fork-a-repo +[commit]: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project +[create a new branch]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository +[create a pull request]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request [pull requests]: https://github.com/mineiros-io/terraform-google-cloud-sql/pulls [pre-commit-file]: https://github.com/mineiros-io/terraform-google-cloud-sql/blob/main/.pre-commit-config.yaml -[github flow]: https://guides.github.com/introduction/flow/ -[codeowners]: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners -[fork]: https://help.github.com/en/github/getting-started-with-github/fork-a-repo -[create a new branch]: https://guides.github.com/introduction/flow/ [readme driven development]: https://tom.preston-werner.com/2010/08/23/readme-driven-development.html -[commit]: https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project -[create a pull request]: https://help.github.com/articles/creating-a-pull-request/ [semantic versioning (semver)]: https://semver.org/ [test driven development]: https://en.wikipedia.org/wiki/Test-driven_development diff --git a/LICENSE b/LICENSE index 2157457..c4714c0 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2020-2021] [Mineiros GmbH] + Copyright [2020-2022] [Mineiros GmbH] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/terramate.tm.hcl b/terramate.tm.hcl new file mode 100644 index 0000000..99c4f7a --- /dev/null +++ b/terramate.tm.hcl @@ -0,0 +1,24 @@ +stack { + name = "terraform-google-cloud-sql" + description = "github.com/mineiros-io/terraform-google-cloud-sql" +} + +generate_hcl "versions.tf" { + condition = terramate.stack.path.absolute == "/" + + content { + terraform { + required_version = global.terraform_version_constraint + + tm_dynamic required_providers { + for_each = [1] + attributes = { + "${global.provider}" = { + source = "hashicorp/${global.provider}" + version = global.provider_version_constraint + } + } + } + } + } +} diff --git a/test/README.md b/test/README.md index 5c92bba..6d64617 100644 --- a/test/README.md +++ b/test/README.md @@ -1,4 +1,4 @@ -[<img src="https://raw.githubusercontent.com/mineiros-io/brand/3bffd30e8bdbbde32c143e2650b2faa55f1df3ea/mineiros-primary-logo.svg" width="400"/>][homepage] +[<img src="https://raw.githubusercontent.com/mineiros-io/brand/f2042a229e8feb4b188bea0aec4f6f2ad900c82e/mineiros-primary-logo.svg" width="400"/>][homepage] [![license][badge-license]][apache20] [![Join Slack][badge-slack]][slack] @@ -110,6 +110,6 @@ Alternatively, you can also run the tests without Docker. [go]: https://golang.org/ [terraform]: https://www.terraform.io/downloads.html [badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg -[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack +[badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f43f5e.svg?logo=slack [apache20]: https://opensource.org/licenses/Apache-2.0 [slack]: https://mineiros.io/slack diff --git a/test/go.mod b/test/go.mod index 8ddf31f..51d0fd2 100644 --- a/test/go.mod +++ b/test/go.mod @@ -3,6 +3,6 @@ module github.com/mineiros-io/terraform-google-cloud-sql/test go 1.14 require ( - github.com/gruntwork-io/terratest v0.40.13 + github.com/gruntwork-io/terratest v0.40.17 github.com/stretchr/testify v1.7.0 ) diff --git a/test/go.sum b/test/go.sum index ffeb640..2ad1e4a 100644 --- a/test/go.sum +++ b/test/go.sum @@ -439,8 +439,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gruntwork-io/go-commons v0.8.0/go.mod h1:gtp0yTtIBExIZp7vyIV9I0XQkVwiQZze678hvDXof78= -github.com/gruntwork-io/terratest v0.40.13 h1:RTJnPTO2kalzkjrNb7nKoKGWfWYnHsf5UzPG3USZBWI= -github.com/gruntwork-io/terratest v0.40.13/go.mod h1:xlVN8UHxN93Z5nt61I0gTU/FESm2C78rYS+/3xcDDdI= +github.com/gruntwork-io/terratest v0.40.17 h1:veSr7MUtk5GRDg5/pZ9qLUvrylr7yuRw0fY9UaSHbuI= +github.com/gruntwork-io/terratest v0.40.17/go.mod h1:enUpxNMsQfiJTTJMGqiznxohqJ4cYPU+nzI3bQNw1WM= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -449,8 +449,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY= -github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= @@ -1018,8 +1018,9 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/test/terramate_aws.tm.hcl b/test/terramate_aws.tm.hcl deleted file mode 100644 index d1a0eb9..0000000 --- a/test/terramate_aws.tm.hcl +++ /dev/null @@ -1,45 +0,0 @@ -# globals { -# minimum_provider_version = "4.0" -# provider_version_constraint = "~> ${global.minimum_provider_version}" -# -# stack_basename = tm_reverse(tm_split("/", terramate.path))[0] -# } -# -# generate_hcl "_generated_aws.tf" { -# # condition = global.provider == "aws" -# content { -# variable "aws_region" { -# description = "(Optional) The AWS region in which all resources will be created." -# type = string -# default = "eu-west-1" -# } -# -# terraform { -# required_providers { -# aws = { -# source = "hashicorp/aws" -# version = global.provider_version_constraint -# } -# random = { -# source = "hashicorp/random" -# version = "~> 3.1" -# } -# } -# -# provider "aws" { -# region = var.aws_region -# } -# -# provider "random" {} -# -# resource "random_id" "suffix" { -# count = local.test_name != "unit-disabled" ? 1 : 0 -# byte_length = 16 -# } -# -# # define default locals for all tests -# locals { -# random_suffix = try(random_id.suffix[0].hex, "disabled") -# } -# } -# } diff --git a/test/terramate_google.tm.hcl b/test/terramate_google.tm.hcl index 6c3dc1a..53db5ae 100644 --- a/test/terramate_google.tm.hcl +++ b/test/terramate_google.tm.hcl @@ -1,16 +1,10 @@ -globals { - minimum_provider_version = "4.4" - provider_version_constraint = "~> ${global.minimum_provider_version}" - - stack_basename = tm_reverse(tm_split("/", terramate.path))[0] -} - generate_hcl "_generated_google.tf" { - # condition = global.provider == "google" + condition = global.provider == "google" || global.provider == "google-beta" content { variable "gcp_project" { type = string - description = "(Required) The ID of the project in which the resource belongs." + description = "(Optional) The ID of the project in which the resource belongs." + default = null } variable "gcp_region" { @@ -28,7 +22,7 @@ generate_hcl "_generated_google.tf" { variable "gcp_billing_account" { type = string description = "(Optional) The billing account to use when creating projects." - default = null + default = "test-billing-account" } terraform { @@ -37,6 +31,10 @@ generate_hcl "_generated_google.tf" { source = "hashicorp/google" version = global.provider_version_constraint } + google-beta = { + source = "hashicorp/google-beta" + version = global.provider_version_constraint + } random = { source = "hashicorp/random" version = "~> 3.1" @@ -49,6 +47,11 @@ generate_hcl "_generated_google.tf" { region = var.gcp_region } + provider "google-beta" { + project = var.gcp_project + region = var.gcp_region + } + provider "random" {} resource "random_id" "suffix" { @@ -56,23 +59,28 @@ generate_hcl "_generated_google.tf" { byte_length = 16 } - data "google_project" "project" {} + data "google_project" "project" { + count = var.gcp_project != null ? 1 : 0 + + project_id = var.gcp_project + } data "google_organization" "org" { - count = local.org_domain != null ? 1 : 0 + count = var.gcp_org_domain != null ? 1 : 0 - domain = local.org_domain + domain = var.gcp_org_domain } # define default locals for all tests locals { - test_name = global.stack_basename - random_suffix = try(random_id.suffix[0].hex, "disabled") - project_id = var.gcp_project - project_number = data.google_project.project.number - org_domain = var.gcp_org_domain - org_id = try(data.google_organization.org[0].name, null) - billing_account = var.gcp_billing_account + test_name = terramate.stack.path.basename + random_suffix = try(random_id.suffix[0].hex, "disabled") + project_id = try(data.google_project.project[0].project_id, "no-project") + project_number = try(data.google_project.project[0].number, null) + org_domain = try(data.google_organization.org[0].domain, "no-domain.mineiros.io") + org_id = try(data.google_organization.org[0].org_id, null) + billing_account = var.gcp_billing_account + directory_customer_id = try(data.google_organization.org[0].directory_customer_id, "no-directoy-customer") } } } diff --git a/test/unit-complete/_generated_google.tf b/test/unit-complete/_generated_google.tf index 11318e2..ca800a8 100644 --- a/test/unit-complete/_generated_google.tf +++ b/test/unit-complete/_generated_google.tf @@ -2,7 +2,8 @@ // TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl variable "gcp_project" { - description = "(Required) The ID of the project in which the resource belongs." + default = null + description = "(Optional) The ID of the project in which the resource belongs." type = string } variable "gcp_region" { @@ -16,7 +17,7 @@ variable "gcp_org_domain" { type = string } variable "gcp_billing_account" { - default = null + default = "test-billing-account" description = "(Optional) The billing account to use when creating projects." type = string } @@ -26,6 +27,10 @@ terraform { source = "hashicorp/google" version = "~> 4.4" } + google-beta = { + source = "hashicorp/google-beta" + version = "~> 4.4" + } random = { source = "hashicorp/random" version = "~> 3.1" @@ -36,6 +41,10 @@ provider "google" { project = var.gcp_project region = var.gcp_region } +provider "google-beta" { + project = var.gcp_project + region = var.gcp_region +} provider "random" { } resource "random_id" "suffix" { @@ -43,17 +52,20 @@ resource "random_id" "suffix" { count = local.test_name != "unit-disabled" ? 1 : 0 } data "google_project" "project" { + count = var.gcp_project != null ? 1 : 0 + project_id = var.gcp_project } data "google_organization" "org" { - count = local.org_domain != null ? 1 : 0 - domain = local.org_domain + count = var.gcp_org_domain != null ? 1 : 0 + domain = var.gcp_org_domain } locals { - billing_account = var.gcp_billing_account - org_domain = var.gcp_org_domain - org_id = try(data.google_organization.org[0].name, null) - project_id = var.gcp_project - project_number = data.google_project.project.number - random_suffix = try(random_id.suffix[0].hex, "disabled") - test_name = "unit-complete" + billing_account = var.gcp_billing_account + directory_customer_id = try(data.google_organization.org[0].directory_customer_id, "no-directoy-customer") + org_domain = try(data.google_organization.org[0].domain, "no-domain.mineiros.io") + org_id = try(data.google_organization.org[0].org_id, null) + project_id = try(data.google_project.project[0].project_id, "no-project") + project_number = try(data.google_project.project[0].number, null) + random_suffix = try(random_id.suffix[0].hex, "disabled") + test_name = "unit-complete" } diff --git a/test/unit-disabled/_generated_google.tf b/test/unit-disabled/_generated_google.tf index 3ea2e76..9366559 100644 --- a/test/unit-disabled/_generated_google.tf +++ b/test/unit-disabled/_generated_google.tf @@ -2,7 +2,8 @@ // TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl variable "gcp_project" { - description = "(Required) The ID of the project in which the resource belongs." + default = null + description = "(Optional) The ID of the project in which the resource belongs." type = string } variable "gcp_region" { @@ -16,7 +17,7 @@ variable "gcp_org_domain" { type = string } variable "gcp_billing_account" { - default = null + default = "test-billing-account" description = "(Optional) The billing account to use when creating projects." type = string } @@ -26,6 +27,10 @@ terraform { source = "hashicorp/google" version = "~> 4.4" } + google-beta = { + source = "hashicorp/google-beta" + version = "~> 4.4" + } random = { source = "hashicorp/random" version = "~> 3.1" @@ -36,6 +41,10 @@ provider "google" { project = var.gcp_project region = var.gcp_region } +provider "google-beta" { + project = var.gcp_project + region = var.gcp_region +} provider "random" { } resource "random_id" "suffix" { @@ -43,17 +52,20 @@ resource "random_id" "suffix" { count = local.test_name != "unit-disabled" ? 1 : 0 } data "google_project" "project" { + count = var.gcp_project != null ? 1 : 0 + project_id = var.gcp_project } data "google_organization" "org" { - count = local.org_domain != null ? 1 : 0 - domain = local.org_domain + count = var.gcp_org_domain != null ? 1 : 0 + domain = var.gcp_org_domain } locals { - billing_account = var.gcp_billing_account - org_domain = var.gcp_org_domain - org_id = try(data.google_organization.org[0].name, null) - project_id = var.gcp_project - project_number = data.google_project.project.number - random_suffix = try(random_id.suffix[0].hex, "disabled") - test_name = "unit-disabled" + billing_account = var.gcp_billing_account + directory_customer_id = try(data.google_organization.org[0].directory_customer_id, "no-directoy-customer") + org_domain = try(data.google_organization.org[0].domain, "no-domain.mineiros.io") + org_id = try(data.google_organization.org[0].org_id, null) + project_id = try(data.google_project.project[0].project_id, "no-project") + project_number = try(data.google_project.project[0].number, null) + random_suffix = try(random_id.suffix[0].hex, "disabled") + test_name = "unit-disabled" } diff --git a/test/unit-minimal/_generated_google.tf b/test/unit-minimal/_generated_google.tf index 9decca0..ba80d48 100644 --- a/test/unit-minimal/_generated_google.tf +++ b/test/unit-minimal/_generated_google.tf @@ -2,7 +2,8 @@ // TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl variable "gcp_project" { - description = "(Required) The ID of the project in which the resource belongs." + default = null + description = "(Optional) The ID of the project in which the resource belongs." type = string } variable "gcp_region" { @@ -16,7 +17,7 @@ variable "gcp_org_domain" { type = string } variable "gcp_billing_account" { - default = null + default = "test-billing-account" description = "(Optional) The billing account to use when creating projects." type = string } @@ -26,6 +27,10 @@ terraform { source = "hashicorp/google" version = "4.4" } + google-beta = { + source = "hashicorp/google-beta" + version = "4.4" + } random = { source = "hashicorp/random" version = "~> 3.1" @@ -36,6 +41,10 @@ provider "google" { project = var.gcp_project region = var.gcp_region } +provider "google-beta" { + project = var.gcp_project + region = var.gcp_region +} provider "random" { } resource "random_id" "suffix" { @@ -43,17 +52,20 @@ resource "random_id" "suffix" { count = local.test_name != "unit-disabled" ? 1 : 0 } data "google_project" "project" { + count = var.gcp_project != null ? 1 : 0 + project_id = var.gcp_project } data "google_organization" "org" { - count = local.org_domain != null ? 1 : 0 - domain = local.org_domain + count = var.gcp_org_domain != null ? 1 : 0 + domain = var.gcp_org_domain } locals { - billing_account = var.gcp_billing_account - org_domain = var.gcp_org_domain - org_id = try(data.google_organization.org[0].name, null) - project_id = var.gcp_project - project_number = data.google_project.project.number - random_suffix = try(random_id.suffix[0].hex, "disabled") - test_name = "unit-minimal" + billing_account = var.gcp_billing_account + directory_customer_id = try(data.google_organization.org[0].directory_customer_id, "no-directoy-customer") + org_domain = try(data.google_organization.org[0].domain, "no-domain.mineiros.io") + org_id = try(data.google_organization.org[0].org_id, null) + project_id = try(data.google_project.project[0].project_id, "no-project") + project_number = try(data.google_project.project[0].number, null) + random_suffix = try(random_id.suffix[0].hex, "disabled") + test_name = "unit-minimal" } diff --git a/versions.tf b/versions.tf index 9244c60..ac0c279 100644 --- a/versions.tf +++ b/versions.tf @@ -1,6 +1,8 @@ -terraform { - required_version = "~> 1.0" +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT +// TERRAMATE: originated from generate_hcl block on /terramate.tm.hcl +terraform { + required_version = "~> 1.0, != 1.1.0, != 1.1.1" required_providers { google = { source = "hashicorp/google" diff --git a/versions.tm.hcl b/versions.tm.hcl new file mode 100644 index 0000000..ce9fce8 --- /dev/null +++ b/versions.tm.hcl @@ -0,0 +1,11 @@ +globals { + minimum_terraform_version = "1.0" + + provider = "google" + minimum_provider_version = "4.4" + + provider_version_constraint = "~> ${global.minimum_provider_version}" + terraform_version_constraint = "~> ${global.minimum_terraform_version}, != 1.1.0, != 1.1.1" + # we exclude 1.1.0 and 1.1.1 because of: + # https://github.com/hashicorp/terraform/blob/v1.1/CHANGELOG.md#112-december-17-2021 +}