Skip to content
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

Modifying Space Id on an existing environment doesn't cause a replacement #639

Open
tleed5 opened this issue May 10, 2024 · 0 comments · May be fixed by #848
Open

Modifying Space Id on an existing environment doesn't cause a replacement #639

tleed5 opened this issue May 10, 2024 · 0 comments · May be fixed by #848
Labels
area/environments Issues about environments, lifecycles and channels

Comments

@tleed5
Copy link
Collaborator

tleed5 commented May 10, 2024

Describe the bug
Modifying the space_id on an environment resource doesn't trigger a replacement but Terraform instead tries to update the resource in place which fails with

│ Error: Octopus API error: Resource is not found or it doesn't exist in the current space context. Please contact your administrator for more information. []
│   with octopusdeploy_environment.env,
│   on main.tf line 37, in resource "octopusdeploy_environment" "env":
│   37: resource "octopusdeploy_environment" "env" {

Steps to reproduce

  1. Apply this TF
resource "octopusdeploy_space" "space" {
  name                 = "test space"
  space_managers_teams = ["teams-everyone"]
}

resource "octopusdeploy_environment" "env" {
  name     = "Env 1"
  space_id = octopusdeploy_space.space.id
}
  1. Update the TF to and re-apply
resource "octopusdeploy_space" "new_space" {
  name                 = "new test space"
  space_managers_teams = ["teams-everyone"]
}

resource "octopusdeploy_environment" "env" {
  name     = "Env 1"
  space_id = octopusdeploy_space.new_space.id
}

Expected behavior
Modifying the space_id on the environment triggers a replacement of the resource

Logs and other supporting information
Add the output of running tf plan or tf apply along with any errors in the Octopus Server logs.

Additional context
Work around - Use create_before_destroy lifecycle on the environment resources to force the replacement

resource "octopusdeploy_environment" "env" {
  name     = "Env 1"
  space_id = octopusdeploy_space.space.id
  lifecycle {
    create_before_destroy = true
  }
}
@domenicsim1 domenicsim1 added the area/environments Issues about environments, lifecycles and channels label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/environments Issues about environments, lifecycles and channels
Projects
None yet
2 participants