Skip to content

Commit

Permalink
PLT-909: Import operation documentation. (#411)
Browse files Browse the repository at this point in the history
* PLT-909: Import operation documentation.

* Update templates/resources/cluster_profile.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/resources/cluster_profile.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/resources/cluster_aks.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* PLT-909: Import operation documentation addressing review comments.

* Apply suggestions from code review

Co-authored-by: Karl Cardenas <[email protected]>

* PLT-909: Import operation documentation addressing review comments.

* Update templates/resources/cluster_maas.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/index.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/resources/cluster_edge_native.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/index.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/resources/cluster_aws.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/index.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* Update templates/index.md.tmpl

Co-authored-by: Karl Cardenas <[email protected]>

* PLT-909: Addressing review comments.

---------

Co-authored-by: Karl Cardenas <[email protected]>
  • Loading branch information
nikchern and karl-cardenas-coding authored Jan 7, 2024
1 parent 32b73e1 commit c584bdf
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 6 deletions.
65 changes: 65 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,71 @@ export SPECTROCLOUD_APIKEY=5b7aad.........
provider "spectrocloud" {}
```

## Import
Starting with Terraform v1.5.0 and later, you can use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import resources into your state file.

Each resource type has its own specific requirements for the import process. We recommend you refer to the documentation for each resource to better understand the exact format of the `id` and any other required parameters.
The `import` block specifies the resource you want to import and its unique identifier with the following structure:

```terraform
import {
to = <resource>.<name>
id = "<unique_identifier>"
}
```

- `<resource>`: The type of the resource you are importing.
- `<name>`: A name you assign to the resource within your Terraform configuration.
- `<unique_identifier>`: The ID of the resource you are importing. This can include additional context if required.

### Examples
The following examples showcase how to import a resource. Some resource requires the context to be specified during the import action. The context refers to the Palette scope. Allowed values are either `project` or `tenant`.

#### Import With Context

When importing resources that require additional context, the `id` is followed by a context, separated by a colon.
```terraform
import {
to = spectrocloud_cluster_aks.example
id = "example_id:project"
}
```
You can also import a resource using the Terraform CLI and the `import` command.
```console
terraform import spectrocloud_cluster_aks.example example_id:project
```

Specify' tenant' after the colon if you want to import a resource at the tenant scope.

```terraform
import {
to = spectrocloud_cluster_aks.example
id = "example_id:tenant"
}
```
Example of importing a resource with the tenant context through the Terraform CLI.
```console
terraform import spectrocloud_cluster_aks.example example_id:tenant
```
~> Ensure you have tenant admin access when importing a resource at the tenant scope.

#### Import Without Context

For resources that do not require additional context, the `id` is the only provided argument. The following is an example of a resource that does not require the context and only provides the ID.

```terraform
import {
to = spectrocloud_cluster_profile.example
id = "id"
}
```
Below is an example of using the Terraform CLI and the `import` command without specifying the context.
```console
terraform import spectrocloud_cluster_profile.example id
```



## Support

For questions or issues with the provider, please post your questions on the
Expand Down
19 changes: 19 additions & 0 deletions docs/resources/cluster_aks.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ resource "spectrocloud_cluster_aks" "cluster" {
}
```

## 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_aks by using its `id` with the Palette `context` separated by a colon. For example:

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

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

```console
% terraform import spectrocloud_cluster_aks.example example_id:project
```

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
21 changes: 20 additions & 1 deletion docs/resources/cluster_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ resource "spectrocloud_cluster_aws" "cluster" {
}
```

## 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_aws by using its `id` with the Palette `context` separated by a colon. For example:

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

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

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

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -363,4 +382,4 @@ Read-Only:
- `latitude` (Number)
- `longitude` (Number)
- `region_code` (String)
- `region_name` (String)
- `region_name` (String)
21 changes: 20 additions & 1 deletion docs/resources/cluster_edge_native.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ description: |-



## 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_edge_native by using its `id` with the Palette `context` separated by a colon. For example:

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

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

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

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -260,4 +279,4 @@ Optional:

- `create` (String)
- `delete` (String)
- `update` (String)
- `update` (String)
21 changes: 20 additions & 1 deletion docs/resources/cluster_maas.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ resource "spectrocloud_cluster_maas" "cluster" {
}
```

## 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_maas by using its `id` with the Palette `context` separated by a colon. For example:

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

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

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

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -347,4 +366,4 @@ Optional:

- `create` (String)
- `delete` (String)
- `update` (String)
- `update` (String)
19 changes: 19 additions & 0 deletions docs/resources/cluster_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ resource "spectrocloud_cluster_profile" "profile" {
}
```

## 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_profile by using its `id`. For example:

```terraform
import {
to = spectrocloud_cluster_profile.example
id = "id"
}
```

You can also use the Terraform CLI and the `terraform import`, command to import the cluster using by referencing the resource `id`. For example:

```console
% terraform import spectrocloud_cluster_profile.example id
```

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
65 changes: 65 additions & 0 deletions templates/index.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,71 @@ export SPECTROCLOUD_APIKEY=5b7aad.........
provider "spectrocloud" {}
```

## Import
Starting with Terraform v1.5.0 and later, you can use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import resources into your state file.

Each resource type has its own specific requirements for the import process. We recommend you refer to the documentation for each resource to better understand the exact format of the `id` and any other required parameters.
The `import` block specifies the resource you want to import and its unique identifier with the following structure:

```terraform
import {
to = <resource>.<name>
id = "<unique_identifier>"
}
```

- `<resource>`: The type of the resource you are importing.
- `<name>`: A name you assign to the resource within your Terraform configuration.
- `<unique_identifier>`: The ID of the resource you are importing. This can include additional context if required.

### Examples
The following examples showcase how to import a resource. Some resource requires the context to be specified during the import action. The context refers to the Palette scope. Allowed values are either `project` or `tenant`.

#### Import With Context

When importing resources that require additional context, the `id` is followed by a context, separated by a colon.
```terraform
import {
to = spectrocloud_cluster_aks.example
id = "example_id:project"
}
```
You can also import a resource using the Terraform CLI and the `import` command.
```console
terraform import spectrocloud_cluster_aks.example example_id:project
```

Specify' tenant' after the colon if you want to import a resource at the tenant scope.

```terraform
import {
to = spectrocloud_cluster_aks.example
id = "example_id:tenant"
}
```
Example of importing a resource with the tenant context through the Terraform CLI.
```console
terraform import spectrocloud_cluster_aks.example example_id:tenant
```
~> Ensure you have tenant admin access when importing a resource at the tenant scope.

#### Import Without Context

For resources that do not require additional context, the `id` is the only provided argument. The following is an example of a resource that does not require the context and only provides the ID.

```terraform
import {
to = spectrocloud_cluster_profile.example
id = "id"
}
```
Below is an example of using the Terraform CLI and the `import` command without specifying the context.
```console
terraform import spectrocloud_cluster_profile.example id
```



## Support

For questions or issues with the provider, please post your questions on the
Expand Down
19 changes: 19 additions & 0 deletions templates/resources/cluster_aks.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,24 @@ resource "spectrocloud_cluster_aks" "cluster" {
}
```

## Import

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

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

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

```console
% terraform import {{ .Name }}.example example_id:project
```

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

{{ .SchemaMarkdown | trimspace }}
21 changes: 20 additions & 1 deletion templates/resources/cluster_aws.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,24 @@ resource "spectrocloud_cluster_aws" "cluster" {
}
```

## Import

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

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

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

```console
terraform import {{ .Name }}.example example_id:project
```

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

{{ .SchemaMarkdown | trimspace }}
21 changes: 20 additions & 1 deletion templates/resources/cluster_edge_native.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,24 @@ description: |-



## Import

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

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

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

```console
terraform import {{ .Name }}.example example_id:project
```

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

{{ .SchemaMarkdown | trimspace }}
Loading

0 comments on commit c584bdf

Please sign in to comment.