Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package terraform for openSUSE:Factory checked in at 2022-07-04 11:32:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terraform (Old) and /work/SRC/openSUSE:Factory/.terraform.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terraform" Mon Jul 4 11:32:48 2022 rev:36 rq:986466 version:1.2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/terraform/terraform.changes 2022-06-23 10:25:50.783842739 +0200 +++ /work/SRC/openSUSE:Factory/.terraform.new.1548/terraform.changes 2022-07-04 11:32:54.516026376 +0200 @@ -1,0 +2,11 @@ +Wed Jun 29 18:23:23 UTC 2022 - Johannes Kastl <ka...@b1-systems.de> + +- Update to 1.2.4: + * ENHANCEMENTS: + - Improved validation of required_providers to prevent single providers from being required with multiple names. (#31218) + - Improved plan performance by optimizing addrs.Module.String for allocations. (#31293) + * BUG FIXES: + - backend/http: Fixed bug where the HTTP backend would fail to retry acquiring the state lock and ignored the -lock-timeout flag. (#31256) + - Fix crash if a precondition or postcondition block omitted the required condition argument. (#31290) + +------------------------------------------------------------------- Old: ---- terraform-1.2.3.obscpio terraform-1.2.3.tar.gz New: ---- terraform-1.2.4.obscpio terraform-1.2.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terraform.spec ++++++ --- /var/tmp/diff_new_pack.SNXKrW/_old 2022-07-04 11:32:56.004028772 +0200 +++ /var/tmp/diff_new_pack.SNXKrW/_new 2022-07-04 11:32:56.008028778 +0200 @@ -17,7 +17,7 @@ Name: terraform -Version: 1.2.3 +Version: 1.2.4 Release: 0 Summary: Tool for building infrastructure safely and efficiently License: MPL-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.SNXKrW/_old 2022-07-04 11:32:56.040028830 +0200 +++ /var/tmp/diff_new_pack.SNXKrW/_new 2022-07-04 11:32:56.044028836 +0200 @@ -3,8 +3,8 @@ <param name="url">https://github.com/hashicorp/terraform</param> <param name="scm">git</param> <param name="filename">terraform</param> - <param name="versionformat">1.2.3</param> - <param name="revision">v1.2.3</param> + <param name="versionformat">1.2.4</param> + <param name="revision">v1.2.4</param> <param name="exclude">.git</param> </service> <service name="tar" mode="disabled"/> @@ -16,7 +16,7 @@ <param name="basename">terraform</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">terraform-1.2.3.tar.gz</param> + <param name="archive">terraform-1.2.4.tar.gz</param> </service> </services> ++++++ terraform-1.2.3.obscpio -> terraform-1.2.4.obscpio ++++++ /work/SRC/openSUSE:Factory/terraform/terraform-1.2.3.obscpio /work/SRC/openSUSE:Factory/.terraform.new.1548/terraform-1.2.4.obscpio differ: char 49, line 1 ++++++ terraform-1.2.3.tar.gz -> terraform-1.2.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/CHANGELOG.md new/terraform-1.2.4/CHANGELOG.md --- old/terraform-1.2.3/CHANGELOG.md 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/CHANGELOG.md 2022-06-29 19:05:59.000000000 +0200 @@ -1,3 +1,15 @@ +## 1.2.4 (June 29, 2022) + +ENHANCEMENTS: + +* Improved validation of `required_providers` to prevent single providers from being required with multiple names. ([#31218](https://github.com/hashicorp/terraform/issues/31218)) +* Improved plan performance by optimizing `addrs.Module.String` for allocations. ([#31293](https://github.com/hashicorp/terraform/issues/31293)) + +BUG FIXES: + +* backend/http: Fixed bug where the HTTP backend would fail to retry acquiring the state lock and ignored the `-lock-timeout` flag. ([#31256](https://github.com/hashicorp/terraform/issues/31256)) +* Fix crash if a `precondition` or `postcondition` block omitted the required `condition` argument. ([#31290](https://github.com/hashicorp/terraform/issues/31290)) + ## 1.2.3 (June 15, 2022) UPGRADE NOTES: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/addrs/module.go new/terraform-1.2.4/internal/addrs/module.go --- old/terraform-1.2.3/internal/addrs/module.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/addrs/module.go 2022-06-29 19:05:59.000000000 +0200 @@ -33,11 +33,22 @@ if len(m) == 0 { return "" } - var steps []string - for _, s := range m { - steps = append(steps, "module", s) + // Calculate necessary space. + l := 0 + for _, step := range m { + l += len(step) } - return strings.Join(steps, ".") + buf := strings.Builder{} + // 8 is len(".module.") which separates entries. + buf.Grow(l + len(m)*8) + sep := "" + for _, step := range m { + buf.WriteString(sep) + buf.WriteString("module.") + buf.WriteString(step) + sep = "." + } + return buf.String() } func (m Module) Equal(other Module) bool { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/addrs/module_test.go new/terraform-1.2.4/internal/addrs/module_test.go --- old/terraform-1.2.3/internal/addrs/module_test.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/addrs/module_test.go 2022-06-29 19:05:59.000000000 +0200 @@ -55,3 +55,42 @@ }) } } + +func TestModuleString(t *testing.T) { + testCases := map[string]Module{ + "": {}, + "module.alpha": { + "alpha", + }, + "module.alpha.module.beta": { + "alpha", + "beta", + }, + "module.alpha.module.beta.module.charlie": { + "alpha", + "beta", + "charlie", + }, + } + for str, module := range testCases { + t.Run(str, func(t *testing.T) { + if got, want := module.String(), str; got != want { + t.Errorf("wrong result: got %q, want %q", got, want) + } + }) + } +} + +func BenchmarkModuleStringShort(b *testing.B) { + module := Module{"a", "b"} + for n := 0; n < b.N; n++ { + module.String() + } +} + +func BenchmarkModuleStringLong(b *testing.B) { + module := Module{"southamerica-brazil-region", "user-regional-desktop", "user-name"} + for n := 0; n < b.N; n++ { + module.String() + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/backend/remote-state/http/client.go new/terraform-1.2.4/internal/backend/remote-state/http/client.go --- old/terraform-1.2.3/internal/backend/remote-state/http/client.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/backend/remote-state/http/client.go 2022-06-29 19:05:59.000000000 +0200 @@ -100,14 +100,23 @@ defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("HTTP remote state already locked, failed to read body") + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked, failed to read body"), + } } existing := statemgr.LockInfo{} err = json.Unmarshal(body, &existing) if err != nil { - return "", fmt.Errorf("HTTP remote state already locked, failed to unmarshal body") + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"), + } + } + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID), } - return "", fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID) default: return "", fmt.Errorf("Unexpected HTTP response code %d", resp.StatusCode) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/checks.go new/terraform-1.2.4/internal/configs/checks.go --- old/terraform-1.2.3/internal/configs/checks.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/configs/checks.go 2022-06-29 19:05:59.000000000 +0200 @@ -40,27 +40,36 @@ // is found. func (cr *CheckRule) validateSelfReferences(checkType string, addr addrs.Resource) hcl.Diagnostics { var diags hcl.Diagnostics - refs, _ := lang.References(cr.Condition.Variables()) - for _, ref := range refs { - var refAddr addrs.Resource - - switch rs := ref.Subject.(type) { - case addrs.Resource: - refAddr = rs - case addrs.ResourceInstance: - refAddr = rs.Resource - default: + exprs := []hcl.Expression{ + cr.Condition, + cr.ErrorMessage, + } + for _, expr := range exprs { + if expr == nil { continue } + refs, _ := lang.References(expr.Variables()) + for _, ref := range refs { + var refAddr addrs.Resource + + switch rs := ref.Subject.(type) { + case addrs.Resource: + refAddr = rs + case addrs.ResourceInstance: + refAddr = rs.Resource + default: + continue + } - if refAddr.Equal(addr) { - diags = diags.Append(&hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: fmt.Sprintf("Invalid reference in %s", checkType), - Detail: fmt.Sprintf("Configuration for %s may not refer to itself.", addr.String()), - Subject: cr.Condition.Range().Ptr(), - }) - break + if refAddr.Equal(addr) { + diags = diags.Append(&hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: fmt.Sprintf("Invalid reference in %s", checkType), + Detail: fmt.Sprintf("Configuration for %s may not refer to itself.", addr.String()), + Subject: expr.Range().Ptr(), + }) + break + } } } return diags diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/config_test.go new/terraform-1.2.4/internal/configs/config_test.go --- old/terraform-1.2.3/internal/configs/config_test.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/configs/config_test.go 2022-06-29 19:05:59.000000000 +0200 @@ -158,6 +158,12 @@ } } +func TestConfigProviderRequirementsDuplicate(t *testing.T) { + _, diags := testNestedModuleConfigFromDir(t, "testdata/duplicate-local-name") + assertDiagnosticCount(t, diags, 3) + assertDiagnosticSummary(t, diags, "Duplicate required provider") +} + func TestConfigProviderRequirementsShallow(t *testing.T) { cfg, diags := testNestedModuleConfigFromDir(t, "testdata/provider-reqs") // TODO: Version Constraint Deprecation. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/provider_validation.go new/terraform-1.2.4/internal/configs/provider_validation.go --- old/terraform-1.2.3/internal/configs/provider_validation.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/configs/provider_validation.go 2022-06-29 19:05:59.000000000 +0200 @@ -82,7 +82,54 @@ } if mod.ProviderRequirements != nil { + // Track all known local types too to ensure we don't have duplicated + // with different local names. + localTypes := map[string]bool{} + + // check for duplicate requirements of the same type for _, req := range mod.ProviderRequirements.RequiredProviders { + if localTypes[req.Type.String()] { + // find the last declaration to give a better error + prevDecl := "" + for localName, typ := range localNames { + if typ.Equals(req.Type) { + prevDecl = localName + } + } + + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagWarning, + Summary: "Duplicate required provider", + Detail: fmt.Sprintf( + "Provider %s with the local name %q was previously required as %q. A provider can only be required once within required_providers.", + req.Type.ForDisplay(), req.Name, prevDecl, + ), + Subject: &req.DeclRange, + }) + } else if req.Type.IsDefault() { + // Now check for possible implied duplicates, where a provider + // block uses a default namespaced provider, but that provider + // was required via a different name. + impliedLocalName := req.Type.Type + // We have to search through the configs for a match, since the keys contains any aliases. + for _, pc := range mod.ProviderConfigs { + if pc.Name == impliedLocalName && req.Name != impliedLocalName { + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagWarning, + Summary: "Duplicate required provider", + Detail: fmt.Sprintf( + "Provider %s with the local name %q was implicitly required via a configuration block as %q. The provider configuration block name must match the name used in required_providers.", + req.Type.ForDisplay(), req.Name, req.Type.Type, + ), + Subject: &req.DeclRange, + }) + break + } + } + } + + localTypes[req.Type.String()] = true + localNames[req.Name] = req.Type for _, alias := range req.Aliases { addr := addrs.AbsProviderConfig{ @@ -95,6 +142,44 @@ } } + checkImpliedProviderNames := func(resourceConfigs map[string]*Resource) { + // Now that we have all the provider configs and requirements validated, + // check for any resources which use an implied localname which doesn't + // match that of required_providers + for _, r := range resourceConfigs { + // We're looking for resources with no specific provider reference + if r.ProviderConfigRef != nil { + continue + } + + localName := r.Addr().ImpliedProvider() + if _, ok := localNames[localName]; ok { + // OK, this was listed directly in the required_providers + continue + } + + defAddr := addrs.ImpliedProviderForUnqualifiedType(localName) + + // Now make sure we don't have the same provider required under a + // different name. + for prevLocalName, addr := range localNames { + if addr.Equals(defAddr) { + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagWarning, + Summary: "Duplicate required provider", + Detail: fmt.Sprintf( + "Provider %q was implicitly required via resource %q, but listed in required_providers as %q. Either the local name in required_providers must match the resource name, or the %q provider must be assigned within the resource block.", + defAddr, r.Addr(), prevLocalName, prevLocalName, + ), + Subject: &r.DeclRange, + }) + } + } + } + } + checkImpliedProviderNames(mod.ManagedResources) + checkImpliedProviderNames(mod.DataResources) + // collect providers passed from the parent if parentCall != nil { for _, passed := range parentCall.Providers { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/testdata/duplicate-local-name/main.tf new/terraform-1.2.4/internal/configs/testdata/duplicate-local-name/main.tf --- old/terraform-1.2.3/internal/configs/testdata/duplicate-local-name/main.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terraform-1.2.4/internal/configs/testdata/duplicate-local-name/main.tf 2022-06-29 19:05:59.000000000 +0200 @@ -0,0 +1,23 @@ +terraform { + required_providers { + test = { + source = "hashicorp/test" + } + dupe = { + source = "hashicorp/test" + } + other = { + source = "hashicorp/default" + } + + wrong-name = { + source = "hashicorp/foo" + } + } +} + +provider "default" { +} + +resource "foo_resource" { +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/testdata/invalid-files/precondition-postcondition-badref.tf new/terraform-1.2.4/internal/configs/testdata/invalid-files/precondition-postcondition-badref.tf --- old/terraform-1.2.3/internal/configs/testdata/invalid-files/precondition-postcondition-badref.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terraform-1.2.4/internal/configs/testdata/invalid-files/precondition-postcondition-badref.tf 2022-06-29 19:05:59.000000000 +0200 @@ -0,0 +1,29 @@ +data "example" "example" { + foo = 5 + + lifecycle { + precondition { + condition = data.example.example.foo == 5 # ERROR: Invalid reference in precondition + error_message = "Must be five." + } + postcondition { + condition = self.foo == 5 + error_message = "Must be five, but is ${data.example.example.foo}." # ERROR: Invalid reference in postcondition + } + } +} + +resource "example" "example" { + foo = 5 + + lifecycle { + precondition { + condition = example.example.foo == 5 # ERROR: Invalid reference in precondition + error_message = "Must be five." + } + postcondition { + condition = self.foo == 5 + error_message = "Must be five, but is ${example.example.foo}." # ERROR: Invalid reference in postcondition + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/configs/testdata/invalid-files/precondition-postcondition-missing-condition.tf new/terraform-1.2.4/internal/configs/testdata/invalid-files/precondition-postcondition-missing-condition.tf --- old/terraform-1.2.3/internal/configs/testdata/invalid-files/precondition-postcondition-missing-condition.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terraform-1.2.4/internal/configs/testdata/invalid-files/precondition-postcondition-missing-condition.tf 2022-06-29 19:05:59.000000000 +0200 @@ -0,0 +1,12 @@ +resource "example" "example" { + foo = 5 + + lifecycle { + precondition { # ERROR: Missing required argument + error_message = "Can a check block fail without a condition?" + } + postcondition { # ERROR: Missing required argument + error_message = "Do not try to pass the check; only realize that there is no check." + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/states/remote/testing.go new/terraform-1.2.4/internal/states/remote/testing.go --- old/terraform-1.2.3/internal/states/remote/testing.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/states/remote/testing.go 2022-06-29 19:05:59.000000000 +0200 @@ -77,6 +77,9 @@ lockerA.Unlock(lockIDA) t.Fatal("client B obtained lock while held by client A") } + if _, ok := err.(*statemgr.LockError); !ok { + t.Errorf("expected a LockError, but was %t: %s", err, err) + } if err := lockerA.Unlock(lockIDA); err != nil { t.Fatal("error unlocking client A", err) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/terraform/transform_provider.go new/terraform-1.2.4/internal/terraform/transform_provider.go --- old/terraform-1.2.3/internal/terraform/transform_provider.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/terraform/transform_provider.go 2022-06-29 19:05:59.000000000 +0200 @@ -543,6 +543,13 @@ Module: path, } + if _, ok := t.providers[addr.String()]; ok { + // The config validation warns about this too, but we can't + // completely prevent it in v1. + log.Printf("[WARN] ProviderConfigTransformer: duplicate required_providers entry for %s", addr) + continue + } + abstract := &NodeAbstractProvider{ Addr: addr, } @@ -568,6 +575,13 @@ Module: path, } + if _, ok := t.providers[addr.String()]; ok { + // The abstract provider node may already have been added from the + // provider requirements. + log.Printf("[WARN] ProviderConfigTransformer: provider node %s already added", addr) + continue + } + abstract := &NodeAbstractProvider{ Addr: addr, } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/internal/terraform/transform_provider_test.go new/terraform-1.2.4/internal/terraform/transform_provider_test.go --- old/terraform-1.2.3/internal/terraform/transform_provider_test.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/internal/terraform/transform_provider_test.go 2022-06-29 19:05:59.000000000 +0200 @@ -446,6 +446,42 @@ } } +func TestProviderConfigTransformer_duplicateLocalName(t *testing.T) { + mod := testModuleInline(t, map[string]string{ + "main.tf": ` +terraform { + required_providers { + # We have to allow this since it wasn't previously prevented. If the + # default config is equivalent to the provider config, the user may never + # see an error. + dupe = { + source = "registry.terraform.io/hashicorp/test" + } + } +} + +provider "test" { +} +`}) + concrete := func(a *NodeAbstractProvider) dag.Vertex { return a } + + g := testProviderTransformerGraph(t, mod) + tf := ProviderConfigTransformer{ + Config: mod, + Concrete: concrete, + } + if err := tf.Transform(g); err != nil { + t.Fatalf("err: %s", err) + } + + expected := `provider["registry.terraform.io/hashicorp/test"]` + + actual := strings.TrimSpace(g.String()) + if actual != expected { + t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual) + } +} + const testTransformProviderBasicStr = ` aws_instance.web provider["registry.terraform.io/hashicorp/aws"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/version/version.go new/terraform-1.2.4/version/version.go --- old/terraform-1.2.3/version/version.go 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/version/version.go 2022-06-29 19:05:59.000000000 +0200 @@ -11,7 +11,7 @@ ) // The main version number that is being run at the moment. -var Version = "1.2.3" +var Version = "1.2.4" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/cli/commands/apply.mdx new/terraform-1.2.4/website/docs/cli/commands/apply.mdx --- old/terraform-1.2.3/website/docs/cli/commands/apply.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/cli/commands/apply.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -7,77 +7,58 @@ # Command: apply -> **Hands-on:** Try the [Terraform: Get Started](https://learn.hashicorp.com/collections/terraform/aws-get-started?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) collection on HashiCorp Learn. For more in-depth details on the `apply` command, check out the [Apply Terraform Configuration tutorial](https://learn.hashicorp.com/tutorials/terraform/apply?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS). - The `terraform apply` command executes the actions proposed in a Terraform plan. -The most straightforward way to use `terraform apply` is to run it without -any arguments at all, in which case it will automatically create a new -execution plan (as if you had run `terraform plan`) and then prompt you to -approve that plan, before taking the indicated actions. - -Another way to use `terraform apply` is to pass it the filename of a saved -plan file you created earlier with `terraform plan -out=...`, in which case -Terraform will apply the changes in the plan without any confirmation prompt. -This two-step workflow is primarily intended for when -[running Terraform in automation](https://learn.hashicorp.com/tutorials/terraform/automate-terraform?in=terraform/automation&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS). +> **Hands On:** Try the [Apply Terraform Configuration](https://learn.hashicorp.com/tutorials/terraform/apply?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial to learn how Terraform applies a configuration, how Terraform recovers from errors during apply, and common ways to use this command. ## Usage Usage: `terraform apply [options] [plan file]` -The behavior of `terraform apply` differs significantly depending on whether -you pass it the filename of a previously-saved plan file. + ### Automatic Plan Mode -In the default case, with no saved plan file, `terraform apply` creates its own -plan of action, in the same way that [`terraform plan`](/cli/commands/plan) would. +When you run `terraform apply` without passing a saved plan file, Terraform automatically creates a new execution plan as if you had run [`terraform plan`](/cli/commands/plan), prompts you to approve that plan, and takes the indicated actions. You can use all of the [planning modes](/cli/commands/plan#planning-modes) and +[planning options](/cli/commands/plan#planning-options) to customize how Terraform will create the plan. -Terraform will propose the plan to you and prompt you to approve it before -taking the described actions, unless you waive that prompt by using the -`-auto-approve` option. +You can pass the `-auto-approve` option to instruct Terraform to apply the plan without asking for confirmation. --> **Tip:** When you run `terraform apply` without a saved plan file, you can use all of the [planning modes](/cli/commands/plan#planning-modes) and -[planning options](/cli/commands/plan#planning-options) available for `terraform plan`. This lets you customize how Terraform will create the plan. +!> **Warning:** If you use `-auto-approve`, we recommend making sure that no one can change your infrastructure outside of your Terraform workflow. This minimizes the risk of unpredictable changes and configuration drift. ### Saved Plan Mode -If you pass the filename of a previously-saved plan file, `terraform apply` -performs exactly the steps specified by that plan file. It does not prompt for -approval; if you want to inspect a plan file before applying it, you can use -[`terraform show`](/cli/commands/show). +When you pass a [saved plan file](/cli/commands/plan#out-filename) to `terraform apply`, Terraform takes the actions in the saved plan without prompting you for confirmation. You may want to use this two-step workflow when [running Terraform in automation](https://learn.hashicorp.com/tutorials/terraform/automate-terraform?in=terraform/automation&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS). + +Use [`terraform show`](/cli/commands/show) to inspect a saved plan file before applying it. -When using a saved plan, none of the planning modes or planning options linked -above are supported; these options only affect Terraform's decisions about which +When using a saved plan, you cannot specify any additional planning modes or options. These options only affect Terraform's decisions about which actions to take, and the plan file contains the final results of those decisions. ### Plan Options -When run without a saved plan file, `terraform apply` supports all of `terraform -plan`'s planning modes and planning options. For details, see: +Without a saved plan file, `terraform apply` supports all planning modes and planning options available for `terraform plan`. -* [Planning Modes](/cli/commands/plan#planning-modes) -* [Planning Options](/cli/commands/plan#planning-options) +- **[Planning Modes](/cli/commands/plan#planning-modes):** These include `-destroy`, which creates a plan to destroy all remote objects, and `-refresh-only`, which creates a plan to update Terraform state and root module output values. +- **[Planning Options](/cli/commands/plan#planning-options):** These include specifying which resource instances Terraform should replace, setting Terraform input variables, etc. ### Apply Options -The following options allow you to change various details about how the -apply command executes and reports on the apply operation. +The following options change how the apply command executes and reports on the apply operation. -* `-auto-approve` - Skips interactive approval of plan before applying. This +- `-auto-approve` - Skips interactive approval of plan before applying. This option is ignored when you pass a previously-saved plan file, because Terraform considers you passing the plan file as the approval and so will never prompt in that case. -* `-compact-warnings` - Shows any warning messages in a compact form which +- `-compact-warnings` - Shows any warning messages in a compact form which includes only the summary messages, unless the warnings are accompanied by at least one error and thus the warning text might be useful context for the errors. -* `-input=false` - Disables all of Terraform's interactive prompts. Note that +- `-input=false` - Disables all of Terraform's interactive prompts. Note that this also prevents Terraform from prompting for interactive approval of a plan, so Terraform will conservatively assume that you do not wish to apply the plan, causing the operation to fail. If you wish to run Terraform @@ -85,27 +66,27 @@ [Running Terraform in Automation](https://learn.hashicorp.com/tutorials/terraform/automate-terraform?in=terraform/automation&utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) for some different approaches. -* `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output. +- `-json` - Enables the [machine readable JSON UI][machine-readable-ui] output. This implies `-input=false`, so the configuration must have no unassigned variable values to continue. To enable this flag, you must also either enable the `-auto-approve` flag or specify a previously-saved plan. [machine-readable-ui]: /internals/machine-readable-ui -* `-lock=false` - Don't hold a state lock during the operation. This is +- `-lock=false` - Don't hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace. -* `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`, +- `-lock-timeout=DURATION` - Unless locking is disabled with `-lock=false`, instructs Terraform to retry acquiring a lock for a period of time before returning an error. The duration syntax is a number followed by a time unit letter, such as "3s" for three seconds. -* `-no-color` - Disables terminal formatting sequences in the output. Use this +- `-no-color` - Disables terminal formatting sequences in the output. Use this if you are running Terraform in a context where its output will be rendered by a system that cannot interpret terminal formatting. -* `-parallelism=n` - Limit the number of concurrent operation as Terraform +- `-parallelism=n` - Limit the number of concurrent operation as Terraform [walks the graph](/internals/graph#walking-the-graph). Defaults to 10\. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/cli/commands/plan.mdx new/terraform-1.2.4/website/docs/cli/commands/plan.mdx --- old/terraform-1.2.3/website/docs/cli/commands/plan.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/cli/commands/plan.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -87,9 +87,7 @@ your configuration. Terraform has two alternative planning modes, each of which creates a plan with a different intended outcome. These options are available for both `terraform plan` and [`terraform apply`](/cli/commands/apply). * **Destroy mode:** creates a plan whose goal is to destroy all remote objects - that currently exist, leaving an empty Terraform state. This can be useful - for situations like transient development environments, where the managed - objects cease to be useful once the development task is complete. + that currently exist, leaving an empty Terraform state. It is the same as running [`terraform destroy`](/cli/commands/destroy). Destroy mode can be useful for situations like transient development environments, where the managed objects cease to be useful once the development task is complete. Activate destroy mode using the `-destroy` command line option. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/language/functions/merge.mdx new/terraform-1.2.4/website/docs/language/functions/merge.mdx --- old/terraform-1.2.3/website/docs/language/functions/merge.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/language/functions/merge.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -38,3 +38,14 @@ "d" = 3 } ``` + +The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/language/expressions/function-calls#expanding-function-arguments) for details. + +``` +> merge([{a="b", c="d"}, {}, {e="f", c="z"}]...) +{ + "a" = "b" + "c" = "z" + "e" = "f" +} +``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/language/modules/develop/providers.mdx new/terraform-1.2.4/website/docs/language/modules/develop/providers.mdx --- old/terraform-1.2.3/website/docs/language/modules/develop/providers.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/language/modules/develop/providers.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -102,7 +102,7 @@ ## Implicit Provider Inheritance For convenience in simple configurations, a child module automatically inherits -default (un-aliased) provider configurations from its parent. This means that +[default provider configurations](/language/providers/configuration#default-provider-configurations) from its parent. This means that explicit `provider` blocks appear only in the root module, and downstream modules can simply declare resources for that provider and have them automatically associated with the root provider configurations. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/language/providers/requirements.mdx new/terraform-1.2.4/website/docs/language/providers/requirements.mdx --- old/terraform-1.2.3/website/docs/language/providers/requirements.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/language/providers/requirements.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -247,7 +247,9 @@ directory where you'd run `terraform apply` ?????should also specify the _maximum_ provider version it is intended to work with, to avoid accidental upgrades to incompatible new versions. The `~>` operator is a convenient -shorthand for allowing only patch releases within a specific minor release: +shorthand for allowing the rightmost component of a version to increment. The +following example uses the operator to allow only patch releases within a +specific minor release: ```hcl terraform { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terraform-1.2.3/website/docs/language/state/purpose.mdx new/terraform-1.2.4/website/docs/language/state/purpose.mdx --- old/terraform-1.2.3/website/docs/language/state/purpose.mdx 2022-06-15 19:34:28.000000000 +0200 +++ new/terraform-1.2.4/website/docs/language/state/purpose.mdx 2022-06-29 19:05:59.000000000 +0200 @@ -11,7 +11,7 @@ State is a necessary requirement for Terraform to function. It is often asked if it is possible for Terraform to work without state, or for Terraform -to not use state and just inspect cloud resources on every run. This page +to not use state and just inspect real world resources on every run. This page will help explain why Terraform state is required. As you'll see from the reasons below, state is required. And in the scenarios @@ -22,9 +22,9 @@ ## Mapping to the Real World Terraform requires some sort of database to map Terraform config to the real -world. When you have a resource `resource "aws_instance" "foo"` in your -configuration, Terraform uses this map to know that instance `i-abcd1234` -is represented by that resource. +world. For example, when you have a resource `resource "aws_instance" "foo"` in your +configuration, Terraform uses this mapping to know that the resource `resource "aws_instance" "foo"` +represents a real world object with the instance ID `i-abcd1234` on a remote system. For some providers like AWS, Terraform could theoretically use something like AWS tags. Early prototypes of Terraform actually had no state files and used @@ -35,16 +35,12 @@ Therefore, for mapping configuration to resources in the real world, Terraform uses its own state structure. -Terraform expects that each remote object is bound to only one resource -instance, which is normally guaranteed by Terraform being responsible for -creating the objects and recording their identities in the state. If you -instead import objects that were created outside of Terraform, you'll need -to check yourself that each distinct object is imported to only one resource -instance. - -If one remote object is bound to two or more resource instances then Terraform -may take unexpected actions against those objects, because the mapping from -configuration to the remote object state has become ambiguous. +Terraform expects that each remote object is bound to only one resource instance in the configuration. +If a remote object is bound to multiple resource instances, the mapping from configuration to the remote +object in the state becomes ambiguous, and Terraform may behave unexpectedly. Terraform can guarantee +a one-to-one mapping when it creates objects and records their identities in the state. +When importing objects created outside of Terraform, you must make sure that each distinct object +is imported to only one resource instance. ## Metadata @@ -53,8 +49,8 @@ Terraform typically uses the configuration to determine dependency order. However, when you delete a resource from a Terraform configuration, Terraform -must know how to delete that resource. Terraform can see that a mapping exists -for a resource not in your configuration and plan to destroy. However, since +must know how to delete that resource from the remote system. Terraform can see that a mapping exists +in the state file for a resource not in your configuration and plan to destroy. However, since the configuration no longer exists, the order cannot be determined from the configuration alone. @@ -67,7 +63,7 @@ between resource types. For example, Terraform could know that servers must be deleted before the subnets they are a part of. The complexity for this approach quickly explodes, however: in addition to Terraform having to understand the -ordering semantics of every resource for every cloud, Terraform must also +ordering semantics of every resource for every _provider_, Terraform must also understand the ordering _across providers_. Terraform also stores other metadata for similar reasons, such as a pointer ++++++ terraform.obsinfo ++++++ --- /var/tmp/diff_new_pack.SNXKrW/_old 2022-07-04 11:32:57.300030859 +0200 +++ /var/tmp/diff_new_pack.SNXKrW/_new 2022-07-04 11:32:57.304030865 +0200 @@ -1,5 +1,5 @@ name: terraform -version: 1.2.3 -mtime: 1655314468 -commit: 9a30749b89d4e88ed31a13d727996ec9bbfeeca2 +version: 1.2.4 +mtime: 1656522359 +commit: 9cc7dbd4f514431cee31155663c16d4f7f77f979 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terraform/vendor.tar.gz /work/SRC/openSUSE:Factory/.terraform.new.1548/vendor.tar.gz differ: char 5, line 1