Commit graph

87 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
Liam Cervante
ffdf9f2a86
actions: preserve unknown metadata in the json plan (#37611)
* actions: preserve unknown metadata in the json plan

* copywrite headers
2025-09-15 14:21:14 +02: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
b2c4766d5e implement review feedback 2025-09-02 13:04:48 +02:00
Daniel Schmidt
dffeeec81e partially expand triggers as well 2025-09-02 13:04:48 +02: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
47994b5542 don't omit action lifecycle indexes 2025-08-25 15:01:31 +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
0313b1471d jsonplan: move action invocation marshalling to separate function 2025-08-25 14:02:30 +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
ccd89c58b2 fail on marked values in action config
this will be supported, but we skip this right now to keep the PR size more manageable
2025-07-31 16:07:38 +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
5e288f56e2 add new planfile fields to terraform show -json 2025-07-31 16:07:38 +02:00
Daniel Schmidt
c2b35e7ee7 remove duplicate place to store action invocations from plan 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 Banck
0aa4ce972d
Add resource identities to plan file and JSON output (#36903) 2025-04-30 14:43:23 +02:00
Daniel Schmidt
fec6e4b552 send resource identities to provider calls 2025-03-12 09:18:55 +01:00
Daniel Banck
b2b42c0fb4
Store resource identities in state (TF-23255) (#36464)
* Persist resource identity in Terraform state

* make syncdeps

* Move identity schema merging closer to the protocol

* mock GetResourceIdentitySchemas

* Fix identity refresh tests

* Add more tests

* Change grcpwrap upgrade identity

* Review feedback

* Remove unnecessary version conversion

* Check if GetResourceIdentitySchemas RPC call is implemented

* Update function signature docs

* Adapt protocol changes

* Check unimplemented error for identities in GetSchema
2025-03-11 20:58:44 +01:00
Daniel Banck
10c9b64007
Rename schema.Block to Body (#36629) 2025-03-04 16:33:43 +01:00
Liam Cervante
f1bd8df9b0
jsonplan: sort the relevant attributes in the correct plan (#36093) 2024-11-25 16:49:18 +01:00
Liam Cervante
36d7e8706f
jsonplan: deterministic relevant attribute order (#36076)
* jsonplan: deterministic relevant attribute order

* simplify sort function
2024-11-25 14:26:34 +01:00
James Bardin
16231373a4 update changes in command pkgs 2024-08-22 09:39:37 -04:00
James Bardin
bc750192e4 POC for always using decoded changes in core
We should not need to encode and decode change values within core, since
the encoded version is only technically needed for serialization. This
pattern stems from the conversion to current changes system, but back
then we did not have easy access to the correct schemas at the time to
encode and decode the entire set of changes.

Moving the core handling of changes to only use the decoded values will
drastically improve evaluation efficiency, removing a round trip
through encoded values for every resource reference.
2024-08-22 09:39:37 -04:00
Daniel Schmidt
4afb3b2b48
jsonformat: render deferred actions 2024-08-09 15:54:44 +02:00
Liam Cervante
471bddf3ba
json plan: update resource index and import ids to support unknown values (#35518) 2024-08-07 08:28:03 +02:00
Liam Cervante
b718c55b13
deferred actions: include deferred resources within JSON plan output (#35065)
* deferred actions: include deferred resources within JSON plan output

* address comments
2024-04-24 14:52:31 +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
thirdkeyword
8284cde302 remove repetitive words
Signed-off-by: thirdkeyword <fliterdashen@gmail.com>
2024-03-06 21:48:30 +08:00
Martin Atkins
884e1fb2a4 terraform: Plans can be "complete" and "applyable"
These ideas are both already implied by some logic elsewhere in the system,
but until now we didn't have the decision logic centralized in a single
place that could therefore evolve over time without necessarily always
updating every caller together.

We'll now have the modules runtime produce its own boolean ruling about
each characteristic, which callers can rely on for the mechanical
decision-making of whether to offer the user an "approve" prompt, and
whether to remind the user after apply that it was an incomplete plan
that will probably therefore need at least one more plan/apply round to
converge.

The "Applyable" flag directly replaces the previous method Plan.CanApply,
with equivalent logic. Making this a field instead of a method means that
we can freeze it as part of a saved plan, rather than recalculating it
when we reload the plan, and we can export the field value in our export
formats like JSON while ensuring it'll always be consistent with what
Terraform is using internally.

Callers can (and should) still use other context in the plan to return
more tailored messages for specific situations they already know about
that might be useful to users, but with these flags as a baseline callers
can now just fall back to a generic presentation when encountering a
situation they don't yet understand, rather than making the wrong decision
and causing something strange to happen. That is: a lack of awareness of
a new rule will now cause just a generic message in the UI, rather than
incorrect behavior.

This commit mostly just deals with populating the flags, and then all of
the direct consequences of that on our various tests. Further changes to
actually make use of these flags elsewhere in the system will follow in
later commits, both in this repository and in other repositories.
2024-02-09 09:24:27 -08:00
kmoe
8f3aa0e099
jsonformat: render forget-only attr changes as no-op (#34403)
* jsonplan: document forget actions

* jsonformat: format forget changes as no-op

Previous to this commit, forget-only actions (i.e. "forget", not "create then forget") would be rendered using the forget action symbol for the top-level resource, and the delete action symbol for each resource attribute, with a new value of "null". This attribute rendering is identical to that for resource deletion, which might suggest to some users that Terraform plans to delete the resource, not just remove it from state.
This commit tweaks the renderer so forget-only changes render as no-ops but with the forget action symbol and resource change comment.
2023-12-12 20:02:38 +00: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
Liam Cervante
2ea141b3f4
Embed the schemas directly in the testing framework JSON verbose outputs (#33755) 2023-08-28 10:25:29 +02:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
Liam Cervante
6882dd9530
testing framework: introduce test command optional flags (#33504)
* testing framework: introduce test command optional flags

* address consistency checks
2023-07-19 10:07:46 +02:00
James Bardin
cf5ebaf685 s/Schemas/ProviderSchema/ 2023-07-06 10:37:35 -04:00
James Bardin
36d34135ad replace remaining types in tests 2023-07-06 10:37:35 -04:00
Andrew Hickman
49f99db1c2
terraform show -json: Add Errored field to output for plan (#33372)
* Add Errored field to JSON output

* Fix test error message
2023-06-19 11:16:41 +01:00
Liam Cervante
4d837df546
Plannable import: Add generated config to JSON and human-readable plan output (#33154)
* 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

* Plannable import: Add generated config to json and human-readable plan output

---------

Co-authored-by: Katy Moe <katy@katy.moe>
2023-05-11 08:50:03 +02:00
Liam Cervante
54c1c1162f
[Plannable Import] Implement human-readable plan rendering (#33113)
* [plannable import] embed the resource id within the changes

* add the plannable imports to the json and human plans

* latest importing struct
2023-05-03 18:50:04 +02:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
Liam Cervante
aae6990d38
Add native plantimestamp function to Terraform (#32980)
* add plantimestamp function

* documentation

* add missing links

* fix typo
2023-04-21 09:47:28 +02:00
Liam Cervante
978263efe9
Checks: Introduce check blocks into the terraform node and transform graph (#32735)
* Add support for scoped resources

* refactor existing checks addrs and add check block addr

* Add configuration for check blocks

* introduce check blocks into the terraform node and transform  graph

* address comments

* address comments

* don't execute checks during destroy operations

* don't even include check nodes for destroy operations
2023-03-23 16:07:31 +01:00
Liam Cervante
d212a72d1d
structured run output: impose canonical ordering on jsonstate and jsonplan packages (#32649) 2023-02-13 15:40:17 +01:00
Liam Cervante
d818d7850d
Structured Renderer: use the new renderer when rendering the state in addition to the plan (#32629)
* Use the new renderer when rendering the state

* remove confusing and unneeded comment
2023-02-07 09:14:14 +01:00
Liam Cervante
6dc49150b7
Structured Plan Renderer: Read the data source schemas from the right place (#32532)
* read the data source schemas from the right place

* address comments and add test
2023-01-19 15:37:02 +01:00
Liam Cervante
8d61c5bfc4
Use the new structured renderer in place of the old diffs package (#32520)
* Use the new structured renderer in place of the old diffs package

* remove old plan tests

* refresh only plans should show moved resources in the refresh section
2023-01-18 10:14:54 +01:00
Liam Cervante
e015b15f12
Structured Plan Renderer: Remove attributes that do not match the relevant attributes filter (#32509)
* remove attributes that do not match the relevant attributes filter

* fix formatting

* fix renderer function, don't drop irrelevant attributes just mark them as no-ops

* fix imports
2023-01-16 15:18:38 +01:00