spacelift-io/terraform-provider-spacelift

In `spacelift_module`, if `name` and `terraform_provider` are set, the resulting `id` is just the `name`

Closed this issue · 2 comments

Example 1:

We are trying to use something like the following:

resource "spacelift_module" "module" {
  administrative       = false
  branch               = "main"
  repository           = "terraform-provider-module-name"
  terraform_provider   = "provider"
  name                 = "module-name"
  labels               = [local.modules_label]
  space_id             = "root"
  enable_local_preview = true
  worker_pool_id       = local.worker_pool_id
}

In this case, the resulting spacelift_module.module.id is module-name and is available at https://ourorg.app.spacelift.io/module/module-name.


Example 2:

When we don't provide the terraform_provider and name i.e.

resource "spacelift_module" "module" {
  administrative       = false
  branch               = "main"
  repository           = "terraform-provider-module-name"
  labels               = [local.modules_label]
  space_id             = "root"
  enable_local_preview = true
  worker_pool_id       = local.worker_pool_id
}

then, the resulting spacelift_module.module.id is terraform-provider-module-name and is available at https://ourorg.app.spacelift.io/module/terraform-provider-module-name.


In example 1 above, I would expect the id to be a combination of terraform_provider and name and not just the name.

The above examples are simplified version of our real use-case. In our real use-case, we want to be able to create different modules from different branches (dev version from dev branch and production version from main).

This is indeed how the backend behaves.
I am however struggling to see how this ID assignment logic can be problematic in practice.
Can you please elaborate on the practical implications of this choice?

The default behavior has been updated to add the prefix to the ID.