In order to allow for type constraints to be inserted into arbitrary
expressions using the `convert` function, we need to allow for the use
of primitive type names. Previously `string`, `number`, `bool`, and
`any` would be considered as incomplete resource references, because
there are no constraints on what providers can name resources. However
because you cannot use a standalone resource type name as a reference in
HCL, we can make an exception here for when these identifiers are not
part of a longer traversal.
Variables can be deprecated through the `deprecated` attribute. If set the variable
will emit a diagnostic if a values is passed to it. This entails both root level and
module variables.
Outputs can be deprecated through the `deprecated` attribute as well. If set wherever
the value is used a diagnostic will be emitted. Root level outputs can not be deprecated.
The only acceptable usage of a deprecated output is another deprecated output (forwarding
the deprecation to the module user).
If modules not under your control have deprecation warnings you can add a `suppress_deprecations_warnigns`
attribute to the module call in question to silence any deeply nested warnings.
* chore: Upgrade golang.org/x/crypto - `go get golang.org/x/crypto@v0.44.0`
* chore: Upgrade golang.org/x/crypto in submodules - `make syncdeps`
* chore: Run `make generate`
* chore: Ignore SA4003 linter error globally, as `golang.org/x/tools/cmd/stringer` generates code that breaks this rule when it's used with custom types that have unsigned integers or bytes as the underlying type.
* Add actions to the plans and change
* jsonplan - ignoring LinkedResources for now, those are not in the MVP
* pausing here: we'll work on the plan rendering later
Some updates to staticcheck were catching more errors. Most of these
were format functions without a format string, but rather than adding
more exceptions I just fixed them all. This did also catch some
incorrectly wrapped errors.
Our package addrs ends up getting imported from just about ever other
package in Terraform, because it contains the types we use to talk about
various different kinds of objects. Therefore we typically try to keep its
transitive dependency graph relatively small, because anything it depends
on becomes an indirect dependency of nearly everything else.
A while back we moved the module source address models into package addrs,
which also brought with them the code for parsing strings to produce those
addresses. Unfortunately, remote module source addresses are defined using
the external dependency go-getter, which is pretty heavy itself and also
brings with it numerous other external dependencies such as the AWS SDK,
the Google Cloud Platform SDK, etc.
Since only relatively few packages actually need to _parse_ source
addresses -- with most either not caring about them at all or only
consuming addresses that were already parsed by someone else -- we'll
move the parser functions into their own package, while keeping the
resulting address types in package addrs.
This does still retain the package addrs dependency on external module
github.com/hashicorp/terraform-registry-address, which is not ideal but
that one at least has a relatively shallow dependency subgraph, so there's
not so much urgency to tidy that one.
This is kinda awkward because this address type represents both resources
whose own instances are not expanded yet and resources belonging to whole
modules whose instance keys haven't been expanded yet, and those two cases
have different address types.
However, in return for this awkward API only for the rare case where we
need to isolate the module instance address, the rest of the system gets
to not worry very much about this distinction: it can share most code
between the two cases, since they both need similar evaluation treatment
anyway.
This is just a variation of the pre-existing ModuleInstance.Call that
returns its result as a single value of type AbsModuleCall.
This should really have been the signature of ModuleInstance.Call in the
first place, but it took us some time to realize that we would benefit
from an absolute address type for module calls themselves as opposed to
the instances they imply once expanded, and so AbsModuleCall didn't
exist at the time we originally wrote ModuleInstance.Call.
Perhaps one day we'll update all existing callers of ModuleInstance.Call
to use ModuleInstance.AbsCall instead, but for now we'll be pragmatic and
keep both to avoid causing unnecessary churn.
This new method calculates the static Module address corresponding to the
receiver, effectively discarding any instance keys present in the
containing module instance path.
Currently we have a slightly different treatment for each of the different
kinds of named values, which makes it hard to generalize the
implementations of their very similar behaviors.
This package should over time take ownership of the problem of tracking
all three kinds of named value during a graph walk, with result data
structures that use this information (such as state and plan objects)
copying the relevant values out of here only once the graph walk is
complete.
Nothing is using this yet, though. Some retrofitting of this into
Terraform Core will follow in subsequent commits.
This logic was previously incorrect for any case where the number of
expanded steps was zero, causing the string representation to begin with
a dot when it ought not to.
* terraform: remove redundant code
NodeDestroyResourceInstance is never instantiated with a DeposedKey of anything other than states.NotDeposed, so the deleted code is never run. Deposed objects get a NodeDestroyDeposedResourceInstanceObject instead.
* tfdiags: add helper func
* configs: introduce removed block type
* terraform: add forget action
* renderer: render forget actions
* terraform: deposed objects can be forgotten
Deposed objects encountered during planning spawn
NodePlanDeposedResourceInstanceObject, which previously generated a
destroy change. Now it will generate a forget change if the deposed
object is a forget target, and a destroy change otherwise.
The apply graph gains a new node type,
NodeForgetDeposedResourceInstanceObject, whose execution simply removes
the object from the state.
* configs: add RemoveTarget address type
* terraform: modules can be forgotten
* terraform: error if removed obj still in config
* tests: better error on restore state fail
* Update CHANGELOG.md
This is another contribution to our slowly-growing library of data
structures of address types that implement UniqueKeyer.
This is currently just a wrapper around *dag.AcyclicGraph which avoids the
need for the caller to type-assert the results and which has hopefully
less confusing method names for analyzing the edges. However, that's just
an implementation detail and we should not expose that in the public
API of this type.
These new methods both take into account the possibility of there being
unknown keys, which will be useful for the expression evaluator to decide
whether it can return a specific type or not.
In preparation for making it not an error to have unknown values in count
or for_each arguments, we will need a way to talk about the
as-yet-undetermined set of module or resource instance addresses that
will result once we _do_ learn the instance keys in a later step.
Unlike many of our address types these have unexported internals so that
we can do some semi-uncool things with our address types that external
callers are not normally supposed to do. This means they therefore need
a bunch more methods than our address types typically need so that it's
possible to access the relevant parts of the internal representation.