spacelift-io / terraform-provider-spacelift

Terraform provider to interact with Spacelift
MIT License
74 stars 28 forks source link

Error "could not update space: unauthorized - is it an administrative stack in the root space?" #424

Closed nitrocode closed 1 month ago

nitrocode commented 1 year ago

From this terraform plan change within an admin stack run

  # module.spacelift.module.stacks["gbl-corp-infrastructure-snip"].spacelift_space.default[0] will be updated in-place
  ~ resource "spacelift_space" "default" {
        id               = "infrastructure-snip"
      ~ labels           = [
          - "deps:stacks/orgs/snip/mgmt/_defaults.yaml",
            # (8 unchanged elements hidden)
        ]
        name             = "infrastructure-snip"
        # (2 unchanged attributes hidden)
    }

We receive this error when trying to update a spacelift_space in terraform.

╷
│ Error: could not update space: unauthorized - is it an administrative stack in the root space?
│ 
│   with module.spacelift.module.stacks["gbl-corp-infrastructure-snip"].spacelift_space.default[0],
│   on .terraform/modules/spacelift/modules/stack/main.tf line 221, in resource "spacelift_space" "default":
│  221: resource "spacelift_space" "default" {
│ 

The spacelift space was created by terraform but it cannot be modified with terraform. I'm unsure if this is a spacelift terraform issue or a spacelift API issue, or maybe even a permissions issue.

The spacelift space is called flex and it's part of the infrastructure space which inherits from the root space.

The workaround was to no-op the terraform by clickops'ing the change within Spacelift.

references

AtzeDeVries commented 1 year ago

Also got into this issue, but according to docs to manage spaces the stack needs to be in the root space https://docs.spacelift.io/concepts/spaces/access-control#roles

Yantrio commented 1 month ago

closing as this was answered by @AtzeDeVries , please feel free to re-open if you are still hitting issues.

sosimon commented 4 weeks ago

In case anyone else runs into this issue - this error is also thrown when you mistakenly use the Spacelift Space name instead for the Space ID when creating stacks 😅