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: mark these attributes as computed because they are defaulted as lists #423

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

brandonc
Copy link
Collaborator

@brandonc brandonc commented Jan 28, 2022

Description

Previously, these attributes would not be added to the state but be defaulted by the API, which would be displayed as a drift

Testing plan

  1. Use this config to create a new workspace:
provider "tfe" {
  hostname = "HOSTNAME"
}

terraform {
  required_providers {
    tfe = {
      version = "~> 0.27.0"
    }
  }
}

resource "tfe_workspace" "test" {
  name               = "my-cool-workspace"
  organization       = "hashicorp"
  global_remote_state = false
}

After applying this, change the name of the workspace and plan the change.

Previously, you'd see this warning:

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # tfe_workspace.test has changed
  ~ resource "tfe_workspace" "test" {
        id                            = "ws-RGzPjmdTVvADZpdb"
        name                          = "my-cool-workspace"
      + remote_state_consumer_ids     = []
      + trigger_prefixes              = []
        # (12 unchanged attributes hidden)
    }

After applying this change, you'll notice that the warning does not show because the state has stored the computed value, which matches the default that the API generates:

$ terraform state show tfe_workspace.test
# tfe_workspace.test:
resource "tfe_workspace" "test" {
    allow_destroy_plan            = true
    auto_apply                    = false
    execution_mode                = "remote"
    file_triggers_enabled         = true
    global_remote_state           = true
    id                            = "ws-cszmfpgBQYCbQGcx"
    name                          = "my-cool-workspace"
    operations                    = true
    organization                  = "hashicorp"
    queue_all_runs                = true
    remote_state_consumer_ids     = []
    speculative_enabled           = true
    structured_run_output_enabled = true
    tag_names                     = []
    terraform_version             = "1.1.4"
    trigger_prefixes              = []
}

@brandonc brandonc requested a review from a team as a code owner January 28, 2022 14:09
…lists

Previously, these attributes would not be added to the state but be defaulted by the API, which would be displayed as a drift
@brandonc brandonc force-pushed the brandonc/compute_defaults_for_array_attributes branch from 4e6f90e to 99b29d0 Compare January 28, 2022 14:32
Copy link
Member

@chrisarcand chrisarcand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, nice work!

@brandonc brandonc merged commit 4fb5a17 into main Jan 28, 2022
@brandonc brandonc deleted the brandonc/compute_defaults_for_array_attributes branch January 28, 2022 14:55
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.

remote_state_consumer_ids shows as "changed outside Terraform" after initial apply
2 participants