Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Set default creation options when importing retool_space resource #34

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

ph-ph
Copy link
Collaborator

@ph-ph ph-ph commented Sep 9, 2024

Description

While experimenting with auto-generated TF code, I noticed that TF always wants to delete and create a space again, even when we're importing an existing space:

  # retool_space.dev_terraform_retool_dev must be replaced
  # (imported from "org_546e2e6bfe2945d38a063b0bd1b112c1")
  # Warning: this will destroy the imported resource
-/+ resource "retool_space" "dev_terraform_retool_dev" {
      + create_options = { # forces replacement
          + copy_branding_and_themes_settings = false
          + copy_sso_settings                 = false
          + create_admin_user                 = true
          + users_to_copy_as_admins           = []
        }
        domain         = "dev.terraform.retool.dev"
      ~ id             = "org_546e2e6bfe2945d38a063b0bd1b112c1" -> (known after apply)
        name           = "Dev Space"
    }

That's because create_options attribute is configured as requires replace - any change in the options would require TF to delete existing space and create a new one, to make sure it's created with the right options.

What happens during the import is:

  • TF creates new resource for the space, and sets create_options to null.
  • It then "remembers" that create_options has default value and sets it.
  • Now it looks like create_options has changed, so the space must be destroyed and created again.

Long story short, this change simply sets create_options to default value on import .

Tests

  • Tested the import scenario with my local build of the provider, verified that it doesn't attempt to re-create the space now:
  # retool_space.dev_terraform_retool_dev will be imported
    resource "retool_space" "dev_terraform_retool_dev" {
        create_options = {
            copy_branding_and_themes_settings = false
            copy_sso_settings                 = false
            create_admin_user                 = true
            users_to_copy_as_admins           = []
        }
        domain         = "dev.terraform.retool.dev"
        id             = "org_546e2e6bfe2945d38a063b0bd1b112c1"
        name           = "Dev Space"
    }
  • Updated the acceptance test to verify new behavior.

@ph-ph ph-ph requested review from a team and albertchang September 9, 2024 21:09
@ph-ph ph-ph merged commit fe29766 into main Sep 10, 2024
3 checks passed
@ph-ph ph-ph deleted the dzmitry-init-space-creation-options-when-importing branch September 10, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants