Commit graph

125 commits

Author SHA1 Message Date
James Bardin
7960f60d21
Merge pull request #38160 from hashicorp/jbardin/inline-type-conversion
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
inline type conversions
2026-02-27 11:11:09 -04:00
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Daniel Schmidt
a3dc571150 fix deprecation origin handling
Some checks are pending
build / Build for windows_amd64 (push) Blocked by required conditions
build / Build for freebsd_arm (push) Blocked by required conditions
build / Build for linux_arm (push) Blocked by required conditions
build / Build for darwin_arm64 (push) Blocked by required conditions
build / Build for linux_arm64 (push) Blocked by required conditions
build / Build for windows_arm64 (push) Blocked by required conditions
build / Build Docker image for linux_386 (push) Blocked by required conditions
build / Build Docker image for linux_amd64 (push) Blocked by required conditions
build / Build Docker image for linux_arm (push) Blocked by required conditions
build / Build Docker image for linux_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_386 (push) Blocked by required conditions
build / Build e2etest for windows_386 (push) Blocked by required conditions
build / Build e2etest for darwin_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_amd64 (push) Blocked by required conditions
build / Build e2etest for windows_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_arm (push) Blocked by required conditions
build / Build e2etest for darwin_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_arm64 (push) Blocked by required conditions
build / Run e2e test for linux_386 (push) Blocked by required conditions
build / Run e2e test for windows_386 (push) Blocked by required conditions
build / Run e2e test for darwin_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_amd64 (push) Blocked by required conditions
build / Run e2e test for windows_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_arm (push) Blocked by required conditions
build / Run e2e test for linux_arm64 (push) Blocked by required conditions
build / Run terraform-exec test for linux amd64 (push) Blocked by required conditions
Quick Checks / Unit Tests (push) Waiting to run
Quick Checks / Race Tests (push) Waiting to run
Quick Checks / End-to-end Tests (push) Waiting to run
Quick Checks / Code Consistency Checks (push) Waiting to run
2026-02-16 13:52:52 +01:00
James Bardin
31237fe968 allow the use of primitive names in HCL
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.
2026-02-13 11:23:05 -05:00
Daniel Schmidt
958a1ae1e7 variable and output deprecation
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.
2026-02-03 15:57:28 +01:00
Kristin Laemmert
7e37e518c4 actions test refactor 2026-02-03 08:22:19 -05:00
Sarah French
1dd8e60f15
chore: Bump golang.org/x/crypto dependency, ignore SA4003 linting errors globally (#37901)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* 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.
2025-11-17 15:01:28 +00:00
Daniel Schmidt
ad4371342f track partial expanded action invocations through deferred action invocation
like we do it for resources just simpler because we don't have layered addrs maps
2025-09-02 13:04:48 +02:00
Daniel Schmidt
dffeeec81e partially expand triggers as well 2025-09-02 13:04:48 +02:00
Daniel Schmidt
29b2ab15e2 support partial expansion in actions 2025-09-02 13:04:48 +02:00
Liam Cervante
4ed8668a8f
actions: make action address targetable (#37499)
* actions: make action address targetable

* add missing functions

* copyright headers
2025-08-28 14:05:05 +02:00
Daniel Schmidt
be810aa80e make AbsActionInstance not referencable 2025-07-24 11:28:29 +02:00
Daniel Schmidt
11f00e584b fix action addrs test 2025-07-24 11:28:29 +02:00
Daniel Schmidt
834665e332 use better hook identity 2025-07-24 11:28:29 +02:00
Daniel Schmidt
812e5a9749 add helper to iterate over elements of an addrs map 2025-07-24 11:28:29 +02:00
Daniel Schmidt
114ce5a0e2 make abs action instances referencable 2025-07-24 11:28:29 +02:00
Kristin Laemmert
9256074c43
Actions in plan/changes (#37320)
* 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
2025-07-17 08:19:57 -04:00
Daniel Schmidt
8649eae35d rename ActionInvocation for clarity 2025-07-08 16:24:38 +02:00
Daniel Schmidt
016daf647e add addrs for action invocation 2025-07-08 16:24:38 +02:00
Samsondeen
685ff9f192
Schema representation of list block config and results (#37209) 2025-06-10 20:08:54 +02:00
Samsondeen
a5434b421f
Build and Validate list resource nodes (#37011) 2025-05-20 19:45:38 +02:00
Samsondeen
44eb0c69ef
Recognize tf query files (#36929) 2025-05-15 07:14:32 +02:00
Kristin Laemmert
90357bccba
initial actions addrs (#37003)
* initial actions addrs

This adds the basic Action-related addresses and parsing Actions as references.
2025-05-09 09:03:10 -04:00
James Bardin
3b3e4bf003 update the rest of the go:generate calls 2025-02-12 12:25:58 -05:00
Daniel Schmidt
34bedeab0f
addrs: AbsModuleCallOutput to ConfigOutputValue translation
The end-goal is to retrieve ConfigOutputValues from References.
This ties in with the work on deprecated outputs.
2024-12-09 16:21:35 +01:00
Liam Cervante
eeacced8f0
Add go vet as a check to the Github commit actions (#31461)
* Add go vet as a check to the Github commit actions

* deliberately break to test

* fix after successful test

* Use  directly

* fix more errors
2024-11-07 17:29:58 +01:00
Liam Cervante
9be46420ce
moved: error if not targeting a resource address (#35850)
* moved: error if not targeting a resource address

* address comments
2024-10-18 10:46:16 +02:00
James Bardin
a5a8f4b16a Ancestors cannot return an error
Just like Descendants, Ancestors doesn't need to return an error.
2024-10-14 09:45:49 -04:00
James Bardin
38804946e7 Descendants should not return an error 2024-10-09 14:37:45 -04:00
James Bardin
3a1a9408d9 fix Descendants spelling
this has proliferated everywhere
2024-10-09 11:09:02 -04:00
James Bardin
6e5ba099cb generate stringer code 2024-09-13 08:55:48 -04:00
James Bardin
9c06a7e8d8 ephemeral resource mode
Make addrs aware of ephemeral resource types
2024-09-13 08:55:48 -04:00
James Bardin
2cbb6bf92f udpate code which was failing staticckeck
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.
2024-09-11 14:09:12 -04:00
Liam Cervante
0f0414d484
Fix partial address representation in plan for deferred actions (#34966)
* Fix partial address representation in plan

* reflect new type in stacks
2024-06-20 10:41:23 +02:00
Liam Cervante
55600d815e
Add support for partial addresses and targets that start with 'resource.' (#35333)
* Add support for partial addresses and targets that start with 'resource.'

* fix broken tests
2024-06-14 09:58:53 +02:00
Liam Cervante
5172cb5e27
deferred actions: allow unknown foreach attributes within import blocks (#35311)
* deferred actions: allow unknown foreach attributes within import blocks

* remember to fail tests when diags returned
2024-06-12 13:14:40 +02:00
Liam Cervante
765ec6e923
Complete implementation of targeting with deferred resources (#34971) 2024-04-11 08:45:03 +02:00
Liam Cervante
28797e7938
Add the deferred changes into the plan (#34946)
* Add the deferred changes into the plan

* add copywrite headers
2024-04-05 10:34:10 +02:00
Martin Atkins
5d87e32eb9 moduleaddrs: Split module source address parsing from package addrs
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.
2024-03-14 09:58:30 -07:00
Martin Atkins
8e02f5dd21 addrs: PartialExpandedResource module address accessors
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.
2024-02-12 12:13:08 -08:00
Martin Atkins
d37436a39a addrs: ModuleInstance.AbsCall
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.
2024-01-19 13:51:57 -08:00
Martin Atkins
f3c48314ab addrs: AbsModuleCall.StaticModule
This new method calculates the static Module address corresponding to the
receiver, effectively discarding any instance keys present in the
containing module instance path.
2024-01-19 13:51:57 -08:00
Martin Atkins
869750da61 namedvals: A new package to encapsulate the tracking of named values
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.
2023-11-29 08:41:40 -08:00
Martin Atkins
908c5fa44f addrs: PartialExpandedModule.String correct for entirely-unexpanded
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.
2023-11-29 08:41:40 -08:00
kmoe
a718f70f85
Add removed block (#34251)
* 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
2023-11-29 11:58:28 +00:00
Martin Atkins
ce267925e6 addrs: Graph of addresses
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.
2023-11-28 13:48:48 -08:00
Martin Atkins
d9a4f9a06b instances: Methods for retrieving the instance keys of modules/resources
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.
2023-11-28 10:11:54 -08:00
Martin Atkins
4d0087e3ef addrs: PartialExpandedModule and PartialExpandedResource
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.
2023-11-28 10:11:54 -08:00
Martin Atkins
f1d68e89c0 addrs: AbsLocalValue is a UniqueKeyer 2023-11-27 11:46:39 -08:00
Martin Atkins
1c734048af addrs: Add a missing copyright comment 2023-11-15 12:38:57 -08:00