This post demonstrates how to migrate your current TF file structure to support the structure of the latest Spotinst Provider version. These steps support a single or multiple Elastigroups resources import.The current implementation of Terraform import can only import resources into the state. It does not generate configuration. A future version of Terraform will also generate configuration.

Make sure to save a copy of your current *.tf file and terraform.tfstatebefore starting.
Step 1 – Prepare your resource/s

Create a new folder containing the following 2 files:

  1. *.tf– a file which contains an empty Elastigroup resource, i.e:
provider "spotinst" {
  token = "xxxxxxxxxxxxxxxxxxxxxxx"
  account = "act-1exxxx40"

resource "spotinst_elastigroup_aws" "TFtest1" {}
Note: The Provider can also be added as described here.

2. terraform.tfstate– a file which contains the following skeleton:

"version": 3,
"terraform_version": "0.11.4",
"serial": 1,
"lineage": "same as on old provider",
"modules": [
        "path": [
        "outputs": {},
        "resources": {
          "spotinst_elastigroup_aws.<name of the resource>-IMPORT": {
           "type": "spotinst_elastigroup_aws",
           "depends_on": [],
           "primary": {
            "id": "<group-id>",
            "attributes": {}
Step 2 – Migrate your current resource
  1.  Open the terminal and run terraform initin order to download the official Spotinst provider to the same folder from the previous step.

2. Execute the following command: terraform import spotinst_elastigroup_aws.<name of the resource> <group-id>

3. The updated terraform.tfstate should now contain your desired elastigroup/s in addition to the previous resource with the `-IMPORT` suffix. Remove the resource with the `-IMPORT` suffix.

Important: You must delete the `-IMPORT` resource to prevent your elastigroup from being destroyed.

4. Perform a terraform plan to ensure the state file has changed successfully – you are supposed to see a log of the changes.
These changes will be addressed in the next step.

Step 3 – Convert your Schema
  1. Migrate the previous tf.file to your empty spotinst_elastigroup_aws resource (created as part of step 1) and convert its schema to be aligned with the new provider as seen in the examples provided within the following links:

2. Occasionally performterraform plan to verify which fields need to modify on the schema without actually changing the group via Spotinst API.

Important: DO NOT terraform apply until you fully migrate the TF schema to the new provider.

3. Perform terraform applyto successfully apply your changes.