Commit Graph

237 Commits

Author SHA1 Message Date
Martin Atkins 67311f73fd website: Draw better attention to for and for_each patterns
When helping folks in the community forum, I commonly see questions around
more complex patterns in transforming deep data structures into different
shapes to work with for_each. We have examples of these patterns in the
docs for the functions that they rely on, but they were not previously
very discoverable in the main configuration language documentation
sections.

Here I've moved the "Using Expressions in for_each" subsection on the
Resources page above some of the other sub-sections to hopefully make it
easier to see, and written out in more detail the two specific patterns
that answer a significant number of for_each-related user questions in
the hope that readers will be more likely to realize that the links are
relevant to what their goals.

I also added some more elaboration about the behavior of converting from
list to set in the "Using Sets" subsection, because this feature is often
a user's first encounter with the set data type and I've inferred from
some of the questions I've answered that a number of Terraform users don't
have prior experience with set data types in other languages to draw
assumptions from.

Finally, I added some similar links to the for_each patterns within the
for expression documentation itself, to try to make those examples more
visible to those who might be discovering the documentation in a different
sequence, e.g. by following a deep link shared in an answer to a question
in the community forum.
2020-06-01 14:17:47 -07:00
James Bardin 866449a78a
Merge pull request #25069 from hashicorp/jbardin/depends-on-docs
depends_on doc updates
2020-05-29 16:50:39 -04:00
Martin Atkins d1bc412220 configs: Custom variable validation is no longer experimental
All of the feedback from the experiment described enhancements that can
potentially be added later without breaking changes, so this change simply
removes the experiment gate from the feature as originally implemented
with no changes to its functionality.

Further enhancements may follow in later releases, but the goal of this
change is just to ship the feature exactly as it was under the experiment.

