terraform-provider-spacelift icon indicating copy to clipboard operation
terraform-provider-spacelift copied to clipboard

Association resource for spaces

Open jkrzemin opened this issue 2 years ago • 1 comments

Currently the only method of setting one space as a child of other via terraform is to use an attribute parent_space_id.

This makes it impossible to reference the resource in single for each since terraform will report a cycle.

# variables.tf
variable "spaces" {
    description = "Map of spaces to create."
    default = {}
    type = map(object({
        name = string
        parent_key = optional(string, "root")
        description = optional(string)
        inherit_entities = optional(bool, false)
    }))
}

# main.tf
resource "spacelift_space" "space" {
  for_each = var.spaces
  name = each.value.name

  parent_space_id = spacelift_space.space[each.value.parent_key].id

  description = each.value.description
  inherit_entities = each.value.inherit_entities
}

If it would be possible to set such relation with association resource like https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs/resources/azure_integration_attachment then it enable usage of for loops in spaces creation.

jkrzemin avatar Jan 09 '23 11:01 jkrzemin