Commit Graph

109 Commits

Author SHA1 Message Date
Li Kexian 76e5b446ba
backend/cos: Add TencentCloud backend cos with lock (#22540)
* add TencentCloud COS backend for remote state

* add vendor of dependence

* fixed error not handle and remove default value for prefix argument

* get appid from TF_COS_APPID environment variables
2020-02-13 11:37:11 -05:00
Alisdair McDiarmid 081f02971d command/logout: Add terraform logout command
Use terraform logout to remove stored credentials for a remote service
host.
2020-02-06 15:00:55 -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
Nick Fagerlund a797152648 website: Remove extra copy of "Running Terraform in Automation", update links
This document now lives at:

- https://learn.hashicorp.com/terraform/development/running-terraform-in-automation

...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
Martin Atkins 778f1ab138
website: Documentation for the "terraform login" command (#22727)
Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2020-02-04 11:30:40 -05: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
George Christou 91100c003c lang/funcs: Add more `trim*` functions (#23016)
* lang/funcs: Add `trim*` functions
2019-11-18 08:31:44 -05:00
Justin Campbell 07624eeb31
website: Add Terraform Registry Provider Docs page (#23139)
Co-Authored-By: Kim Ngo <kngo@hashicorp.com>
Co-Authored-By: Nick Fagerlund <nick@hashicorp.com>
2019-10-28 16:05:22 -04:00
Nick Fagerlund f6e648cc8b website: Document behavior of `self` object for provisioners 2019-10-03 15:12:18 -07:00
Jeet Parekh bcc69c05bb lang/funcs: parseint function 2019-09-17 15:33:22 -07:00
Kristin Laemmert 212d5b0b1c
Mildwonkey/docs updates (#22623)
* website/formatdate: update example

The given example was showing HOUR:MONTH instead of HOUR:MINUTE

Fixes #22598

* website/import: remove reference to no-longer-working option

Users can no longer supply `-config=""` to tell Terraform not to load
configuration for import.

Fixes #22294

* website/provisioners: `host` is required in connection blocks

Fixes #21877

* website/variables: clarify variable definition precedence

It was not entirely obvious that a variable could not be assigned
multiples times in a single source.

Fixes #21682

* website/backend/local: add `workspace_dir` attribute

Fixes #21391

* website/output: `sensitive` outputs are redacted in output

Fixes #21502

* website/backends: sidebar order tweak

It makes sense for backend 'configuration' to appear before 'init'.

Fixes #13796

* Revert "website/formatdate: update example"

This reverts commit ccd93c86ddd15a21625c0767702ee1cc62e77254.
2019-08-28 15:34:22 -04:00
Brian Flad d48d9ed766
lang/funcs: Add fileset function
Reference: https://github.com/hashicorp/terraform/issues/16697

Enumerates a set of regular file names from a given glob pattern. Implemented via the Go stdlib `path/filepath.Glob()` functionality. Notably, stdlib does not support `**` or `{}` extended patterns. See also: https://github.com/golang/go/issues/11862

To support the extended glob patterns, it will require adding a dependency on a third party library or adding our own matching code.
2019-08-20 04:50:01 -04:00
Nick Fagerlund 3aa909ac6e website: Update URLs and name references for Terraform Cloud rebrand
The Terraform Enterprise brand has now been split into two parts:

- Terraform Cloud is the application that helps teams use Terraform together,
  with remote state storage, a shared run environment, etc.
- Terraform Enterprise is the on-premise distribution that lets enterprises run
  a private instance of the Terraform Cloud application.

The former TFE docs have been split accordingly.
2019-08-16 15:55:29 -07:00
Martin Atkins 135afaeb9c lang: "regex" and "regexall" functions
These existing upstream cty functions allow matching strings against
regular expression patterns, which can be useful if you need to consume
a non-standard string format that Terraform doesn't (and can't) have a
built-in function for.
2019-08-06 11:52:14 -07:00
Andreas Sommer 042aead714 lang/funcs: add "abspath" function (#21409) 2019-07-02 08:30:30 -04:00
Kristin Laemmert 0f6b46bd93
website: add puppet provisioner to the sidebar (#21821) 2019-06-20 09:02:23 -04:00
James Bardin 877b4a1587 missing link to OSS backend 2019-06-13 18:00:38 -04:00
Lars Eric Scheidler aa07806bfc lang/funcs: New "uuidv5" function
This generates name-based uuids, rather than pseudorandom uuids as with the
"uuid" function.
2019-06-07 14:38:22 -07:00
Martin Atkins 382e1ca821 lang: yamldecode and yamlencode functions
These follow the same principle as jsondecode and jsonencode, but use
YAML instead of JSON.

YAML has a much more complex information model than JSON, so we can only
support a subset of it during decoding, but hopefully the subset supported
here is a useful one.

Because there are many different ways to _generate_ YAML, the yamlencode
function is forced to make some decisions, and those decisions are likely
to affect compatibility with other real-world YAML parsers. Although the
format here is intended to be generic and compatible, we may find that
there are problems with it that'll we'll want to adjust for in a future
release, so yamlencode is therefore marked as experimental for now until
the underlying library is ready to commit to ongoing byte-for-byte
compatibility in serialization.

The main use-case here is met by yamldecode, which will allow reading in
files written in YAML format by humans for use in Terraform modules, in
situations where a higher-level input format than direct Terraform
language declarations is helpful.
2019-06-04 16:24:09 -07:00
Martin Atkins f9a73d48db lang: "range" function
This is similar to the function of the same name in Python, generating a
sequence of numbers as a list that can then be used in other
sequence-oriented operations.

The primary use-case for it is to turn a count expressed as a number into
a list of that length, which can then be iterated over or passed to a
collection function to produce that number of something else, as shown
in the example at the end of its documentation page.
2019-06-04 16:20:17 -07:00
Kristin Laemmert b1d0b1383f
lang/funcs: remove sethaselement function and documentation (#21164)
`contains` and `sethaselement` are effectively the same function, and
`contains` works with `sets` thanks to automatic HCL conversion.
2019-05-02 10:47:19 -04:00
Kristin Laemmert 394cf7f25e
lang/funcs: add acc tests for functions (#21112)
* lang/funcs: testing of functions through the lang package API
The function-specific unit tests do not cover the HCL conversion that happens when the functions are called in a terraform configuration. For e.g., HCL converts sets to lists before passing it to the function. This means that we could not test passing a set in the function _unit_ tests.
This adds a higher-level acceptance test, plus a check that every (pure) function has a test.

* website/docs: update function documentation
2019-04-29 13:11:28 -04:00
Kit Ewbank efc08de5d6 lang/funcs: add 'strrev' interpolation function. (#21091) 2019-04-24 14:52:39 -04:00
Nick Fagerlund b4042947d1 website: null_resource isn't a type of provisioner
This page is useful, but it's easier to tell what it's for if we
put it next to the page about connections.
2019-04-15 14:11:02 -07:00
Nick Fagerlund 88982fdbc3
website: in functions sidebar, default lists to collapsed (#20945)
Find-in-page is still supported with the 'expand/collapse all' control.
2019-04-11 16:54:18 -07:00
Nick Fagerlund 53cff99f84
website: Add `workspace show` command to sidebar nav (#20800) 2019-03-22 15:06:53 -07:00
Martin Atkins 096b1bb87b lang/funcs: Port the "reverse" function from the old functions set
This has the same functionality as the "reverse" function that was
implemented in the "config" package, but adapted to the new language type
system.
2019-03-19 17:32:19 -07:00
PenelopeFudd 247faca59d website: formatdate function in the navigation sidebar 2019-03-15 09:51:47 -07:00
Nick Fagerlund 13166df619 website: move docs/index.html to docs/cli-index.html
Terraform is way bigger than the core CLI tools and the language
now, and the docs have grown accordingly. So we're adding a
global index page to help users get around the many sections of the
docs site, and bumping the CLI/core docs down so they're no longer at the
top of the hierarchy.

The "right" (as in, conceptually pure) way to do this would be to actually
create a new level of directory hierarchy in between. But that would be real
expensive and annoying — the amount of 301s and links to edit would be
monumental, and it wouldn't gain us much beyond a certain picture-straightening
satisfaction, so I'm resisting the temptation.
2019-03-15 13:00:58 +00:00
Nick Fagerlund 094a5d65d3 website: Use a middleman partial for "other docs" list instead of hardcoding it
This relies on a commit in the terraform-website repo, and should make updating
that list much less annoying.
2019-03-14 10:38:07 +00:00
David Chwalisz ddb7e0ab20 fix `Publishing Modules` link of website documentation.
Currently links to [Creating Modules](https://www.terraform.io/docs/modules/create.html) page.
Should link to [Publishing Modules](https://www.terraform.io/docs/modules/publish.html) page.

fixes #20636
2019-03-11 08:20:35 -07:00
Martin Atkins 9336c7fba3 website: Revamped module-authoring docs for Terraform v0.12
As well as some general consolidation and reorganizing, this also includes
some updated advice for making the best use of new Terraform v0.12
features to create infrastructure building-blocks.

In particular, the "Module Usage" documentation is now consolidated into
the configuration section in order to bring all of our general language
documentation together, and the top-level "Modules" section is now
primarily focused on module _authors_ as an audience, covering topics such
as publishing modules and designing them for reuse.
2019-03-05 14:14:06 -08:00
Kristin Laemmert 5ebf8b2992
website: fix link (#20501) 2019-02-27 12:21:20 -08:00
Kristin Laemmert f44e4b2c6a
website: add documentation for terraform providers schema (#20468)
* website: add documentation for terraform providers schema
2019-02-27 11:08:31 -08:00
James Bardin eada955721
Merge pull request #19070 from mars/postgres-backend
Postgres backend
2019-02-26 20:20:01 -05:00
Martin Atkins f4bc502f51 website: Documentation for "terraform 0.12upgrade" 2019-02-26 10:27:51 -08:00
Mars Hall 312d408f06 📚 pg backend docs 2019-02-22 13:51:57 -08:00
Nick Fagerlund 01eb224469 website: Large, on-brand link preview image for marketing pages (/intro/*)
Although /intro/getting-started includes docs content, those pages currently
redirect to the Learn platform, and so shouldn't be affected by the large unfurl
image.
2019-02-22 10:09:09 -08:00
Nick Fagerlund 0a58004da4 website: Add JSON output format to nav sidebar 2019-02-20 18:40:44 -08:00
Nick Fagerlund d1daa7e518 website: Make 0.11 and 0.12 subsections of 'Configuration Language' 2019-02-01 17:20:54 -08:00
Nick Fagerlund a9bcc0fe06 website: Fix sidebar nav links and 'sidebar_current' IDs for 0.11 docs
Because of the different possibilities for arranging the nav sidebars, we want
to make sure:

- IDs for the 0.11 and 0.12 language docs have a common prefix.
- That prefix is not the exact string `docs-config`.

Have I mentioned before that I really dislike this prefix matching behavior.
2019-02-01 17:20:54 -08:00
Nick Fagerlund 11cfdf3b67 website: Add 0.11 configuration language docs (WIP)
This is a non-working commit, because a bunch of links (including the sidebar
nav) are broken. Using a transition commit like this makes it easier to see the
changes necessary to get this content woven into the site.
2019-02-01 17:20:54 -08:00
Nick Fagerlund 0fddabf972 website: Reorganize nav sidebars to improve jumps between sections 2019-01-31 16:18:23 -08:00
Martin Atkins 954d38e870 lang: New file-hashing functions
In prior versions, we recommended using hash functions in conjunction with
the file function as an idiom for detecting changes to upstream blobs
without fetching and comparing the whole blob.

That approach relied on us being able to return raw binary data from
file(...). Since Terraform strings pass through intermediate
representations that are not binary-safe (e.g. the JSON state), there was
a risk of string corruption in prior versions which we have avoided for
0.12 by requiring that file(...) be used only with UTF-8 text files.

The specific case of returning a string and immediately passing it into
another function was not actually subject to that corruption risk, since
the HIL interpreter would just pass the string through verbatim, but this
is still now forbidden as a result of the stricter handling of file(...).

To avoid breaking these use-cases, here we introduce variants of the hash
functions a with "file" prefix that take a filename for a disk file to
hash rather than hashing the given string directly. The configuration
upgrade tool also now includes a rule to detect the documented idiom and
rewrite it into a single function call for one of these new functions.

This does cause a bit of function sprawl, but that seems preferable to
introducing more complex rules for when file(...) can and cannot read
binary files, making the behavior of these various functions easier to
understand in isolation.
2019-01-25 10:18:44 -08:00
Martin Atkins 2f8f7d6f4d lang/funcs: Type conversion functions
It's not normally necessary to make explicit type conversions in Terraform
because the language implicitly converts as necessary, but explicit
conversions are useful in a few specialized cases:

- When defining output values for a reusable module, it may be desirable
  to force a "cleaner" output type than would naturally arise from a
  computation, such as forcing a string containing digits into a number.
- Our 0.12upgrade mechanism will use some of these to replace use of the
  undocumented, hidden type conversion functions in HIL, and force
  particular type interpretations in some tricky cases.
- We've found that type conversion functions can be useful as _temporary_
  workarounds for bugs in Terraform and in providers where implicit type
  conversion isn't working correctly or a type constraint isn't specified
  precisely enough for the automatic conversion behavior.

These all follow the same convention of being named "to" followed by a
short type name. Since we've had a long-standing convention of running all
the words together in lowercase in function names, we stick to that here
even though some of these names are quite strange, because these should
be rarely-used functions anyway.
2019-01-17 10:01:47 -08:00
Martin Atkins da51e72cbb lang/functions: set functions from cty
The sethaselement, setintersection, and setunion functions are defined in
the cty stdlib. Making them available in Terraform will make it easier to
work with sets, and complement the currently-Terraform-specific setproduct
function.

In the long run setproduct should probably move into the cty stdlib too,
but since it was submitted as a Terraform function originally we'll leave
it here now for simplicity's sake and reorganize later.
2019-01-16 09:57:16 -08:00
Martin Atkins edb5f82de1 lang/funcs: Convert the "setproduct" function to the new approach
In our new world it produces either a set of a tuple type or a list of a
tuple type, depending on the given argument types.

The resulting collection's element tuple type is decided by the element
types of the given collections, allowing type information to propagate
even if unknown values are present.
2019-01-16 09:57:16 -08:00
Nick Fagerlund ac45e43fda website: Finish moving "writing custom providers" to /docs/extend/
This document was previously copied to the "Extending Terraform" section (in the
terraform-website repo), and the old URL was redirected so that the copy in
/guides can no longer be reached on the website. But the old copy of the file
remained, and now it runs the risk of confusing contributors, since the copy in
terraform-website/.../docs/extend is the more up-to-date version.
2019-01-11 16:36:40 -08:00
Martin Atkins c753df6a93 lang/funcs: templatefile function
This function is similar to the template_file data source offered by the
template provider, but having it built in to the language makes it more
convenient to use, allowing templates to be rendered from files anywhere
an inline template would normally be allowed:

    user_data = templatefile("${path.module}/userdata.tmpl", {
      hostname = format("petserver%02d", count.index)
    })

Unlike the template_file data source, this function allows values of any
type in its variables map, passing them through verbatim to the template.
Its tighter integration with Terraform also allows it to return better
error messages with source location information from the template itself.

The template_file data source was originally created to work around the
fact that HIL didn't have any support for map values at the time, and
even once map support was added it wasn't very usable. With HCL2
expressions, there's little reason left to use a data source to render
a template; the only remaining reason left to use template_file is to
render a template that is constructed dynamically during the Terraform
run, which is a very rare need.
2018-12-21 08:06:14 -08:00