Skip to content

Commit

Permalink
Merge pull request #259 from averbuks/averbukh-issue-258
Browse files Browse the repository at this point in the history
Deprecate 'parent_type' and 'parent_id' input variables
  • Loading branch information
morgante authored Aug 14, 2019
2 parents d6ddc4e + 2ccc94b commit 9b53e8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 2 additions & 4 deletions modules/fabric-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Basic usage of this module is as follows:
```hcl
module "project_myproject" {
source = "terraform-google-modules/project-factory/google//modules/fabric-project"
parent_id = "1234567890"
parent_type = "folder"
parent = "folders/1234567890"
billing_account = "ABCD-1234-ABCD-1234"
prefix = "staging"
name = "myproject"
Expand Down Expand Up @@ -50,8 +49,7 @@ module "project_myproject" {
| oslogin\_admins | List of IAM-format members that will get OS Login admin role. | list | `<list>` | no |
| oslogin\_users | List of IAM-format members that will get OS Login user role. | list | `<list>` | no |
| owners | Optional list of IAM-format members to set as project owners. | list | `<list>` | no |
| parent\_id | Id of the resource under which the folder will be placed. | string | n/a | yes |
| parent\_type | Type of the parent resource, defaults to organization. | string | `"organization"` | no |
| parent | The resource name of the parent Folder or Organization. Must be of the form folders/folder_id or organizations/org_id | string | n/a | yes |
| prefix | Prefix used to generate project id and name | string | n/a | yes |
| viewers | Optional list of IAM-format members to set as project viewers. | list | `<list>` | no |

Expand Down
6 changes: 4 additions & 2 deletions modules/fabric-project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ locals {
num_oslogin_users = length(var.oslogin_users) + length(var.oslogin_admins)
gce_service_account = "${google_project.project.number}[email protected]"
gke_service_account = "service-${google_project.project.number}@container-engine-robot.iam.gserviceaccount.com"
parent_type = split("/", var.parent)[0]
parent_id = split("/", var.parent)[1]
}

resource "google_project" "project" {
org_id = var.parent_type == "organization" ? var.parent_id : ""
folder_id = var.parent_type == "folder" ? var.parent_id : ""
org_id = local.parent_type == "organizations" ? local.parent_id : ""
folder_id = local.parent_type == "folders" ? local.parent_id : ""
project_id = "${var.prefix}-${var.name}"
name = "${var.prefix}-${var.name}"
billing_account = var.billing_account
Expand Down
9 changes: 2 additions & 7 deletions modules/fabric-project/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
* limitations under the License.
*/

variable "parent_id" {
description = "Id of the resource under which the folder will be placed."
}

variable "parent_type" {
description = "Type of the parent resource, defaults to organization."
default = "organization"
variable "parent" {
description = "The resource name of the parent Folder or Organization. Must be of the form folders/folder_id or organizations/org_id"
}

variable "prefix" {
Expand Down

0 comments on commit 9b53e8c

Please sign in to comment.