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

Backport of feat: add state_key for test run blocks into v1.11 #36341

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

github-actions[bot]
Copy link
Contributor

Backport

This PR is auto-generated from #36185 to be assessed for backporting due to the inclusion of the label 1.11-backport.

🚨

Warning automatic cherry-pick of commits failed. If the first commit failed,
you will see a blank no-op commit below. If at least one commit succeeded, you
will see the cherry-picked commits up to, not including, the commit where
the merge conflict occurred.

The person who merged in the original PR is:
@liamcervante
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.

merge conflict error: POST https://api.github.com/repos/hashicorp/terraform/merges: 409 Merge conflict []

The below text is copied from the body of the original PR.


While working on terraform module testing, i've been in need for a test case that ensure that a module upgrade is possible. Tests runs can only plan, apply and destroy a complete new infrastructure. My proposal allows to have multiple run blocks that targets the same infrastructure.

This could allow to make module upgrade tests, by ensuring the second apply using the new code still pass, or even checking that ressources does not get recreated.

Example code i want to implement :

run "old_code" {
  state_key = "module_test"

  variables {
    input1 = "toto"
  }

  module {
    source = "./test/old_code_path"
  }
}

run "new_code" {
  state_key = "module_test"

  variables {
    input1 = ""
  }

  module {
    source = "./test/new_code_path"
  }
}

Fixes #35080

PR Modifications ideas

I'm not sure about naming and where this option should be added

  • Rename state_alias to state_key ?
  • Move state_aliasfrom plan_options to run block ?

Target Release

1.11.x

Draft CHANGELOG entry

NEW FEATURES | UPGRADE NOTES | ENHANCEMENTS | BUG FIXES | EXPERIMENTS

  • The terraform test command now supports a state_alias attribute in plan_option blocks during test runs. This feature allows multiple Terraform test runs to target the same infrastructure.

Overview of commits

@liamcervante liamcervante marked this pull request as ready for review January 16, 2025 09:39
@liamcervante liamcervante requested a review from a team as a code owner January 16, 2025 09:39
@liamcervante
Copy link
Member

The commits that failed here were the docs and changelog entries being added and then removed. We actually don't need these, so it's all good to merge.

@liamcervante liamcervante merged commit f2fa64b into v1.11 Jan 16, 2025
6 of 7 checks passed
@liamcervante liamcervante deleted the backport/main/reliably-sweeping-bunny branch January 16, 2025 09:49
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.

3 participants