Commit Graph

27973 Commits

Author SHA1 Message Date
Ben Moskovitz 21228e19df Fix broken links as pointed out by CI
See: https://app.circleci.com/pipelines/github/hashicorp/terraform/6853/workflows/cc37def1-6bf5-4f6c-89b1-10dfcc65ea5e/jobs/44887
2021-06-30 16:55:00 +12:00
Ben Moskovitz d29cdccb5b Add a note to the docs on the S3 backend around permissions needed for encrypted state storage 2021-06-30 16:45:17 +12:00
James Bardin 0750a16cce
Merge pull request #28072 from hashicorp/jbardin/provider-meta-interpolation
validate provider_meta contains no interpolations
2021-03-12 17:12:58 -05:00
Martin Atkins dc7f2b7314 website: docs for the terraform validate JSON output 2021-03-12 09:39:56 -08:00
James Bardin 759b76436a validate provider_meta contains no interpolations
The provider_meta specification does not allow interpolation, but we
were not preventing it in the configuration.
2021-03-12 12:10:25 -05:00
Kristin Laemmert b26ae9cf48
add support for attributes with nested types in providers schema (#28055)
This PR extends jsonprovider to support attributes with NestedTypes and extends test coverage in jsonprovider and the providers schemas tests. I've also cleaned up some comments and extracted the logic to parse the nesting mode so it can be used in both marshalling blocks and attributes.
2021-03-12 08:28:22 -05:00
Nick Fagerlund 42c6c5dd6c
Merge pull request #28035 from antoineco/hcl-spec-link
docs: Update link to HCL native syntax spec
2021-03-11 11:03:01 -08:00
Pam Selle 242f319638
Give suggestions & remind users to use required_providers when provider not in registry (#28014)
* Add helper suggestion when failed registry err

When someone has a failed registry error on init, remind them that
they should have required_providers in every module

* Give suggestion for a provider based on reqs

Suggest another provider on a registry error, from the list of
requirements we have on init. This skips the legacy lookup
process if there is a similar provider existing in requirements.
2021-03-11 08:54:18 -05:00
James Bardin c5428959b5
Merge pull request #28043 from hashicorp/jbardin/missing-deposed-state
do not panic if there is no deposed state
2021-03-11 08:52:43 -05:00
James Bardin 1d4e1ed2b7 do not panic if there is no deposed state
NodeDestroyDeposedResourceInstanceObject should not panic if the deposed
state no longer exists.
2021-03-10 16:48:30 -05:00
Antoine Cotten 3442873cdb
docs: Update link to HCL native syntax spec 2021-03-10 17:47:21 +01:00
James Bardin e5538693ce
Merge pull request #28017 from hashicorp/jbardin/data-destroy-deps-2
destroying data source does not require a provider
2021-03-09 12:59:25 -05:00
Masayuki Morita 31a5aa1878
command/init: Add a new flag `-lockfile=readonly` (#27630)
Fixes #27506

Add a new flag `-lockfile=readonly` to `terraform init`.
It would be useful to allow us to suppress dependency lockfile changes
explicitly.

The type of the `-lockfile` flag is string rather than bool, leaving
room for future extensions to other behavior variants.

The readonly mode suppresses lockfile changes, but should verify
checksums against the information already recorded. It should conflict
with the `-upgrade` flag.

Note: In the original use-case described in #27506, I would like to
suppress adding zh hashes, but a test code here suppresses adding h1
hashes because it's easy for testing.

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2021-03-09 11:12:00 -05:00
James Bardin e6ab48addf test data source destroy with no provider 2021-03-08 21:43:47 -05:00
James Bardin 58b085f0dc prune unused providers from the graph, again
The provider transformers remove extra provider nodes when they are
initially setup, but it may turn out that they are not used later on.

The pruneUnusedNodesTransformer takes care of removing unused expansion
nodes, which originally required a provider, and hence may cause some
provider nodes to no longer be needed. We can also detect these and
remove them during the pruneUnusedNodesTransformer process.
2021-03-08 21:43:47 -05:00
James Bardin 7674e19d4e data source destroy nodes do not need a provider
Removing a data source is a state-only operation, and the node itself
does not require a provider.
2021-03-08 15:40:31 -05:00
James Bardin 3c6b2a8780 rename attachDataResourceDependsOnTransformer
Clarify the use of this transformer, interface and method which now does
not apply to anything but `depends_on` for data sources,
2021-03-08 15:39:09 -05:00
Alisdair McDiarmid 98899df514
Merge pull request #27979 from hashicorp/alisdair/defaults-fixes
functions: Fix panics in defaults
2021-03-05 14:39:50 -05:00
Alisdair McDiarmid ac8c6c1aa7
Merge pull request #27998 from hashicorp/alisdair/faster-addr-equals
core: Reduce string allocations for addrs Equal
2021-03-05 14:39:39 -05:00
Alisdair McDiarmid a43b035a51 core: Reduce string allocations for addrs Equal
Generating strings and comparing them to implement Equal is a quick and
easy solution. Unfortunately when this code is in the hot path, it
becomes very expensive, so this commit changes some of those instances
to compare the values directly.

Combined with using addr.Equal instead of checking for string equality,
this makes Terraform dramatically faster for some operations, such as
generating large JSON plans.
2021-03-05 13:23:32 -05:00
Alisdair McDiarmid 3d8b43dfe7
Merge pull request #27944 from hashicorp/alisdair/fix-missing-source-in-diags
views: Fix missing source in diagnostic output
2021-03-04 12:28:42 -05:00
Alisdair McDiarmid 66f8d1c1c2 functions: Fix defaults mismatched types fallback
We allow primitive fallback values which have mismatched types, but only
if there is a conversion to the target type. Previously we would allow
unsafe conversions (e.g. string to bool), but later had no capacity to
return an error if the conversion failed due to the value of the
fallback being unable to convert to the target type.

This commit makes the more conservative requirement that default
fallback values must have a safe conversion.
2021-03-04 10:43:09 -05:00
Alisdair McDiarmid 178a9b32d7 functions: Fix defaults null collections panic
When applying default values to collection types, null collections in
the input should result in empty collections in the output.
2021-03-04 10:13:41 -05:00
Omar Ismail e9c7f37b8c
Enable --auto-approve for Policy checks on Remote Backend (Terraform Cloud) (#27804)
* Fix auto-approve for soft-policy
* Update error handling
* update testing string for consistency
2021-03-01 08:54:30 -05:00
Alisdair McDiarmid 86495f93cb views: Fix missing source in diagnostic output
The previous implementation of views was copying and embedding the base
View struct in each individual view. While this allowed for easy access
to the interface of that struct (both in the view and externally), it more
importantly completely broke the ability of the diagnostic printer to
output source code snippets.

This is because the `configSources` field on the base view is lazily set
after the config loader is initialized. In the commands ported to use
views, this happens after the base View struct is copied, so we are
updating the wrong copy of the struct.

This commit fixes this with a simple mechanical refactor: keep a pointer
to the base View struct instead, and update all of the individual views
to explicitly refer to that struct to access its fields and methods.

This is not a particularly satisfying solution, but I can't find
anything clearly better. It might be worth exploring the alternative
approach in the view for the new test command, which explicitly pulls
its dependencies out of the base view, rather than retaining a full
reference. Maybe there's a third way which is better still.
2021-02-26 16:43:03 -05:00
Martin Atkins b5adc33075 configs: Accept and minimally validate a "language" argument
We expect that in order to continue to evolve the language without
breaking existing modules we will at some point need to have a way to mark
when a particular module is expecting a newer interpretation of the
language.

Although it's too early to do any deep preparation for that, this commit
aims to proactively reserve an argument named "language" inside
"terraform" blocks, which currently only accepts the keyword TF2021 that
is intended to represent "the edition of the Terraform language as defined
in 2021".

That argument also defaults to TF2021 if not set, so in practice there's
no real reason to set this today, but this minimal validation today is
intended to give better feedback to users of older Terraform versions in
the event that we introduce a new language edition later and they try to
use an module incompatible with their Terraform version.
2021-02-26 11:43:32 -08:00
Martin Atkins 54cc4dadf6 configs: A better error message for custom variable validation
Our previous message conflated the requirement for a full sentence with
the suggestion to write in a style similar to Terraform's built-in error
messages, which created a sense that the system would actively reject an
error message written in another language.

There's no intent here to block writing error messages in other languages,
but there is a practical consideration that Terraform's UI output is
currently not localized and so consistency with Terraform's other output,
if that's important to a module author, will typically mean writing the
error message in English.
2021-02-26 09:36:42 -08:00
Aaron Lane f172585eaa Fix Kitchen-Terraform language in test experiment
This isn't incredibly important, but Kitchen-Terraform is written in and requires tests to be written in Ruby.
2021-02-25 14:12:00 -08:00
Alisdair McDiarmid 37fff9336a
Merge pull request #27929 from hashicorp/alisdair/command-views-cleanup
Some command views cleanup
2021-02-25 16:26:08 -05:00
Alisdair McDiarmid 7c0ec0107f backend: Replace ShowDiagnostics with view.Diagnostics 2021-02-25 11:26:05 -05:00
James Bardin 1a71cdc132
Merge pull request #27926 from hashicorp/jbardin/apply-plan-config
check errors before using configSnap
2021-02-25 10:10:13 -05:00
James Bardin 936f597ba1 check errors before using configSnap
configSnap may be nil if there are errors loading it from the plan file.
2021-02-25 09:54:02 -05:00
Alisdair McDiarmid 3737ee5081 views: Remove outdated comment 2021-02-25 09:34:32 -05:00
Kristin Laemmert c99d02f326
update arch docs; remove old EvalNode references (#27900)
* update arch docs; remove old EvalNode and EvalTree references
2021-02-24 16:19:55 -05:00
James Bardin a0ca99201c
Merge pull request #27918 from hashicorp/jbardin/go-version
Revert "match terraform-releases expectations"
2021-02-24 16:17:49 -05:00
James Bardin 9ea805f480 Revert "match terraform-releases expectations"
This reverts commit 270de49ef5.
2021-02-24 14:33:24 -05:00
James Bardin 55fb442578
Merge pull request #27913 from hashicorp/jbardin/go-version
match terraform-releases expectations
2021-02-24 14:14:58 -05:00
James Bardin 270de49ef5 match terraform-releases expectations 2021-02-24 14:08:12 -05:00
Kristin Laemmert 106bcd3bf0
update to match new default branch name (#27909) 2021-02-24 13:36:47 -05:00
James Bardin 2b252ac677
Merge pull request #27910 from hashicorp/jbardin/remote-provisioners
remote provisioners require a connection config
2021-02-24 13:35:24 -05:00
James Bardin 47a682141a remote provisioners require a connection config 2021-02-24 13:25:58 -05:00
Martin Atkins 45b795b3fd
Update CHANGELOG.md 2021-02-24 10:09:08 -08:00
Alisdair McDiarmid 6697245c18
Update CHANGELOG.md 2021-02-24 12:45:51 -05:00
James Bardin 8c9083d880
Merge pull request #27903 from hashicorp/jbardin/plan-valid-computed
objchange: catch invalidly planned attributes earlier
2021-02-24 12:44:35 -05:00
Alisdair McDiarmid 326583bb6e
Merge pull request #27906 from hashicorp/alisdair/remove-var-args-from-validate
cli: Remove -var/-var-file flags from validate
2021-02-24 12:43:53 -05:00
James Bardin b735d80f1f website: Provider configuration notes for the v0.15 upgrade guide 2021-02-24 09:37:55 -08:00
Martin Atkins 9508ff2630 website: Terraform v0.15 upgrade guide first draft
As usual, we'll continue to iterate on this based on feedback and
questions during the beta period, but this is a first draft intended to
help those who are trying out the first beta.
2021-02-24 09:37:55 -08:00
Alisdair McDiarmid 4271b0e11d cli: Remove -var/-var-file flags from validate
These flags are not used and have been deprecated since 0.12.11.
2021-02-24 12:29:56 -05:00
Kristin Laemmert e5a7586559
moduletest: update provider to match recent provider interface changes (#27904)
this fixes a bad merge on my part
2021-02-24 12:29:45 -05:00
James Bardin cd7fb9bd5a catch invalidly planned attributes earlier
Catch attributes which are planed but not computed separately to provide
a clearer error to provider developers.

The error conditions were previously caught, however it was unclear from
the error text as to _why_ the change was an error. The statements about
value inequality would be incorrect when planning no changes for a value
which should not have been set in the first place.
2021-02-24 12:13:12 -05:00