Skip to content
15 changes: 15 additions & 0 deletions docs/resources/appliance.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ resource "spectrocloud_appliance" "appliance" {
}
```

## Import

Appliances can be imported using the appliance UID. This is a project-level resource.

```bash
terraform import spectrocloud_appliance.example <appliance_uid>
```

Where `<appliance_uid>` is the appliance UID.

The import will automatically populate all configuration fields from the Spectro Cloud API, including the UID, tags, and tunnel configuration settings. The `wait` field will be set to `false` by default for imported appliances. After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.

**Note**: Since this is a project-level resource, ensure your provider is configured with appropriate project-level credentials and access.


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

Expand Down
10 changes: 10 additions & 0 deletions docs/resources/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ resource "spectrocloud_application" "application" {

```

## Import

Applications can be imported using their UID. The import will automatically detect the cluster context.

```bash
terraform import spectrocloud_application.example 63444eb70807dc2c14a8ad59
```

Note: During import, the application's configuration will be automatically populated from the Spectro Cloud API, including the correct cluster context.


<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
15 changes: 15 additions & 0 deletions docs/resources/application_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,21 @@ resource "spectrocloud_application_profile" "app_profile_all_tiers" {

```

```
## Import

# terraform import spectrocloud_application_profile.app_profile_all_tiers "profile_uid_here"
#
# Where:
# - profile_uid_here is the unique identifier of the application profile
#
# To import using import block:
# import {
# to = spectrocloud_application_profile.app_profile_all_tiers
# id = "profile_uid_here"
# }
```

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

Expand Down
27 changes: 27 additions & 0 deletions docs/resources/backup_storage_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ resource "spectrocloud_backup_storage_location" "bsl2" {
}
```

## Import

Backup Storage Locations can be imported using either a simple ID format or with explicit context specification. This resource supports both project and tenant contexts.

### Simple Import (defaults to project context)

```bash
terraform import spectrocloud_backup_storage_location.example <bsl_id>:project
```

### Context-specific Import

```bash
terraform import spectrocloud_backup_storage_location.example <bsl_id>:project
terraform import spectrocloud_backup_storage_location.example <bsl_id>:tenant
```

Where:
- `<bsl_id>` is the Backup Storage Location ID
- `project` or `tenant` specifies the context where the backup storage location exists

**Import behavior:**
- If no context is specified, it defaults to `project` context
- If the resource is not found in the specified context, the import will automatically try the other context
- The import will automatically populate all configuration fields from the Spectro Cloud API, including the correct context, storage provider, and all provider-specific settings

After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.


<!-- schema generated by tfplugindocs -->
Expand Down
19 changes: 19 additions & 0 deletions docs/resources/cluster_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ resource "spectrocloud_cluster_group" "cg" {

```

## Import

In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import)
to import the resource spectrocloud_cluster_group by using its `id` with the Palette `context` separated by a colon. For example:

```terraform
import {
to = spectrocloud_cluster_group.example
id = "example_id:context"
}
```

Using `terraform import`, import the cluster group using the `id` colon separated with `context`. For example:

```console
terraform import spectrocloud_cluster_group.example example_id:project
```

Refer to the [Import section](/docs#import) to learn more.

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
17 changes: 17 additions & 0 deletions docs/resources/privatecloudgateway_dns_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ An example of creating an DNS Map for a Private Cloud Gateway using a search dom
}
```

## Import

Private Cloud Gateway DNS maps can be imported using the composite ID format: `pcg_id:dns_map_id`. This is a tenant-level resource.

```bash
terraform import spectrocloud_privatecloudgateway_dns_map.example <pcg_id>:<dns_map_id>
```

Where:
- `<pcg_id>` is the Private Cloud Gateway ID
- `<dns_map_id>` is the DNS map ID

The import will automatically populate all configuration fields from the Spectro Cloud API, including the associated Private Cloud Gateway ID, search domain name, data center, and network. After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.

**Note**: Since this is a tenant-level resource, ensure your provider is configured with appropriate tenant-level credentials and access.


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

Expand Down
16 changes: 16 additions & 0 deletions docs/resources/privatecloudgateway_ippool.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ An example of creating an IP Pool for a Private Cloud Gateway using a subnet of
}
```

## Import

Private Cloud Gateway IP pools can be imported using the composite ID format: `pcg_id:ippool_id`. This is a tenant-level resource.

```bash
terraform import spectrocloud_privatecloudgateway_ippool.example <pcg_id>:<ippool_id>
```

Where:
- `<pcg_id>` is the Private Cloud Gateway ID
- `<ippool_id>` is the IP Pool ID

The import will automatically populate all configuration fields from the Spectro Cloud API. After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.

**Note**: Since this is a tenant-level resource, ensure your provider is configured with appropriate tenant-level credentials and access.


<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
14 changes: 14 additions & 0 deletions docs/resources/registry_helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ resource "spectrocloud_registry_helm" "r1" {
}
```

## Import

Helm registries can be imported using the registry ID. This is a tenant-level resource.

```bash
terraform import spectrocloud_registry_helm.example <registry_id>
```

Where `<registry_id>` is the Helm registry ID.

The import will automatically populate all configuration fields from the Spectro Cloud API, including the name, endpoint, privacy setting, and authentication credentials. After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.

**Note**: Since this is a tenant-level resource, ensure your provider is configured with appropriate tenant-level credentials and access.


<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
14 changes: 14 additions & 0 deletions docs/resources/registry_oci.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ resource "spectrocloud_registry_oci" "r1" {
}
```

## Import

OCI registries can be imported using the registry ID. This is a tenant-level resource.

```bash
terraform import spectrocloud_registry_oci.example <registry_id>
```

Where `<registry_id>` is the OCI registry ID.

The import will automatically detect whether the registry is an ECR or basic type and populate all configuration fields from the Spectro Cloud API. After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.

**Note**: Since this is a tenant-level resource, ensure your provider is configured with appropriate tenant-level credentials and access.


<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
28 changes: 28 additions & 0 deletions docs/resources/ssh_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ resource "spectrocloud_ssh_key" "primary_key_1" {
}
```

## Import

SSH keys can be imported using either a simple ID format or with explicit context specification. This resource supports both project and tenant contexts.

### Simple Import (defaults to project context)

```bash
terraform import spectrocloud_ssh_key.example <ssh_key_id>
```

### Context-specific Import

```bash
terraform import spectrocloud_ssh_key.example <ssh_key_id>:project
terraform import spectrocloud_ssh_key.example <ssh_key_id>:tenant
```

Where:
- `<ssh_key_id>` is the SSH key ID
- `project` or `tenant` specifies the context where the SSH key exists

**Import behavior:**
- If no context is specified, it defaults to `project` context
- If the resource is not found in the specified context, the import will automatically try the other context
- The import will automatically populate all configuration fields from the Spectro Cloud API, including the correct context, name, and SSH key content

After import, you can run `terraform plan` to see the current configuration and make any necessary adjustments.


<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
7 changes: 7 additions & 0 deletions examples/resources/spectrocloud_alert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ resource "spectrocloud_alert" "alert_http" {
type = "http"
alert_all_users = true
}

# Import example:
# terraform import spectrocloud_alert.alert_email "alertUid:ClusterHealth"
#
# Where:
# - alertUid is the unique identifier of the alert
# - ClusterHealth is the component type
12 changes: 12 additions & 0 deletions examples/resources/spectrocloud_application_profile/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,15 @@ resource "spectrocloud_application_profile" "app_profile_all_tiers" {
}
}
}

