Skip to content

Add disk_offering & override_disk_offering to instance resource - #208

Merged
kiranchavala merged 2 commits into
apache:mainfrom
shapeblue:add-diskoffering-instance-resource
Aug 29, 2025
Merged

kiranchavala merged 2 commits into
apache:mainfrom
shapeblue:add-diskoffering-instance-resource

Conversation

@vishesh92

Copy link
Copy Markdown
Member

Fixes #68
Changes in these fields is ignored as of now.

@vishesh92
vishesh92 requested a review from Copilot August 26, 2025 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for disk offering configuration in CloudStack instance resources by introducing two new optional parameters: disk_offering and override_disk_offering. These fields allow users to specify disk offerings for virtual machines when deploying from templates or ISO images.

Key changes:

  • Added two new optional fields to the instance resource schema with ForceNew behavior
  • Implemented parameter handling in the instance creation logic
  • Added documentation for the new fields explaining their usage with templates vs ISO images

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
website/docs/r/instance.html.markdown Added documentation for the new disk_offering and override_disk_offering parameters
cloudstack/resource_cloudstack_instance.go Added schema definitions and creation logic for the new disk offering fields

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread website/docs/r/instance.html.markdown Resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@kiranchavala kiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Tested manually

resource "cloudstack_instance" "web" {
  name             = "server-1"
  service_offering = "6bf9d0ab-49fd-4bae-937b-286f54532474"
  network_id       = "1eb73b50-1db5-42f5-8938-8592df101d61"
  template         = "CentOS 5.5(64-bit) no GUI (KVM)"
  zone             = "ref-trl-9219-k-Mol8-kiran-chavala"
  disk_offering    = "2c8a9190-3099-4598-95b1-19560bd40210"
  override_disk_offering = "90383b87-f8f9-419a-8b90-4e0a03898c25"
}

terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudstack_instance.web will be created
  + resource "cloudstack_instance" "web" {
      + disk_offering          = "2c8a9190-3099-4598-95b1-19560bd40210"
      + display_name           = (known after apply)
      + expunge                = false
      + group                  = (known after apply)
      + id                     = (known after apply)
      + ip_address             = (known after apply)
      + name                   = "server-1"
      + network_id             = "1eb73b50-1db5-42f5-8938-8592df101d61"
      + override_disk_offering = "90383b87-f8f9-419a-8b90-4e0a03898c25"
      + project                = (known after apply)
      + root_disk_size         = (known after apply)
      + service_offering       = "6bf9d0ab-49fd-4bae-937b-286f54532474"
      + start_vm               = true
      + tags                   = (known after apply)
      + template               = "CentOS 5.5(64-bit) no GUI (KVM)"
      + uefi                   = false
      + zone                   = "ref-trl-9219-k-Mol8-kiran-chavala"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudstack_instance.web: Creating...
cloudstack_instance.web: Still creating... [00m10s elapsed]
cloudstack_instance.web: Creation complete after 18s [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
╭─ ~/Desktop/cloudstack-India-demo/cloudstack-terraform copy                                                                                           ✔ ╱ 21s ╱ Azure subscription 1  ╱ 03:11:37 PM 
╰─ terraform destroy
cloudstack_instance.web: Refreshing state... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # cloudstack_instance.web will be destroyed
  - resource "cloudstack_instance" "web" {
      - disk_offering          = "90383b87-f8f9-419a-8b90-4e0a03898c25" -> null
      - display_name           = "server-1" -> null
      - expunge                = false -> null
      - id                     = "c132df8e-4e0d-4994-b0c1-ee6167aeae78" -> null
      - ip_address             = "10.1.1.212" -> null
      - name                   = "server-1" -> null
      - network_id             = "1eb73b50-1db5-42f5-8938-8592df101d61" -> null
      - override_disk_offering = "90383b87-f8f9-419a-8b90-4e0a03898c25" -> null
      - root_disk_size         = 20 -> null
      - service_offering       = "6bf9d0ab-49fd-4bae-937b-286f54532474" -> null
      - start_vm               = true -> null
      - tags                   = {} -> null
      - template               = "CentOS 5.5(64-bit) no GUI (KVM)" -> null
      - uefi                   = false -> null
      - zone                   = "ref-trl-9219-k-Mol8-kiran-chavala" -> null
        # (2 unchanged attributes hidden)
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

cloudstack_instance.web: Destroying... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78]
cloudstack_instance.web: Still destroying... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78, 00m10s elapsed]
cloudstack_instance.web: Still destroying... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78, 00m20s elapsed]
cloudstack_instance.web: Still destroying... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78, 00m30s elapsed]
cloudstack_instance.web: Still destroying... [id=c132df8e-4e0d-4994-b0c1-ee6167aeae78, 00m40s elapsed]
cloudstack_instance.web: Destruction complete after 48s

Destroy complete! Resources: 1 destroyed.

Screenshot 2025-08-29 at 3 12 53 PM

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@kiranchavala
kiranchavala merged commit 540f8d0 into apache:main Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Override root disk offering and Disk Offerings to cloudstack_instance Resource

4 participants