Commit graph

41 commits

Author SHA1 Message Date
Kristin Laemmert
70e074b8aa chore (actions): rename LifecycleActionTrigger -> ResourceActionTrigger in plan and proto
We'd previously removed all other references to "lifecycle" actions, which made this reference stand out. ResourceLifecycleActionTrigger is probably the most accurate name, but as this type just needs to be differentiated from InvokeActionTrigger I thought "resource" was enough (and I specifically wanted= to avoid lifecycle at all). I'm not super attached to the name, but I did think it would be clearer if we avoided Lifecycle as much as possible, since that's got some overlap with action subtypes.

In this instance, we call it a LifecycleActionTrigger because it's come from the resource's `lifecycle` block. This doesn't directly relate to the concept of LifecycleActions - even if we expand the design to have multiple action types (for example generic and lifecycle actions), both those actions types would use this same Trigger struct.
2026-02-23 15:17:45 -05:00
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Daniel Schmidt
e0748b30c4 add interface checks 2025-10-08 13:18:13 +02:00
Daniel Schmidt
7721cd5c50 refactor: make action diff transformer only responsible for attaching action invocations 2025-10-08 13:18:13 +02:00
Kristin Laemmert
df113486a1
actions: remove references to action types, linked resources (#37616)
* action renaming
* actions: remove references to action types
* actions: remove references to linked_resources or action types from the plan proto
2025-09-16 08:46:22 -04:00
Liam Cervante
49cc60531d
actions: fix cycle when multiple actions are triggered across multiple events (#37591) 2025-09-11 10:20:33 +02:00
James Bardin
4c610ac5e6 use the new genconfig types throughout 2025-08-29 15:11:56 -04:00
James Bardin
ddc47f15e7 remove the recursive genconfig resource struct
The Resource struct didn't really match the data structure. Refactor
this to make it easier to break up the config generation calls so we can
pass in final config from the provider.
2025-08-29 15:11:56 -04:00
Liam Cervante
866363ffff
actions: add invoke nodes to the graph (#37521)
* actions: add invoke graph nodes

* fix small bugs

* add additional tests

* remove whitespace

* fix copyright headers

* go generate

* address comments
2025-08-29 14:43:09 +02:00
Daniel Schmidt
871d3ce64f support sensitive values in action configuration 2025-08-25 15:00:34 +02:00
Daniel Schmidt
14c83aa7ee allow reporting action invocations as deferred 2025-08-25 14:02:30 +02:00
Daniel Schmidt
5187efdd1d refactor: move method into changes_src 2025-08-18 13:53:09 +02:00
Daniel Schmidt
219c31f4eb action: move action trigger into nested struct
this prepares the work on CLI / flag-driven invocations
2025-08-18 13:53:09 +02:00
Daniel Schmidt
4fb4c3f056 render action config values 2025-07-31 16:07:38 +02:00
Daniel Schmidt
eb26b72d55 display lifecycle triggered actions aside their triggering resources 2025-07-31 16:07:38 +02:00
Daniel Schmidt
2654e4d7cd add information for graph building into plan action invocations 2025-07-24 11:28:29 +02:00
Daniel Schmidt
e0ab23a040 ensure we encode action invocations from change to changesrc 2025-07-18 14:20:17 +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
Samsondeen
8d8b2bb694
Generate config for list results (#37173) 2025-07-04 11:35:39 +02:00
Daniel Banck
2b9d25c7fd
Add terraform query subcommand (TF-25494) (#37174)
* WIP

* Reuse plan command for query CLI

* Basic CLI output

* Only fail a list request on error

* poc: store query results in separate field

* WIP: odd mixture between JSONs

* Fix list references

* Separate JSON rendering

The structured JSON now only logs a status on which list query is
currently running. The new jsonlist package can marshal the query fields
of a plan.

* Remove matcher

* Store results in an extra struct

* Structured list result logging

* Move list result output into hooks

* Add help text and additional flag

* Disable query runs with the cloud backend for now

* Review feedback
2025-07-02 15:06:25 +02:00
Samsondeen
685ff9f192
Schema representation of list block config and results (#37209) 2025-06-10 20:08:54 +02:00
Daniel Banck
0aa4ce972d
Add resource identities to plan file and JSON output (#36903) 2025-04-30 14:43:23 +02:00
Daniel Banck
6917e69d12
Config-driven importing through identity (TF-23179) (#36703)
* configschema: Add identity attribute to import block

* Mark import target ID as legacy

* Add test with import identity

* Use ID or identity when importing via configuration

* Add plan import tests

* Review Feedback

* Make sure to copy identity for ResourceInstanceObjects

* Add helper for converting cty.Objects to string

* Replace getProvider calls

* Improve unknown object check
2025-04-02 13:39:16 +02:00
Daniel Schmidt
fec6e4b552 send resource identities to provider calls 2025-03-12 09:18:55 +01:00
Daniel Banck
10c9b64007
Rename schema.Block to Body (#36629) 2025-03-04 16:33:43 +01:00
James Bardin
16231373a4 update changes in command pkgs 2024-08-22 09:39:37 -04:00
James Bardin
4eca878acc have change sets manage encoding and decoding
Add Changes.Encode and ChangesSrc.Decode to put all encoding and
decoding in a single place.
2024-08-22 09:39:37 -04:00
James Bardin
696fc7378d Update tests to match new changes types
Changes now stores Changes rather than ChangeSrcs, and ChangeSrcs are
stored in ChangesSrc
2024-08-22 09:39:37 -04:00
Liam Cervante
96da5e9f46
deferred actinos: add support for unknown ids in import blocks (#35300) 2024-06-12 12:59:28 +02:00
Martin Atkins
30e2fd6525 Handle marks a little more consistently
In the very first implementation of "sensitive values" we were
unfortunately not disciplined about separating the idea of "marked value"
from the idea of "sensitive value" (where the latter is a subset of the
former). The first implementation just assumed that any marking whatsoever
meant "sensitive".

We later improved that by adding the marks package and the marks.Sensitive
value to standardize on the representation of "sensitive value" as being
a value marked with _that specific mark_.

However, we did not perform a thorough review of all of the mark-handling
codepaths to make sure they all agreed on that definition. In particular,
the state and plan models were both designed as if they supported arbitrary
marks but then in practice marks other than marks.Sensitive would be
handled in various inconsistent ways: dropped entirely, or interpreted as
if marks.Sensitive, and possibly do so inconsistently when a value is
used only in memory vs. round-tripped through a wire/file format.

The goal of this commit is to resolve those oddities so that there are now
two possible situations:
 - General mark handling: some codepaths genuinely handle marks
   generically, by transporting them from input value to output value in
   a way consistent with how cty itself deals with marks. This is the
   ideal case because it means we can add new marks in future and assume
   these codepaths will handle them correctly without any further
   modifications.
 - Sensitive-only mark preservation: the codepaths that interact with our
   wire protocols and file formats typically have only specialized support
   for sensitive values in particular, and lack support for any other
   marks. Those codepaths are now subject to a new rule where they must
   return an error if asked to deal with any other mark, so that if we
   introduce new marks in future we'll be forced either to define how we'll
   avoid those markings reaching the file/wire formats or extend the
   file/wire formats to support the new marks.

Some new helper functions in package marks are intended to standardize how
we deal with the "sensitive values only" situations, in the hope that
this will make it easier to keep things consistent as the codebase evolves
in future.

In practice the modules runtime only ever uses marks.Sensitive as a mark
today, so all of these checks are effectively covering "should never
happen" cases. The only other mark Terraform uses is an implementation
detail of "terraform console" and does not interact with any of the
codepaths that only support sensitive values in particular.
2024-04-18 07:32:52 -07:00
Martin Atkins
1f7dbaf3a8 plans: ResourceInstanceChange.ObjectAddr
We've now many times made the mistake of thinking that the resource
instance address is a suitable unique identifier for a resource instance
change in a plan -- the name certainly seems to suggest it -- but really
these represent changes to resource instance _objects_ and so it's
important to also include the DeposedKey field as part of the unique
identifier for a change.

Now we'll expose ObjectAddr as a new method that returns the two together
for convenient use as a single address value, along with adding some
commentary to the fields to make it clearer that Addr is not sufficient.
Ideally we'd rename Addr to make it less of an attractive nuisance, but
that was too invasive a change for today so will need to wait for another
time.
2023-11-15 12:38:56 -08:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
Liam Cervante
79f7f59155
Plannable import: Generate config for imported resources during the plan. (#33153)
* command: keep our promises

* remove some nil config checks

Remove some of the safety checks that ensure plan nodes have config attached at the appropriate time.

* add GeneratedConfig to plan changes objects

Add a new GeneratedConfig field alongside Importing in plan changes.

* add config generation package

The genconfig package implements HCL config generation from provider state values.

Thanks to @mildwonkey whose implementation of terraform add is the basis for this package.

* generate config during plan

If a resource is being imported and does not already have config, attempt to generate that config during planning. The config is generated from the state as an HCL string, and then parsed back into an hcl.Body to attach to the plan graph node.

The generated config string is attached to the change emitted by the plan.

* complete config generation prototype, and add tests

---------

Co-authored-by: Katy Moe <katy@katy.moe>
2023-05-11 08:38:37 +02:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
Liam Cervante
4210d905c0
[plannable import] embed the resource id within the changes (#33134)
* [plannable import] embed the resource id within the changes

* make pointers and update docs
2023-05-02 16:04:51 +02:00
kmoe
28643516b2
Plannable import 3: Make import plannable (#33085)
During a plan, Terraform now checks for the presence of import blocks.

For each resource in config, if an import block is present with a matching address, planning that node will now trigger an ImportResourceState and ReadResource. The resulting state is treated as the node's "refresh state", and planning proceeds as normal from there.

The walkImport operation is now only used for the legacy "terraform import" CLI command. This is the only case under which the plan should produce graphNodeImportStates.
2023-04-28 23:45:43 +01:00
kmoe
531efd303b
add types for plannable import (#33080) 2023-04-25 15:19:48 +01:00
Alisdair McDiarmid
29999c1d6f command: Render "moved" annotations in plan UI
For resources which are planned to move, render the previous run address
as additional information in the plan UI. For the case of a move-only
resource (which otherwise is unchanged), we also render that as a
planned change, but without any corresponding action symbol.

If all changes in the plan are moves without changes, the plan is no
longer considered "empty". In this case, we skip rendering the action
symbols in the UI.
2021-09-03 17:44:07 -04:00
Martin Atkins
22b36d1f4c Field for the previous address of each resource instance in the plan
In order to expose the effect of any relevant "moved" statements we dealt
with prior to creating the plan, we'll record with each
ResourceInstanceChange both is current address and the address it was
tracked at for the previous run.

To save consumers of these objects from having to special-case the
situation where there _was_ no previous run (e.g. because this is a Create
change), we'll just pretend the previous run address was the same as the
current address in that case, the same as for an update without any
renaming in effect.

This includes a breaking change to the plan file format, but one that
doesn't require a version number increment because there is no ambiguity
between the two formats and so mismatched parsers will already fail with
an error message.

As of this commit we've just added the new field but not yet populated it
with any useful information: it always just matches Addr. A future commit
will wire this up to the result of applying the moves so that we can
populate it correctly. We also don't yet expose this new information
anywhere in the UI layer.
2021-08-30 13:59:14 -07:00
Martin Atkins
f40800b3a4 Move states/ to internal/states/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00
Martin Atkins
034e944070 Move plans/ to internal/plans/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00
Renamed from plans/changes_src.go (Browse further)