# Import example:
# terraform import spectrocloud_application_profile.app_profile_all_tiers "profile_uid_here"
#
# Where:
# - profile_uid_here is the unique identifier of the application profile
#
# To import using import block:
# import {
# to = spectrocloud_application_profile.app_profile_all_tiers
# id = "profile_uid_here"
# }
10 changes: 9 additions & 1 deletion examples/resources/spectrocloud_cluster_group/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ resource "spectrocloud_cluster_group" "cg" {
host_dns = "*.dev.spectrocloud.com"
}

}
}

# terraform import spectrocloud_cluster_group.cg "cluster_group_id:tenant"

# Or using the import block (Terraform 1.5+):
# import {
# to = spectrocloud_cluster_group.cg
# id = "cluster_group_id:context"
# }
3 changes: 3 additions & 0 deletions spectrocloud/resource_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func resourceAlert() *schema.Resource {
ReadContext: resourceAlertRead,
UpdateContext: resourceAlertUpdate,
DeleteContext: resourceAlertDelete,
Importer: &schema.ResourceImporter{
StateContext: resourceAlertImport,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Expand Down
37 changes: 37 additions & 0 deletions spectrocloud/resource_alert_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package spectrocloud

import (
"context"
"fmt"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func resourceAlertImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
c := getV1ClientWithResourceContext(m, "tenant")
idParts := strings.Split(d.Id(), ":")
if len(idParts) != 2 {
return nil, fmt.Errorf("invalid import ID format, expected 'alertUid:component', got: %s", d.Id())
}
alertUid := idParts[0]
component := idParts[1]
pjt, err := c.GetProject(ProviderInitProjectUid)
if err != nil {
return nil, err
}
if err := d.Set("project", pjt.Metadata.Name); err != nil {
return nil, err
}
if err := d.Set("component", component); err != nil {
return nil, err
}
d.SetId(alertUid)
// Read all alert data to populate the state
diags := resourceAlertRead(ctx, d, m)
if diags.HasError() {
return nil, fmt.Errorf("could not read alert for import: %v", diags)
}

return []*schema.ResourceData{d}, nil
}
8 changes: 6 additions & 2 deletions spectrocloud/resource_appliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"errors"
"fmt"
"log"
"time"

"github.com/go-openapi/strfmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/spectrocloud/palette-sdk-go/api/apiutil/transport"
"log"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"

Expand All @@ -25,6 +26,9 @@ func resourceAppliance() *schema.Resource {
ReadContext: resourceApplianceRead,
UpdateContext: resourceApplianceUpdate,
DeleteContext: resourceApplianceDelete,
Importer: &schema.ResourceImporter{
StateContext: resourceApplianceImport,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Expand Down
Loading