linode / terraform-provider-linode

Terraform Linode provider
https://www.terraform.io/docs/providers/linode/
Mozilla Public License 2.0
202 stars 98 forks source link

fix: Instance state has placement groups by default #1619

Closed ezilber-akamai closed 1 month ago

ezilber-akamai commented 1 month ago

📝 Description

Fixed issue causing an empty list of placement groups gets added to the instance state, even when none are defined.

✔️ How to Test

The following steps assume that you pulled down this PR locally.

First, verify that instance-related integration tests are passing, i.e. make PKG_NAME=linode/instance ARGS="-run TestAccDataSourceInstances_basic" int-test

  1. Generate a compliant firewall in Cloud Manager.
  2. Initialize terraform in a sandbox environment, i.e. dx-devenv.
  3. Create a placement group and instance resource with the firewall's id, and assign the instance to that PG
    
    resource "linode_placement_group" "test" {
    label = "my-placement-group"
    region = "us-mia"
    placement_group_type = "anti_affinity:local"
    }

resource "linode_instance" "foobar" { label = "test-tf-instance" type = "g6-standard-1" region = "us-mia" image = "linode/alpine3.19" firewall_id = placement_group { id = linode_placement_group.test.id } }


4. Go to Cloud Manager and unassign the instance from the PG
5. Run `make plan` and verify that there is an update in-place to add the instance back to the PG
6. Destroy all resources created for this test
ykim-akamai commented 1 month ago

Integration tests on linode/instance - https://github.com/linode/terraform-provider-linode/actions/runs/11369649792/job/31627587646