Skip to content

Project Factory with factory_data_path uses the each.key of the files to create the project names #1850

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

Closed
benjaminwestern opened this issue Nov 9, 2023 · 0 comments · Fixed by #1851
Assignees

Comments

@benjaminwestern
Copy link

Describe the bug
If the YAML files for the source directory are in a folder structure like:

  • env
    • production
      • warehouse.yaml

The each.key for the project name will be prefix-production/warehouse

This is only an issue due to us not being able to override the project name and or project id

Environment

output from `terraform -version`
Terraform v1.6.3
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.5.0
+ provider registry.terraform.io/hashicorp/google-beta v5.5.0
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/random v3.5.1

output from `git rev-parse --short HEAD`
de0325b

To Reproduce
Create a folder structure in your terraform repository like:

  • env (top level)
    • production (environment for separation)
      • warehouse.yaml

This will result in the project key being: prefix-production/warehouse which is an invalid project-id. It also isn't desirable to have the full folder name in the project name either.

Expected behavior
I would expect to be able to pass the project name and id in as data_overrides to allow for the immediate resolution of this, in combination with the ability for us to add our own suffixes etc to ensure unique project ids

Result

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: "mutd-production/test" project_id must be 6 to 30 with lowercase letters, digits, hyphens and start with a letter. Trailing hyphens are prohibited.
│ 
│   with module.project-factory.module.projects["production/test"].google_project.project[0],
│   on .terraform/modules/project-factory/modules/project/main.tf line 48, in resource "google_project" "project":
│   48:   project_id          = "${local.prefix}${var.name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants