OctopusDeployLabs / terraform-provider-octopusdeploy

Terraform Provider for Octopus Deploy :octopus:
https://registry.terraform.io/providers/OctopusDeployLabs/octopusdeploy
Mozilla Public License 2.0
81 stars 67 forks source link

resource id should be readonly. space name on datasource should be optional #770

Closed benPearce1 closed 1 month ago

benPearce1 commented 1 month ago

setup:

resource "octopusdeploy_lifecycle" "lifecycle" {
  id = "Lifecycles-1"
  space_id = data.octopusdeploy_space.space.id
  name = "lifecycle 2"
}

on 0.22.1

# octopusdeploy_lifecycle.lifecycle will be created
  + resource "octopusdeploy_lifecycle" "lifecycle" {
      + description = "description2"
      + id          = (known after apply)
      + name        = "lifecycle 2"
      + space_id    = "Spaces-1"
...

Lifecycle resource was created with id of Lifecycles-1762. From state:

"id": "Lifecycles-1762",
"name": "lifecycle 2",

Plan with 0.30.0-beta8

# octopusdeploy_lifecycle.lifecycle will be updated in-place
  ~ resource "octopusdeploy_lifecycle" "lifecycle" {
      ~ id          = "Lifecycles-1762" -> "Lifecycles-1"
        name        = "lifecycle 2"
        # (2 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Plan now fails validation as Id is readonly:

│ Error: Invalid Configuration for Read-Only Attribute
│ 
│   with octopusdeploy_lifecycle.lifecycle,
│   on main.tf line 32, in resource "octopusdeploy_lifecycle" "lifecycle":
│   32:   id = "Lifecycles-1"
│ 
│ Cannot set value for this attribute as the provider has marked it as read-only. Remove the configuration line setting the value.
│ 
│ Refer to the provider documentation or contact the provider developers for additional information about configurable and read-only attributes that are
│ supported.
╵