Commit Graph

26347 Commits

Author SHA1 Message Date
Pam Selle ad8ff621ff
Update CHANGELOG.md 2020-06-24 14:05:49 -04:00
João G. Packer fd47260fdc
command: adjust exit code of state rm (#22300)
* command: adjust exit code of state rm and state mv

Commands `state rm` and `state mv` will now exit with code 1 when the
target resource is not found in the current state.
This is consistent with `terraform state show non_existent_resource`.

Fixes #17800
2020-06-24 14:03:23 -04:00
James Bardin a0fad2c6b4 always return original workspace, even when null
The returned value type needs to strictly match the proposed value type.
2020-06-24 13:41:51 -04:00
Alisdair McDiarmid 9f455bfc55
Update CHANGELOG.md 2020-06-24 13:39:56 -04:00
Alisdair McDiarmid 563abd55dc
Merge pull request #25369 from hashicorp/alisdair/fix-provider-requirements-panics
configs: Fix provider requirements panics
2020-06-24 13:38:11 -04:00
Alisdair McDiarmid f714a9da79
Merge pull request #25352 from hashicorp/alisdair/fix-import-allow-missing-config
command/import: Fix allow-missing-config option
2020-06-24 13:37:13 -04:00
James Bardin 6ef11e9d9e update CHANGELOG.md 2020-06-24 13:35:21 -04:00
James Bardin f9ff7d1ee8 test for targeting with modules and output 2020-06-24 12:52:29 -04:00
Martin Atkins 8f77bd344e lang/funcs: Filesystem functions hint about dynamically-generated files
The functions that interact with the filesystem are, by design, restricted
to reading files that are distributed as a static part of the
configuration, and cannot be used to interact with files that are
generated dynamically by resources in the configuration.

However, new users have often yet developed a correct mental model of how
Terraform execution works and are confused by the terse error messages
these functions return. As an interim step to help some of those users,
this just adds some more commentary to the error message which gives a
vague, generic directive to look to attributes of the resource that is
generating the file, which should (if it's designed well) export
attributes that allow the resulting file to be used effectively with
common patterns, such as checksums of the content of the generated file.

The error message here is not particularly attractive due to the
limitations of the context where it's being returned from, but I'm
accepting that here in the interest of keeping this change simple, so we
can give a hint about a case that seems to frequently generate new-user
questions. We may iterate further on the presentation of this message
later.
2020-06-24 09:02:38 -07:00
Alisdair McDiarmid 8c3648c1e6
terraform version is preferred 2020-06-24 10:59:59 -04:00
Alisdair McDiarmid 7b526b1969
terraform version is preferred 2020-06-24 10:59:49 -04:00
James Bardin 2fa16c24f7 remove unused interfaces
RemovableIfNotTargeted and GraphNodeTargetDownstream are no longer used
by the target transformer.
2020-06-24 10:45:58 -04:00
Alisdair McDiarmid cbe932f88d
Update CHANGELOG.md 2020-06-24 10:35:18 -04:00
Alisdair McDiarmid 550d75f5ce
Merge pull request #25300 from hashicorp/alisdair/fix-init-flags-silent-exit
command: Fix init flags silent exit bug
2020-06-24 10:33:09 -04:00
Alisdair McDiarmid c093c50c80
Merge pull request #25255 from unki/patch-1
fix yamldecode()-example, missing a file() call
2020-06-24 10:31:08 -04:00
James Bardin c99157c35b new targets transformer
This simplifies the initial targeting logic, and removes the complex
algorithm for finding descendants that result in output changes, which
hid bugs that failed with modules.

The targeting is handled in 2 phases. First we find all individual
resource nodes that are targeted, then add all their dependencies to the
set of targets. This in essence is all we need for targeting, and is
straightforward to understand.

The next phase is to add any root module outputs that can be solely
derived from the set of targeted resources. There is currently no way to
target outputs themselves, so this is how we can allow these to be
updated as part of a target.

Rather than attempting to backtrack through the graph to find candidate
outputs, requiring each node on the chain to properly advertise if it
could be traversed, then backtracking again to determine if the
candidate is valid (which often got "off course"), we can start directly
from the outputs themselves. The algorithm here is simpler: if all the
root output's resource dependencies are targeted, add that output and
its dependencies to the targeted set.
2020-06-24 10:27:52 -04:00
Alisdair McDiarmid 377b99907b
Merge pull request #25339 from jessica-ritter/patch-1
Trimprefix: what happens when prefix is not in string?
2020-06-24 10:25:30 -04:00
James Bardin 504b49b1d3 make outptut destroy nodes a temporaryValue
These never need to be pruned, except in the case of adding output
changes to a targeted graph.
2020-06-24 10:22:10 -04:00
Alisdair McDiarmid 9a9f4e2696 configs: Fix provider requirements panics
When parsing provider requirements we should check the type of the
source and version attributes rather than assuming that they are
strings. Otherwise an invalid attribute value will cause a panic.
2020-06-24 10:12:29 -04:00
Jamie Finnigan be510e53bc
website/docs: add note re. SSH hostkey validation to provisioner connection doc (#25355) 2020-06-24 08:09:06 -04:00
James Bardin 308eb5f47f add CountBoundaryTransformer after targeting
no need to have the extra nodes and edges in the graph when we're
traversing everything for targeting
2020-06-23 17:22:44 -04:00
Alisdair McDiarmid 9ab9ef6291 command/import: Fix allow-missing-config option
We previously intentionally removed support for the allow-missing-config
option to terraform import, requiring that all imported resources have
matching config. See #24412.

However, the option was not removed from the import command, and it is
widely used. This commit reintroduces support for importing with a
missing configuration by falling back to implying the provider FQN based
on the resource type.
2020-06-23 14:20:50 -04:00
James Bardin 3178d7d7ac
Merge pull request #25345 from hashicorp/jbardin/module-depends-on-providers
don't allow providers in modules using depends_on
2020-06-23 10:38:58 -04:00
James Bardin 3f22bbf8d5 don't allow providers in modules using depends_on
Providers themselves don't support depends_on, and therefor a module
with providers cannot use depends_on.
2020-06-23 09:56:00 -04:00
James Bardin 41befeaa37
Merge pull request #25341 from hashicorp/jbardin/remote-panic
prevent panic in remote backend retry
2020-06-22 15:12:50 -04:00
James Bardin 35d232481f prevent panic in remote backend retry
Ensure that the *http.Response is not nil before checking the status.
2020-06-22 15:02:23 -04:00
jessica-ritter edbf59ed4c
what happens when prefix is not in string
https://github.com/hashicorp/terraform/blob/master/lang/functions.go#L126 shows that Terraform's Trimprefix comes directly from the standard go library. 
When prefix is absent in the go standard library, the original string is returned; https://golang.org/pkg/strings/#TrimPrefix.
2020-06-22 11:31:08 -07:00
Alisdair McDiarmid 43737f2f4f
Update CHANGELOG.md 2020-06-22 13:11:07 -04:00
Alisdair McDiarmid 6198b8a4f1
Merge pull request #25334 from hashicorp/alisdair/fix-nested-provider-requirements
configs: Fix nested provider requirements bug
2020-06-22 13:07:32 -04:00
Alisdair McDiarmid 45f7da9678 configs: Fix nested provider requirements bug
In a recent PR, we changed the provider requirements code to permit
per-module requirements gathering, to enhance the provider command
output. This had an incorrect implementation of recursive requirements
gathering for the normal case, which resulted in only depth-1 modules
being inspected.

This commit fixes the broken recursion and adds a grandchild module to
the unit tests as test coverage. This also demanded fixing the
testNestedModuleConfigFromDir helper function to cope with nested
modules in test configs.
2020-06-22 12:16:22 -04:00
James Bardin 06493d791b
Merge pull request #25302 from hashicorp/jbardin/data-source-plan
Hide empty plans for misbehaving data resource
2020-06-22 12:04:37 -04:00
James Bardin ff91a2257b
Merge pull request #25297 from hashicorp/jbardin/terraform-remote-state
don't set remote workspace in state
2020-06-22 12:04:19 -04:00
Alisdair McDiarmid 69b94ec149
Update CHANGELOG.md 2020-06-22 09:48:13 -04:00
Alisdair McDiarmid 2fdde395ea
Merge pull request #25299 from hashicorp/alisdair/fix-command-fixture-modify-in-place
command: Fix command fixture modify-in-place bugs
2020-06-22 09:47:04 -04:00
James Bardin f433228906 hide empty plans for misbehaving data resource
If a data source is storing a value that doesn't comply precisely with
the schema, it will now show up as a perpetual diff during plan.

Since we can easily detect if there is no resulting change from the
stored value, rather than presenting a planned read each time, we can
change the plan to a NoOp and log the incongruity as a warning.
2020-06-18 19:21:19 -04:00
Alisdair McDiarmid 820ed48813 command: Fix init flags silent exit bug
When using `-flag=value` with Powershell, unquoted values are broken
into separate arguments. This means that the following command:

  terraform init -backend-config=./backend.conf

is interpreted by Terraform as:

  terraform init -backend-config= ./backend.conf

This results in an empty backend-config setting (which is semantically
valid!) followed by a custom configuration path (pointing at a file).

Due to a bug where we could exit without printing diagnostics, this
would result in a silent failure that was very difficult to diagnose.
2020-06-18 17:58:45 -04:00
Alisdair McDiarmid 0ed04d05aa command: Fix command fixture modify-in-place bugs
Some of the tests in the command package were running directly on the
fixture directories, and modifying or locking files within them. This
could cause state to leak between tests.

This commit cleans up all such cases that I could find.
2020-06-18 17:09:20 -04:00
James Bardin fb06063b2b don't set remote workspace in state
The workspace attribute is not computed, and cannot be changed from the
configuration.
2020-06-18 16:34:57 -04:00
Martin Atkins dc8fd14c1e website: "Provider Requirements" documentation
We previously covered everything about using providers on a single page,
but that was getting unwieldy already and we now have a lot more to
discuss with v0.13 introducing a new source address syntax and some other
concepts.

Here we split the provider-related content into two parts: "Provider
Requirements" covers how to find and declare dependencies on providers,
and then "Provider Configuration" (formerly just "Providers") then focuses
primarily on how to write zero or more provider configurations for a
particular provider.

Because "Provider Requirements" is now presented before "Provider
Configuration" in the navigation, I've also moved some of the introductory
content about providers in general onto the "Requirements" page. The
first paragraph of that content is duplicated onto the "Configuration"
page for discoverability, but we now link to the requirements page to get
the full story.
2020-06-18 09:31:52 -07:00
Nick Fagerlund b1eb9dcfcf website: Configuration Language navigation refactoring
The "Configuration Language" section was becoming rather unweildy, both
by having a lot of pages and by some of the pages being quite large in
themselves.

This is a first step towards breaking things up a little more, starting
with two changes:

 - The "Configuration Language" navigation is now split into two
   sub-headings "Configuration Blocks" and "Syntax".

 - Some of the information about sub-blocks of the "terraform" block are
   now given their own pages, because their content is quite complex
   in itself.

 - "Version Constraints" is now a page in its own right, rather than this
   content being duplicated in slightly different forms across multiple
   contexts that make use of user-specified version constraints.
2020-06-18 09:31:52 -07:00
Matt Schuchard 86a511e257
update hcl language markdown to terraform markdown 2020-06-18 12:30:36 -04:00
Alisdair McDiarmid aefead2207
Update CHANGELOG.md 2020-06-18 10:29:58 -04:00
Alisdair McDiarmid c12ad38c5d
Merge pull request #25277 from hashicorp/alisdair/fix-terraform-version-version
command: Fix bug with -v/-version/--version flags
2020-06-18 10:21:31 -04:00
Chris Griggs ea24faa9ac
Merge pull request #25290 from hashicorp/cgriggs01-azuredevops
[Website] Azure DevOps provider links
2020-06-18 07:04:30 -07:00
Chris Griggs 207b10278a [Website] Azure DevOps provider links 2020-06-18 06:51:32 -07:00
Chris Griggs bc569eb083
Merge pull request #25278 from hashicorp/cgriggs01-mso
[Website] Cisco MSO provider links
2020-06-17 14:27:31 -07:00
Chris Griggs 24e1c9eff5 [Website] Cisco MSO provider links 2020-06-17 14:00:20 -07:00
Alvin Huang d4c055dea4
Merge pull request #25275 from hashicorp/ci/fix-go-mod-updating
don't update deps of gox in docker build and use -mod=readonly
2020-06-17 16:25:20 -04:00
Alvin Huang ada89661d5 don't update deps of gox in docker build and use -mod=readonly 2020-06-17 15:34:30 -04:00
Alisdair McDiarmid 163c943e9b command: Fix bug with -v/-version/--version flags
We globally support a -v/-version/--version flag, which triggers the
version subcommand. The recent introduction of JSON output support meant
we started parsing the flags for the first time, but we didn't add flags
for these global version arguments.

This commit adds those flags (but doesn't check them, since they have no
effect on the version command itself). Also adds usage information for
terraform version.
2020-06-17 15:24:15 -04:00