Skip to content

Commit 5af74bf

Browse files
shivam-thakur12Harness
authored andcommitted
feat: [CCM-27683]: Call Delete Cluster Orchestrator API on terraform destroy (#1317)
* 28fcb3 use sdk version v0.6.4 * 6ef376 Call Delete Cluster Orchestrator API on terraform destroy
1 parent 0ac87e2 commit 5af74bf

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

docs/resources/cluster_orchestrator.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "harness_cluster_orchestrator Resource - terraform-provider-harness"
44
subcategory: "Next Gen"
55
description: |-
6-
Resource for creating ClusterOrchestrators.
6+
Resource for creating and deleting ClusterOrchestrators.
77
---
88

99
# harness_cluster_orchestrator (Resource)
1010

11-
Resource for creating ClusterOrchestrators.
11+
Resource for creating and deleting ClusterOrchestrators.
1212

1313
## Example Usage
1414

@@ -20,6 +20,15 @@ resource "harness_cluster_orchestrator" "test" {
2020
}
2121
```
2222

23+
## Lifecycle Operations
24+
25+
This resource supports the following lifecycle operations:
26+
27+
- **Create**: Creates a new cluster orchestrator in Harness CCM
28+
- **Delete**: Deletes the cluster orchestrator from Harness CCM
29+
30+
When you run `terraform destroy`, the cluster orchestrator will be permanently deleted from your Harness account.
31+
2332
<!-- schema generated by tfplugindocs -->
2433
## Schema
2534

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/aws/aws-sdk-go v1.46.4
1010
github.com/docker/docker v28.3.2+incompatible
1111
github.com/google/uuid v1.6.0
12-
github.com/harness/harness-go-sdk v0.6.3
12+
github.com/harness/harness-go-sdk v0.6.4
1313
github.com/harness/harness-openapi-go-client v0.0.25
1414
github.com/hashicorp/go-cleanhttp v0.5.2
1515
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
7878
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7979
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
8080
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
81-
github.com/harness/harness-go-sdk v0.6.3 h1:phdfV+C1sZe726ty5UBQTv2l4ToDcXLTqtG2XpMPzag=
82-
github.com/harness/harness-go-sdk v0.6.3/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
81+
github.com/harness/harness-go-sdk v0.6.4 h1:vo54sx8hYg14Td9rcwXDjrhV9jJEM3kQbhnjC34T0UY=
82+
github.com/harness/harness-go-sdk v0.6.4/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
8383
github.com/harness/harness-openapi-go-client v0.0.25 h1:s1ALpC6cCJCMBkEVPjAjyHTPEpBfPyV78TeXpp3CEoU=
8484
github.com/harness/harness-openapi-go-client v0.0.25/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
8585
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=

internal/service/platform/cluster_orchestrator/clusterorch_resource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,15 @@ func resourceClusterOrchestratorCreate(ctx context.Context, d *schema.ResourceDa
6363
}
6464

6565
func resourceClusterOrchestratorDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
66+
c, ctx := meta.(*internal.Session).GetPlatformClientWithContext(ctx)
67+
68+
orchestratorID := d.Id()
69+
70+
httpResp, err := c.CloudCostClusterOrchestratorApi.DeleteClusterOrchestrator(ctx, c.AccountId, orchestratorID)
71+
72+
if err != nil {
73+
return helpers.HandleApiError(err, d, httpResp)
74+
}
75+
6676
return nil
6777
}

0 commit comments

Comments
 (0)