terraform-google-modules / terraform-google-project-factory

Creates an opinionated Google Cloud project by using Shared VPC, IAM, and Google Cloud APIs
https://registry.terraform.io/modules/terraform-google-modules/project-factory/google
Apache License 2.0
826 stars 535 forks source link

Can't specify folder_id. #195

Closed mikhail-khodorovskiy closed 5 years ago

mikhail-khodorovskiy commented 5 years ago
module "host-project" {
  source            = "terraform-google-modules/project-factory/google"
  random_project_id = true
  name              = "${local.host_project_name}"
  billing_account   = "${var.billing_account}"
  auto_create_network = false
  group_name = "${var.sysadmingroup}"
  labels = "${var.labels}"
  folder_id = "${var.folder_id}"
  # org_id = "${var.org_id}
}

When both org_id and folder_id are specified:

When org_id is not specified: module "host-project": missing required argument "org_id"

How can I create a project in a folder?

iniinikoski commented 5 years ago

Hi @mikhail-khodorovskiy,

Interesting... I'm able to create projects into folder - no error like yours happening...

Using the latest factory with latest TF version (0.11.14)...

mikhail-khodorovskiy commented 5 years ago

I was also passing domain. When I stopped doing that, the error went away.

From: Iiro Niinikoski notifications@github.com Reply-To: terraform-google-modules/terraform-google-project-factory reply@reply.github.com Date: Monday, May 20, 2019 at 9:16 AM To: terraform-google-modules/terraform-google-project-factory terraform-google-project-factory@noreply.github.com Cc: "Khodorovskiy, Mikhail" Mikhail.Khodorovskiy@cambiahealth.com, Mention mention@noreply.github.com Subject: [Marketing Mail] Re: [terraform-google-modules/terraform-google-project-factory] Can't specify folder_id. (#195)

This message is from an EXTERNAL email address - Please only click links and attachments if you're sure they are safe.


Hi @mikhail-khodorovskiyhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmikhail-khodorovskiy&data=02%7C01%7CMikhail.Khodorovskiy%40cambiahealth.com%7Ccb72f659fe684088b42508d6dd3e79c3%7Ce964274919d44f7fb4df802b2b75a809%7C0%7C0%7C636939657740971390&sdata=puV23oUeeKi%2Bu3ckfXYFZMNo6sl%2FFbamIAZv8lz4Wzg%3D&reserved=0,

Interesting... I'm able to create projects into folder - no error like yours happening...

Using the latest factory with latest TF version (0.11.14)...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fterraform-google-project-factory%2Fissues%2F195%3Femail_source%3Dnotifications%26email_token%3DAKV7KDTOGDLXIADYRQKS6LDPWLFDDA5CNFSM4HLV2ERKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVZKYXI%23issuecomment-494054493&data=02%7C01%7CMikhail.Khodorovskiy%40cambiahealth.com%7Ccb72f659fe684088b42508d6dd3e79c3%7Ce964274919d44f7fb4df802b2b75a809%7C0%7C0%7C636939657740981398&sdata=UTpUiDo98ICAdX1WX7iDcqK%2BSRVtukR6MuMT2Q8kPzM%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKV7KDVO7UZ57LF6HAE4EHDPWLFDDANCNFSM4HLV2ERA&data=02%7C01%7CMikhail.Khodorovskiy%40cambiahealth.com%7Ccb72f659fe684088b42508d6dd3e79c3%7Ce964274919d44f7fb4df802b2b75a809%7C0%7C0%7C636939657740981398&sdata=2jy3d661OOLLsNlFekMj6G6T6ZzP9jhbXJsWmZyB1nI%3D&reserved=0.

Ensure a sustainable future - only print when necessary.

IMPORTANT NOTICE: This communication, including any attachment, contains information that may be confidential or privileged, and is intended solely for the entity or individual to whom it is addressed. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message is strictly prohibited. Nothing in this email, including any attachment, is intended to be a legally binding signature.

aaron-lane commented 5 years ago

@mikhail-khodorovskiy can you please confirm which version of the module you are using?

ingwarr commented 5 years ago

@mikhail-khodorovskiy

module "host-project" {
  source            = "terraform-google-modules/project-factory/google"
  random_project_id = true
  name              = "${local.host_project_name}"
  billing_account   = "${var.billing_account}"
  auto_create_network = false
  group_name = "${var.sysadmingroup}"
  labels = "${var.labels}"
  folder_id = "${var.folder_id}"
  # org_id = "${var.org_id}
}

When both org_id and folder_id are specified:

  • google_project.main: 'org_id' and 'folder_id' cannot be both set. How can I create a project in a folder?

Could you please provide me with the path to reproduce this issue. I can't reproduce it in my environment. All looking good and I can create a project in a folder and without folder.

When org_id is not specified: module "host-project": missing required argument "org_id"

Variable org_id is a mandatory parameter, so it is proper behavior.

neodani commented 5 years ago

Same error I'm using Terraform v0.11.14 and this version module 2.4.1

Any idea how to solve? if I have to increase terraform version or module version? Thanks!

module "project-1" {
  source            = "terraform-google-modules/project-factory/google"
  version           = "2.4.1"

  name              = "${var.host_project_id}"
  credentials_path  = "${var.credentials_file_path}"
  random_project_id = "false"

  activate_apis = [
    "compute.googleapis.com",
    "cloudbilling.googleapis.com",
    "storage-api.googleapis.com",
    "sourcerepo.googleapis.com",
    "monitoring.googleapis.com",
    "logging.googleapis.com"
  ]

  folder_id              = "${var.folder_ops_networking}"
  org_id              = "${var.organization_id}"
  auto_create_network = "false"
  billing_account     = "${var.billing_account_id}"
}

1 error occurred:

morgante commented 5 years ago

@neodani Can you try using the latest module version with Terraform 0.12? Specifying a folder works for me:

module "project-prod-morgantep" {
  source  = "terraform-google-modules/project-factory/google"
  version = "~> 3.0"

  name              = "clf-morgantep-prod2"
  folder_id         = google_folder.prod.name
  org_id            = var.organization_id

  billing_account   = var.billing_account

  activate_apis = [
    "compute.googleapis.com",
    "container.googleapis.com",
  ]
}

Terraform version info:

Terraform v0.12.5
+ provider.google v2.11.0
+ provider.google-beta v2.11.0
+ provider.null v2.1.2
+ provider.random v2.1.2