Skip to content

tfe_workspace_run: Adding an apply block requires two deploys #1605

Open
@tmatilai

Description

@tmatilai

Terraform Configuration Files

Initial configuration:

resource "tfe_workspace" "test" {
  name = "foo"

  # VCS and other configurations
  # [...]
}

resource "tfe_workspace_run" "test" {
  workspace_id = tfe_workspace.test.id

  destroy {
    manual_confirm = false
  }
}

Next iteration:

resource "tfe_workspace_run" "test" {
  # Same as before
  # [...]

  apply {
    manual_confirm = false
  }
}

Expected Behavior

The tfe_workspace_run resource would have been recreated (because of the ID change), and a run triggered.

Actual Behavior

  1. A Terraform run with the initial configuration adds the workspace_run resource to the state, with a random ID.
  2. After adding an apply block to the configuration, the next terraform apply detects that the apply block doesn't exist in the state, but doesn't check the new configuration. The resource is kept in the state with the same random ID, updated with the new ( apply) configuration, but nothing else is done as the resourceTFEWorkspaceRunUpdate() does nothing.
  3. Next Terraform run (without any config changes), finds the apply block in the state, but obviously fails to find a Run matching the random ID. Thus it drops the old state, and lets Terraform to create a new resource, now also triggering the run to the workspace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions