diff --git a/spacelift/resource_stack.go b/spacelift/resource_stack.go index f55b11d8..bc8c3dfb 100644 --- a/spacelift/resource_stack.go +++ b/spacelift/resource_stack.go @@ -51,6 +51,7 @@ func resourceStack() *schema.Resource { Version: 0, Type: resourceStackResourceV0().CoreConfigSchema().ImpliedType(), Upgrade: func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + // This function will upgrade any existing state files and will remove any data saved to the `import_state` key. rawState["import_state"] = "" return rawState, nil }, @@ -685,6 +686,8 @@ func resourceStackCreate(ctx context.Context, d *schema.ResourceData, meta inter return diag.Errorf(`"import_state" requires "manage_state" to be true`) } else if ok { stateContent = content.(string) + // After we've saved the imported state to memory, set the value to an empty string so it doesn't get saved to this state file. + // We purposefully ignore this value after creation, so we have no reason to save it. d.Set("import_state", "") }