Most of the changes here are cleaning up the experiment opt-ins from our
test cases. The most important parts are in configs/experiments.go and in
experiments/experiment.go .
2020-05-28 16:07:59 -07:00
James Bardin 5d64029275 depends_on doc updates
Update depends_on for modules and data sources.
2020-05-28 16:17:01 -04:00
Garron Kramer f3db1232a0
Update modules.html.md
the -module option is no longer present.
2020-05-25 15:41:45 +03:00
Daniel Dreier 44e3d99409
Merge pull request #24659 from hashicorp/timestamp-doc
specify that `timestamp` returns UTC
2020-05-21 14:30:16 -07:00
Daniel Dreier 5e35dedc2a
Update website/docs/configuration/functions/timestamp.html.md
Co-authored-by: Matthew Sanabria <24284972+sudomateo@users.noreply.github.com>
2020-05-21 14:29:38 -07:00
Daniel Dreier 5f80f6d49d
Merge pull request #24771 from bradleypmartin/issue-24198-update-docs-for-map-type
Update maps docs to reflect v0.12 colon behavior
2020-05-21 14:28:19 -07:00
Daniel Dreier 5ef80b35e3
Merge pull request #24996 from pcleddy/foreach_with_toset_and_list
Example of for_each with list -> set using toset
2020-05-21 14:22:06 -07:00
Pam Selle bfbdb4cb1d
Add docs for provider limitations when expanding modules (#25007)
* Add docs for provider limitations when expanding modules
2020-05-21 14:04:44 -04:00
Paul Leddy 3d17c87698 Example of for_each with list -> set using toset 2020-05-19 16:03:21 -07:00
Jean Dupouy a54bb124a9
website/docs: provider aliases in the JSON format
Fixes #24889
2020-05-13 15:52:26 +02:00
Robin Norwood af5c425360
website: Add link to new learn track in configuration/modules.html (#24847) 2020-05-07 15:52:22 -07:00
Daniel Dreier 7aa97f415d
Fix "additoinal" typo in web site
Fixes 24769
2020-04-27 10:14:27 -07:00
bradleypmartin 0b45a3c83d Update maps docs to reflect v0.12 colon behavior 2020-04-26 17:52:08 -06:00
Martin Atkins c6cbbcb79a website: Initial documentation for provider_installation in the CLI config
This is an initial draft of documentation for this new feature of the
CLI configuration. This is mainly intended as a placeholder for now,
because there are other documentation updates pending for the new provider
namespacing and installation scheme and we'll likely want to revise these
docs to better complement the broader documentation once it's written.
2020-04-23 10:52:01 -07:00
Noah Mercado d4d8812afa
Feature: Sum Function (#24666)
The sum function takes a list or set of numbers and returns the sum of those
numbers.
2020-04-15 14:27:06 -04:00
Namho Kim 9cc658b491 specify that `timestamp` returns UTC 2020-04-13 18:09:05 -07:00
Pam Selle ab101f99df
Merge pull request #24635 from hashicorp/pselle/docs-mod-count
Docs for count/for_each on modules
2020-04-13 18:39:59 -04:00
Pam Selle 608c17d518 Update providers block notes 2020-04-13 12:08:08 -04:00
Fred 76f583ac9f
website/docs: fix broken hcl json spec link (#24630) 2020-04-13 11:15:13 -04:00
Pam Selle 65c4ba9c85 First docs for count/for_each on modules 2020-04-10 15:14:06 -04:00
Eduard Tamsa 534ba630e4
docs(flatten): Fix typos (#24492) 2020-04-10 08:59:17 -04:00
Adam Leskis 4f85a1a6ba
website: fix simple typo (#24415) 2020-03-23 08:55:08 -04:00
Paddy e6592dc710
Add support for provider metadata to modules. (#22583)
Implement a new provider_meta block in the terraform block of modules, allowing provider-keyed metadata to be communicated from HCL to provider binaries.

Bundled in this change for minimal protocol version bumping is the addition of markdown support for attribute descriptions and the ability to indicate when an attribute is deprecated, so this information can be shown in the schema dump.

Co-authored-by: Paul Tyng <paul@paultyng.net>
2020-03-05 16:53:24 -08:00
Martin Atkins 67d95b97ce lang/funcs: templatefile requires valid variable names
Previously the templatefile function would permit any arbitrary string as
a variable name, but due to the HCL template syntax it would be impossible
to refer to one that isn't a valid HCL identifier without causing an
HCL syntax error.

The HCL syntax errors are correct, but don't really point to the root
cause of the problem. Instead, we'll pre-verify that the variable names
are valid before we even try to render the template, and given a
specialized error message that refers to the vars argument expression as
the problematic part, which will hopefully make the resolution path
clearer for a user encountering this situation.

The syntax error still remains for situations where all of the variable
names are correct but e.g. the user made a typo referring to one, which
makes sense because in that case the problem _is_ inside the template.
2020-02-25 10:19:46 -05:00
James Bardin 4185aa93f5 doc typo 2020-02-13 21:27:35 -05:00
James Bardin a765d69fb0
Merge pull request #24032 from hashicorp/jbardin/map-funcs
make the merge function more precise
2020-02-12 10:51:05 -05:00
James Goodhouse 25bfe7337b
lang: add setsubtract function (#23424)
* add setdifference and setsubtract functions and docs
* remove setdifference as it is not implemented correct in underlying lib

* Update setintersection.html.md
* Update setproduct.html.md
* Update setunion.html.md
2020-02-06 12:49:11 -05:00
Nick Fagerlund 6494591ec1 website: Remove extra copy of "Getting Started", update links
This guide now lives at:

- https://learn.hashicorp.com/terraform#getting-started

...and terraform.io has been redirecting to there for quite a while. This commit
removes the extra copy so that the text of the two versions doesn't drift, and
updates existing links to point to the new location.
2020-02-05 14:58:30 -08:00
James Bardin 529271e0be update merge docs to match behavior 2020-02-05 15:47:36 -05:00
Pam Selle 4e0879c486 Document for_each key requirements 2020-01-30 17:18:16 -05:00
Pam Selle 213189c3d0 Use a real resource 2020-01-24 13:47:51 -05:00
Pam Selle 885ff69c50 Update docs to generalize/use fake example vs one that could be misleading 2020-01-24 12:44:07 -05:00
Kristin Laemmert 4c221cbcb9
website: document optional syntax for required_providers setting (#23854) 2020-01-14 07:59:18 -05:00
ZMI-RyanMann 66411b5ca0 website/docs: Updated documentation for range function pseudocode (#23823) 2020-01-13 09:17:47 -05:00
Martin Atkins ff4ea042c2 config: Allow module authors to specify validation rules for variables
The existing "type" argument allows specifying a type constraint that
allows for some basic validation, but often there are more constraints on
a variable value than just its type.

This new feature (requiring an experiment opt-in for now, while we refine
it) allows specifying arbitrary validation rules for any variable which
can then cause custom error messages to be returned when a caller provides
an inappropriate value.

    variable "example" {
      validation {
        condition = var.example != "nope"
        error_message = "Example value must not be \"nope\"."
      }
    }

The core parts of this are designed to do as little new work as possible
when no validations are specified, and thus the main new checking codepath
here can therefore only run when the experiment is enabled in order to
permit having validations.
2020-01-10 15:23:25 -08:00
Martin Atkins 02576988c1 lang: "try" and "can" functions
These are intended to make it easier to work with arbitrary data
structures whose shape might not be known statically, such as the result
of jsondecode(...) or yamldecode(...) of data from a separate system.

For example, in an object value which has attributes that may or may not
be set we can concisely provide a fallback value to use when the attribute
isn't set:

    try(local.example.foo, "fallback-foo")

Using a "try to evaluate" model rather than explicit testing fits better
with the usual programming model of the Terraform language where values
are normally automatically converted to the necessary type where possible:
the given expression is subject to all of the same normal type conversions,
which avoids inadvertently creating a more restrictive evaluation model
as might happen if this were handled using checks like a hypothetical
isobject(...) function, etc.
2020-01-10 15:23:25 -08:00
Pam Selle 76831793d0
Merge pull request #23265 from lucazz/update_docs_for_outputs
Update Output values docs
2019-12-17 07:34:46 -05:00
Pam Selle 3bcea18d1c
Update outputs.html.md 2019-12-17 07:33:11 -05:00
Pam Selle 31b56207e0
Update outputs.html.md 2019-12-17 07:32:22 -05:00
Igor Vodka be89975667
Fix markdown being misused in docs 2019-12-16 16:29:47 +03:00
Martin Atkins bfbd00a23c website: Note about using jsonencode/yamlencode in templatefile
It's a common source of errors to try to produce JSON or YAML syntax
using string concatenation via our template language but to miss some
details like correct string escaping, quoting, required commas, etc.

The jsonencode and yamlencode functions are a better way to generate JSON
and YAML, but it's not immediately obvious that both of these functions
are available for use in external templates (via templatefile) too.

Given that questions related to this come up a lot in our community forum
and elsewhere, it seems worth having a documentation section to show the
pattern of having a template that consists only of a single function call.
2019-12-11 12:57:01 -08:00
Graham Davison e32641c9ce website/docs: Corrects function name in `cidrsubnets` function documentation (#23473) 2019-11-26 07:50:32 -05:00
George Christou 91100c003c lang/funcs: Add more `trim*` functions (#23016)
* lang/funcs: Add `trim*` functions
2019-11-18 08:31:44 -05:00
Yuki Ito 72c910cebc website: Fix typographical errors in the docs for base64sha256/512 2019-11-08 09:43:27 -08:00
Lucas do Amaral Saboya 806397803c
Update Output values docs. 2019-11-02 17:56:16 -03:00
Martin Atkins f8a32f0b83 website: Consistently recommend the required_providers block
Previously we were inconsistent in whether we were recommending the
new required_providers block or the "version" setting inside a "provider"
block.
2019-10-28 15:56:12 -07:00
Martin Atkins 7c110f9cf8 website: provider version constraints in modules 2019-10-28 15:56:12 -07:00
Thomas Alton ddd0d2a442 website: Provider proxy config only supports alias 2019-10-28 15:56:12 -07:00