You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If we're handling the builtin "terraform" provider then there's no version information to store in the dependency lock file, so don't access it.
1605
1606
// We must record a value into the backend state file, and we cannot include a value that changes (e.g. the Terraform core binary version) as migration
1606
1607
// is impossible with builtin providers.
1607
-
// So, we use a hardcoded version number of 42.
1608
-
varerrerror
1609
-
pVersion, err=version.NewVersion("0.42.0")
1608
+
// So, we use an arbitrary stand-in version.
1609
+
standInVersion, err:=version.NewVersion("0.0.1")
1610
1610
iferr!=nil {
1611
-
diags=diags.Append(fmt.Errorf("Error when creating a backend state file containing a builtin provider. This is a bug in Terraform and should be reported: %w",
1611
+
diags=diags.Append(fmt.Errorf("Error when creating a backend state file. This is a bug in Terraform and should be reported: %w",
1612
1612
err))
1613
1613
returnnil, diags
1614
1614
}
1615
+
pVersion=standInVersion
1615
1616
} else {
1616
-
pLock:=opts.Locks.Provider(c.ProviderAddr)
1617
-
ifpLock==nil {
1618
-
diags=diags.Append(fmt.Errorf("The provider %s (%q) is not present in the lockfile, despite being used for state store %q. This is a bug in Terraform and should be reported.",
diags=diags.Append(fmt.Errorf("Failed obtain the in-use version of provider %s (%q) when recording backend state for state store %q. This is a bug in Terraform and should be reported: %w",
1628
-
c.Provider.Name,
1629
-
c.ProviderAddr,
1630
-
c.Type,
1619
+
diags=diags.Append(fmt.Errorf("Error determining if the state storage provider is reattached or not. This is a bug in Terraform and should be reported: %w",
1631
1620
err))
1632
1621
returnnil, diags
1633
1622
}
1623
+
ifisReattached {
1624
+
// If the provider is unmanaged then it won't be in the locks.
1625
+
// If there are no locks then there's no version information to for us to access and use when creating the backend state file.
1626
+
// So, we use an arbitrary stand-in version.
1627
+
diags=diags.Append(&hcl.Diagnostic{
1628
+
Severity: hcl.DiagWarning,
1629
+
Summary: "State storage provider is not managed by Terraform",
1630
+
Detail: "Terraform is using a provider supplied via TF_REATTACH_PROVIDERS for initializing state storage. This will affect Terraform's ability to detect when state migrations are required.",
1631
+
})
1632
+
standInVersion, err:=version.NewVersion("0.0.1")
1633
+
iferr!=nil {
1634
+
diags=diags.Append(fmt.Errorf("Error when creating a backend state file. This is a bug in Terraform and should be reported: %w",
1635
+
err))
1636
+
returnnil, diags
1637
+
}
1638
+
pVersion=standInVersion
1639
+
} else {
1640
+
// The provider is not built in and is being managed by Terraform
1641
+
// This is the most common scenario, by far.
1642
+
pLock:=opts.Locks.Provider(c.ProviderAddr)
1643
+
ifpLock==nil {
1644
+
diags=diags.Append(fmt.Errorf("The provider %s (%q) is not present in the lockfile, despite being used for state store %q. This is a bug in Terraform and should be reported.",
diags=diags.Append(fmt.Errorf("Failed obtain the in-use version of provider %s (%q) when recording backend state for state store %q. This is a bug in Terraform and should be reported: %w",
0 commit comments