OpenTofu lets you declaratively manage your cloud infrastructure.
Go to file
Martin Atkins 6f0bd52d3d configs+tofu: alternative check block style with error_messages
The original design for check blocks was a boolean argument "condition"
which returns true for valid and false for invalid, and then a separate
string argument "error_message" whose value is displayed as part of an
error diagnostic if the value is found to be invalid.

That design has worked well for simple primitive-typed variables, but it's
annoying for variables of collection types because in that case we
typically want to apply a validation rule to each element and then mention
in the error messages exactly which elements were invalid, which requires
both a complicated "condition" expression _and_ a very similar complicated
"error_message" expression to repeat essentially the same steps to find
out which elements were invalid.

This change is a prototype for an optional new design where the block
contains only a single argument error_messages that deals with both the
condition and the error message generation at the same time. Its expression
must return a list of strings where an empty list represents "valid" and
a non-empty list represents "invalid". In the invalid case, each element
is returned as a separate error diagnostic.

This means that module authors can use a "for" expression with an "if"
clause to filter out all of the valid elements and to project any invalid
elements into an error messages describing what is wrong with them.

In principle this could also be used with new provider-defined functions
that are designed to take a value and return a list of problems with that
value, such as in a hypothetical provider that implements JSON schema-based
validation of a data structure using an externally-provided schema.

This is only a prototype so the test coverage is rudimentary and it only
currently works for input variable validation. If we decide that we'd like
to implement something like this for real then we'll want to extend it to
work for all of the other kinds of checks -- test assertions, "check"
block assertions, and preconditions/postconditions -- since the language
design intent is for those to all appear to have essentially the same
treatment, despite not all of the code currently being shared between
them.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-01-30 18:21:16 -08:00
.github Switch to native Linux/ARM64 runners (#2387) 2025-01-24 10:43:47 -05:00
cmd/tofu Another batch of minor typos (#1953) 2024-09-09 07:51:39 -04:00
docs tfplugin5+tfplugin6: Update to latest protocol schema 2025-01-09 16:16:58 -08:00
internal configs+tofu: alternative check block style with error_messages 2025-01-30 18:21:16 -08:00
rfc rfc: Update README.md to discuss RFC Tracking Issues (#2377) 2025-01-15 07:36:54 -05:00
scripts Fix typos (#1905) 2024-08-29 13:20:33 -04:00
testing Fix typos (#1905) 2024-08-29 13:20:33 -04:00
tools Replace mock module with go.uber.org/mock (#1673) 2025-01-10 08:29:20 -05:00
version Bump main to 1.10.0-alpha1 now that 1.9 has been branched (#2291) 2024-12-12 12:13:54 -05:00
website Add example on supporting both OpenTofu and Terraform versions to version-constraints.mdx (#2302) 2025-01-24 12:48:11 -05:00
.copywrite.hcl ignore any lock file on license header check (#1776) 2024-07-08 15:27:11 +03:00
.devcontainer.json Update .devcontainer.json go's version to 1.22 (#2385) 2025-01-17 15:45:56 +01:00
.gitignore Bug Fix #1403 - Set grade and channel correctly (#1450) 2024-04-09 10:41:35 -04:00
.go-version Bumping Go version to address CVE-2024-45336 and CVE-2024-45341 (#2438) 2025-01-28 21:40:13 +01:00
.golangci-complexity.yml Temporarily disable the complexity-related lint rules 2025-01-03 10:41:05 -05:00
.golangci.yml Temporarily disable the complexity-related lint rules 2025-01-03 10:41:05 -05:00
.goreleaser.yaml Fixes #2356: Minimal base image (#2375) 2025-01-15 13:46:34 +01:00
.licensei.toml feat: add license checks on dependencies (#310) 2023-09-13 19:10:41 +03:00
.tfdev Rename github.com/placeholderplaceholderplaceholder/opentf to github.com/opentofu/opentofu (#461) 2023-09-20 14:35:35 +03:00
CHANGELOG.md Add a new go-getter detector wrapper that can remove the query params before giving the src to the actual detector (#2451) 2025-01-30 17:20:25 +02:00
CODE_OF_CONDUCT.md Update core team email. (#752) 2023-10-19 12:03:39 +02:00
codecov.yml Update copyright notice (#1232) 2024-02-08 09:48:59 +00:00
CODEOWNERS Add MAINTAINER and update CODEOWNERS (#919) 2023-11-24 14:08:53 +01:00
CONTRIBUTING.md Update CONTRIBUTING.md: Update 'docker run' example (#2005) 2024-09-23 07:23:32 -04:00
CONTRIBUTING.RELEASE.md Adding warning to the release documentation (#2434) 2025-01-28 13:11:09 +01:00
Dockerfile OpenTofu 1.10: Disable usage of ghcr.io image as a base image (#1994) 2025-01-07 10:08:23 -05:00
Dockerfile.minimal Fixes #2356: Minimal base image (#2375) 2025-01-15 13:46:34 +01:00
go.mod build(deps): bump github.com/hashicorp/go-slug from 0.15.0 to 0.16.3 2025-01-22 13:16:27 -08:00
go.sum build(deps): bump github.com/hashicorp/go-slug from 0.15.0 to 0.16.3 2025-01-22 13:16:27 -08:00
LICENSE Update copyright notice (#1232) 2024-02-08 09:48:59 +00:00
MAINTAINERS update MAINTAINERS file (#2341) 2025-01-08 10:52:42 +01:00
Makefile Update lint make target to match CI (#2025) 2024-10-02 08:26:27 -04:00
README.md [TSC] summary for TSC meetings in August (#1935) 2024-08-27 16:03:56 +02:00
RELEASE.md Creates RELEASE.md (#1758) 2024-09-04 07:14:32 -04:00
SECURITY.md Added Security disclousure policy (#749) 2023-10-19 15:27:59 -07:00
tools.go add automated copyright header check (#1696) 2024-06-03 16:49:36 +03:00
TSC_SUMMARY.md Update TSC_SUMMARY.md (#2279) 2024-12-11 08:40:19 -08:00
WEEKLY_UPDATES.md Weekly update 2024-10-11 (#2068) 2024-10-11 15:20:00 +02:00

OpenTofu

OpenTofu is an OSS tool for building, changing, and versioning infrastructure safely and efficiently. OpenTofu can manage existing and popular service providers as well as custom in-house solutions.

The key features of OpenTofu are:

  • Infrastructure as Code: Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

  • Execution Plans: OpenTofu has a "planning" step where it generates an execution plan. The execution plan shows what OpenTofu will do when you call apply. This lets you avoid any surprises when OpenTofu manipulates infrastructure.

  • Resource Graph: OpenTofu builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, OpenTofu builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

  • Change Automation: Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what OpenTofu will change and in what order, avoiding many possible human errors.

Getting help and contributing

Tip

For more OpenTofu events, subscribe to the OpenTofu Events Calendar!

Reporting security vulnerabilities

If you've found a vulnerability or a potential vulnerability in OpenTofu please follow Security Policy. We'll send a confirmation email to acknowledge your report, and we'll send an additional email when we've identified the issue positively or negatively.

If you believe you have found any possible copyright or intellectual property issues, please contact liaison@opentofu.org. We'll send a confirmation email to acknowledge your report.

Registry Access

In an effort to comply with applicable sanctions, we block access from specific countries of origin.

License

Mozilla Public License v2.0