gridscale / terraform-provider-gridscale

Terraform gridscale provider
https://registry.terraform.io/providers/gridscale/gridscale/latest/docs
Mozilla Public License 2.0
12 stars 11 forks source link

gridscale_storage : modify or change of eg. capacity for existing storage not possible #224

Open DennisPohlig opened 1 year ago

DennisPohlig commented 1 year ago

Hi there,

I have issues when trying to modify storage in gridscale via terraform. Maybe I have overseen some documentation or maybe there is actual no implementation for this task.

Terraform Version

Terraform v1.3.9 on linux_amd64 provider registry.terraform.io/gridscale/gridscale v1.17.0

Affected Resource(s)

Terraform Configuration Files

Creating of Resources works:

resource "gridscale_server" "Demo-Server" {
  name   = "Demo-Server"
  cores  = 1
  memory = 2
  auto_recovery = true
  power = false
  storage {
    object_uuid = gridscale_storage.demo-storage.id
  }
}

resource "gridscale_storage" "demo-storage" {
 name = "demo-storage"
 capacity = 10
 storage_type = "storage"
  template {
    template_uuid = data.gridscale_template.Ubuntu.id
    hostname = "Demo-Server"
    password = "Password123"
    password_type = "plain"
  }
}

data "gridscale_template" "Ubuntu" {
  name = "Ubuntu 22.04 LTS (Jammy Jellyfish) "
}

Adding existing Storage to a Server works:

resource "gridscale_server" "Demo-Server" {
  name   = "Demo-Server"
  cores  = 1
  memory = 2
  auto_recovery = true
  power = false
  storage {
    object_uuid = gridscale_storage.demo-storage.id
  }
 storage {
   object_uuid = data.gridscale_storage.demo-storage2.id
 }
data "gridscale_storage" "demo-storage2" {
  resource_id = "6716d655-f271-4fb6-a89d-8bce4c81ba5f"
 }
}

Now changing the Storage Capacity will not work:

resource "gridscale_server" "Demo-Server" {
  name   = "Demo-Server"
  cores  = 1
  memory = 2
  auto_recovery = true
  power = false
  storage {
    object_uuid = gridscale_storage.demo-storage.id
  }
 storage {
   object_uuid = data.gridscale_storage.demo-storage2.id
 }
 storage {
   object_uuid = data.gridscale_storage.demo-storage2.id
 }
}

resource "gridscale_storage" "demo-storage2" {
 name = "demo-storage2"
 capacity = 20 (changed from 10 to 20)
 storage_type = "storage"
  }

Expected Behavior

Changing the capacity in the Terraform configuration should result in a change of the real storage.

Actual Behavior

Modifying the "demo-storage2" is not possible, as Terraform would like to create some new storage even though it has the same name as the attached storage or does not accept the UUID of the Storage as a Parameter (Which works as intended following the docs).

Is there any way of modifying or changing parameters of the storage like capacity with terraform?

nvthongswansea commented 1 year ago

Hi. According to your config, I see that you tried to modify a datasource which is not allowed to be changed in terraform. Datasource is used to import source which is not managed by terraform. When using resource "gridscale_storage"."demo-storage2", terraform will create a new storage "demo-storage2" with given data, since it has no ideas what is going on outside of terraform state.

DennisPohlig commented 1 year ago

Ok I understand that. Is there any way to import such information so that terraform can handle that? Or is the result that I could import existing infrastructure only with lack of modifying possibilities?

nvthongswansea commented 1 year ago

@DennisPohlig At the moment, the data sources are not modifiable.

nvthongswansea commented 1 year ago

The main purpose of data source is to allow Terraform to use information defined outside of Terraform.