Skip to content

Commit 0b0b7f3

Browse files
authored
PLT-2137: Fix for Terraform plan shows persistent drift for spectrocloud_cluster_aws machine_pool (#806)
* Adding the fix for drift issue due to skip_k8s_upgrade * Adding the change in unit test * Adding the changes in template for virtual cluster documentation * Adding the template changes for import
1 parent 3aab533 commit 0b0b7f3

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

docs/resources/virtual_cluster.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ resource "spectrocloud_virtual_cluster" "cluster" {
4646
4747
```
4848

49+
## Import
50+
51+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import)
52+
to import the resource spectrocloud_virtual_cluster by using its `id` with the Palette `context` separated by a colon. For example:
53+
54+
```terraform
55+
import {
56+
to = spectrocloud_virtual_cluster.example
57+
id = "example_id:context"
58+
}
59+
```
60+
61+
Using `terraform import`, import the cluster using the `cluster_name` or `id` colon separated with `context`. For example:
62+
63+
```console
64+
terraform import spectrocloud_virtual_cluster.example example_id
65+
```
66+
67+
```console
68+
terraform import spectrocloud_virtual_cluster.example cluster_name
69+
```
70+
71+
Refer to the [Import section](/docs#import) to learn more.
4972

5073
<!-- schema generated by tfplugindocs -->
5174
## Schema

spectrocloud/resource_cluster_aws.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,11 @@ func flattenMachinePoolConfigsAws(machinePools []*models.V1AwsMachinePoolConfig)
529529
oi["max_price"] = machinePool.SpotMarketOptions.MaxPrice
530530
}
531531
// Flatten skip_k8s_upgrade (worker pools only); default "disabled" for backward compat when API omits field
532+
skipK8sUpgrade := "disabled"
532533
if machinePool.SkipK8sUpgrade != nil && *machinePool.SkipK8sUpgrade != "" {
533-
oi["skip_k8s_upgrade"] = *machinePool.SkipK8sUpgrade
534+
skipK8sUpgrade = *machinePool.SkipK8sUpgrade
534535
}
536+
oi["skip_k8s_upgrade"] = skipK8sUpgrade
535537
oi["disk_size_gb"] = int(machinePool.RootDeviceSize)
536538
if machinePool.SubnetIds != nil {
537539
oi["az_subnets"] = machinePool.SubnetIds

spectrocloud/resource_cluster_aws_flatten_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func TestFlattenMachinePoolConfigsAws(t *testing.T) {
5858
"max": 5,
5959
"instance_type": "t2.micro",
6060
"disk_size_gb": 8,
61+
"skip_k8s_upgrade": "disabled",
6162
"az_subnets": map[string]string{"us-west-2d": "subnet-87654321"},
6263
"update_strategy": "RollingUpdateScaleOut",
6364
"additional_security_groups": []string{"sg-1234567890"},

templates/resources/virtual_cluster.md.tmpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,28 @@ resource "spectrocloud_virtual_cluster" "cluster" {
4646
4747
```
4848

49+
## Import
50+
51+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import)
52+
to import the resource {{ .Name }} by using its `id` with the Palette `context` separated by a colon. For example:
53+
54+
```terraform
55+
import {
56+
to = {{ .Name }}.example
57+
id = "example_id:context"
58+
}
59+
```
60+
61+
Using `terraform import`, import the cluster using the `cluster_name` or `id` colon separated with `context`. For example:
62+
63+
```console
64+
terraform import {{ .Name }}.example example_id
65+
```
66+
67+
```console
68+
terraform import {{ .Name }}.example cluster_name
69+
```
70+
71+
Refer to the [Import section](/docs#import) to learn more.
4972

5073
{{ .SchemaMarkdown | trimspace }}

0 commit comments

Comments
 (0)