Skip to content

Commit 156e929

Browse files
committed
Merge branch 'main' into matejrisek/providers/dynamic_sources
2 parents df2a016 + 80a9d6b commit 156e929

9 files changed

Lines changed: 699 additions & 168 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: Fix Terraform Stacks plugin installation error
3+
time: 2026-04-20T16:30:16.77992+02:00
4+
custom:
5+
Issue: "38406"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: Fix Terraform Stacks plugin installation error
3+
time: 2026-04-20T16:30:16.77992+02:00
4+
custom:
5+
Issue: "38406"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: Fix `validate` not returning JSON for some early diagnostics
3+
time: 2026-04-17T18:10:51.004741+02:00
4+
custom:
5+
Issue: "38400"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: Fix Terraform Stacks plugin installation error
3+
time: 2026-04-20T16:30:16.77992+02:00
4+
custom:
5+
Issue: "38406"

internal/command/init_run.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,35 @@ func (c *InitCommand) run(initArgs *arguments.Init, view views.Init) int {
220220
header = true
221221
}
222222

223+
// The init command is not allowed to upgrade the provider used for PSS (unless we're reconfiguring the state store).
224+
// Unless users choose to reconfigure, they must upgrade the state store provider separately using `terraform state migrate -upgrade`.
225+
if initArgs.Upgrade && !initArgs.Reconfigure && config.Module.StateStore != nil {
226+
pAddr := config.Module.StateStore.ProviderAddr
227+
old := previousLocks.Provider(pAddr)
228+
new := configLocks.Provider(pAddr)
229+
if old == nil || new == nil {
230+
panic(fmt.Sprintf(`Unexpected missing provider lock for %s during init -upgrade:
231+
prior lock: %#v
232+
new lock: %#v`, pAddr.ForDisplay(), old, new))
233+
}
234+
if !new.Version().Same((old.Version())) {
235+
// The upgrade has impacted the provider
236+
diags = diags.Append(tfdiags.Sourceless(
237+
tfdiags.Error,
238+
"Cannot upgrade the provider used for pluggable state storage during \"terraform init -upgrade\"",
239+
fmt.Sprintf(`While upgrading providers Terraform attempted to upgrade the %s (%q) provider, which is used by the state_store block in your configuration.
240+
Please use \"terraform state migrate -upgrade\" to upgrade the state store provider and navigate migrating your state between the two versions. You can then re-attempt \"terraform init -upgrade\" to upgrade the rest of your providers.
241+
242+
If you do not intend to upgrade the state store provider, please update your configuration to pin to the current version (%s), and re-run \"terraform init -upgrade\" to upgrade the rest of your providers.
243+
`,
244+
pAddr.Type, pAddr.ForDisplay(), old.Version()),
245+
),
246+
)
247+
view.Diagnostics(diags)
248+
return 1
249+
}
250+
}
251+
223252
// If we outputted information, then we need to output a newline
224253
// so that our success message is nicely spaced out from prior text.
225254
if header {

0 commit comments

Comments
 (0)