Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate 'parent_type' and 'parent_id' input variables #259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}-compute@developer.gserviceaccount.com"
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