Commit graph

32419 commits

Author SHA1 Message Date
Alisdair McDiarmid
f3ec86b17b stackruntime: Treat unset and null equally
When handling root input variable values, we now consider unset and null
values to be equivalent to each other. This is consistent with how we
handle variables in embedded stacks, and very similar to how we handle
variable in the modules runtime with `nullable = false`.

One difference from the modules runtime case is that we do not prevent
a null default value for stack variables.
2024-03-07 15:49:39 -05:00
Alisdair McDiarmid
0fe26468cd stackruntime: Apply defaults to root variables
When evaluating a stack's root input variables, supplied by the caller,
we must apply any default values specified in the variable
configuration for variables with no specified value. This commit adds
this default fallback case, using NilVal as a marker indicating the lack
of a specified value.

If no default value exists for a variable, it is therefore required to
be supplied by the caller. This commit also reports a diagnostic error
in this case.
2024-03-04 16:20:17 -05:00
James Bardin
33bf5203b8 update CHANGELOG.md 2024-03-01 11:06:06 -05:00
James Bardin
41e5745c39
Merge pull request #34756 from hashicorp/jbardin/update-cty
update go-cty
2024-03-01 11:02:39 -05:00
Martin Atkins
071b6de78a configs: Don't treat module_variable_optional_attrs as special
Due to some specific circumstances around how this experiment reached
stabilization we made a planned-temporary exception to make it valid to
specify even in non-alpha builds of Terraform, just to be able to return
a more precise error message.

The comment added at the time suggested that we remove this "a release or
two after v1.3", and v1.8 is the actively-developed release at the time
I'm writing this so we've kept this around far longer than we originally
felt we needed to. It's time for it to go.

This particular experiment will now get the same treatment as all others
when used in a non-alpha release: Terraform will return the general error
about experiments only being available in alpha releases.
2024-03-01 07:20:00 -08:00
James Bardin
8ff17813b7 update go-cty 2024-03-01 10:05:07 -05:00
James Bardin
c4db017658 update CHANGELOG.md 2024-02-29 16:43:36 -05:00
James Bardin
78d89718d5 fix CHANGELOG.md links 2024-02-29 16:35:26 -05:00
James Bardin
15f1d8c445
Merge pull request #34751 from hashicorp/jbardin/update-hcl
update hcl v2.20.0
2024-02-29 15:23:23 -05:00
James Bardin
a639adc27b update hcl 2024-02-29 14:29:57 -05:00
Jared Baker
04fc8c7e18
Merge pull request #34723 from hashicorp/s3/use_legacy_workflow-removal
backend/s3: remove use_legacy_workflow argument
2024-02-29 09:20:56 -05:00
Daniel Schmidt
49ad27f1c9
Merge pull request #34737 from hashicorp/stacks-for-each
stacks: make component for_each more robust
2024-02-29 10:58:54 +01:00
Jared Baker
b700911cda
Merge branch 'main' into s3/use_legacy_workflow-removal 2024-02-28 16:41:05 -05:00
Martin Atkins
9b57a43bde website: First draft of Terraform v1.8 upgrade guide
We may revise this further during the Terraform v1.8 prerelease period, if
feedback suggests that more information is needed or that this information
is not clear enough. The main goal here is just to get out of the confusing
situation where the v1.8 branch contains a v1.7 upgrade guide, so that
we can link to the upgrade guide from the changelog.

The full upgrade guide page gives us room for more details, allowing the
changelog to serve just as a concise list of changes.
2024-02-28 11:24:32 -08:00
Nick Fagerlund
c9c24706aa
Merge pull request #34741 from hashicorp/nf/feb24-provider-addrs-in-statuses
Stacks, Hooks: Include full provider addresses
2024-02-28 11:11:33 -08:00
James Bardin
dada9d683e
Merge pull request #34740 from hashicorp/jbardin/render-string-null-changes
try to render some changes between `""` and `null`
2024-02-28 13:31:05 -05:00
Nick Fagerlund
67b0de9d43 Use blank string as the zero provider fallback (instead of implied provider) 2024-02-28 10:24:05 -08:00
James Bardin
90b89c5931
Merge pull request #34744 from hashicorp/jbardin/go1.22
upgrade to go1.22
2024-02-28 13:20:25 -05:00
Daniel Schmidt
2a0962328d
stacks: make error message more precise 2024-02-28 15:41:00 +01:00
James Bardin
89b3e8a3e3 upgrade to go1.22 2024-02-28 09:01:01 -05:00
Liam Cervante
dde743c436 cleanup after 1.8.0-alpha20240228 release 2024-02-28 14:52:34 +01:00
Liam Cervante
26dc2e0e88 Update GH issue links in changelog for release 2024-02-28 14:15:56 +01:00
Liam Cervante
0c1f7b3900 prepare for 1.8.0-alpha20240228 release 2024-02-28 14:06:54 +01:00
Daniel Schmidt
8da61e2d20
stacks: reword for_each error message 2024-02-28 13:12:50 +01:00
Daniel Schmidt
217879e510
stacks: make component for_each more robust 2024-02-28 12:23:17 +01:00
Radek Simko
fcfbfb3eff
website: ensure for_each examples take maps (#34675) 2024-02-28 08:58:17 +00:00
Liam Cervante
cec4b7b74c
stacks: validate providers based on types instead of local names (#34735)
* stacks: validate providers based on types instead of local names

* fix tests
2024-02-28 08:24:53 +01:00
Nick Fagerlund
f58c71e77c Stacks: Update expectations in TestTerraformHook 2024-02-27 19:28:20 -08:00
Nick Fagerlund
ccab5f1e55 Rename some UiHook tests for easier ad-hoc runs 2024-02-27 19:28:20 -08:00
Nick Fagerlund
09f8ed1fd3 Stacks: Update stack change hooks to send provider address in RPC messages
This updates the `ReportResourceInstanceStatus` and
`ReportResourceInstancePlanned` callbacks to extract the provider address they
received in their arguments and include it in the RPC messages they emit.

The corresponding RPC message formats were recently updated to include a field
for provider address.

The planned callback already could have accessed the provider address prior to
this PR, but the status callback needed the recent refactor of the
`terraform.Hook` API.
2024-02-27 19:28:20 -08:00
Nick Fagerlund
7703a5aead Stacks: Add ProviderAddr field to ResourceInstanceStatusHookData
This updates the stackruntime `hooks.ResourceInstanceStatusHookData` struct to
include the provider address, and updates everything that instantiates that
struct to pass along the valid provider address it received from its own caller.

In other words, this commit is a bridge between the terraform.Hook interface
methods (which already have access to the provider address) and the stacks hook
callbacks that result in RPC messages being sent to the agent.
2024-02-27 19:28:20 -08:00
Nick Fagerlund
2e228ff619 RPC protobufs: Add provider_addr to resource status and planned change messages
Notably, this doesn't add it to the provisioner event messages... but the stacks
runtime doesn't seem to stream those over the RPC API yet anyway.
2024-02-27 19:28:20 -08:00
Nick Fagerlund
94ea534e40 Refactor terraform.Hook to use a resource-identifying wrapper struct
The terraform.Hook interface lets other areas of code perform streaming
reactions to various events, generally in the service of some UI somewhere.
Nearly all of the methods on this interface take an `addrs.AbsResourceInstance`
as their first argument, to identify the resource that's being operated on.

However, that addrs struct doesn't necessarily contain everything you might want
in order to uniquely and usefully identify a resource. It has the module
instance and resource instance addresses, but it lacks the provider source
address, which can affect how the consuming UI should display the resource's
events. (For example, Terraform Cloud wants reliable info about who maintains a
given provider, what cloud provider it operates on, and where to find its
documentation.)

Instead of polluting `addrs.AbsResourceInstance` with extra information that
isn't relevant to other call sites, let's change the first argument of each Hook
method to be a wrapper struct defined in the package that owns the Hook
interface, and add the provider address to that wrapper as a sibling of the
resource address. This causes a big noisy commit today, but should streamline
future updates to the UI-facing "identity" of a resource; existing callers can
ignore any new fields they're uninterested in, or exploit new info as needed.

Other than making new information available for future edits to Hook
implementing types, this commit should have no effect on existing behavior.
2024-02-27 19:28:20 -08:00
Nick Fagerlund
d81a546e55 Lints: hook_count_test, "redundant type from slice composite literal"
I was in the file for other reasons, and wanted to reduce noise in my editor.
2024-02-27 19:28:20 -08:00
Nick Fagerlund
402f9816f4 Dead code removal: ProvisionerUIOutput
Nothing ever uses this struct.
2024-02-27 19:28:20 -08:00
Martin Atkins
1ef7844e34
Update CHANGELOG.md 2024-02-27 16:18:04 -08:00
Martin Atkins
94ba52fc9e
Update CHANGELOG.md 2024-02-27 16:16:40 -08:00
Martin Atkins
573c2db658 provider/terraform: Terraform-specific encoding functions
Using the new possibility of provider-contributed functions, this
introduces three new functions which live in the
terraform.io/builtin/terraform provider, rather than being language
builtins, due to their Terraform-domain-specific nature.

The three new functions are:
 - tfvarsencode: takes a mapping value and tries to transform it into
   Terraform CLI's "tfvars" syntax, which is a small subset of HCL that
   only supports key/value pairs with constant values.
 - tfvarsdecode: takes a string containing content that could potentially
   appear in a "tfvars" file and returns an object representing the
   raw variable values defined inside.
 - exprencode: takes an arbitrary Terraform value and produces a string
   that would yield a similar value if parsed as a Terraform expression.

All three of these are very specialized, of use only in unusual situations
where someone is "gluing together" different Terraform configurations etc
when the usual strategies such as data sources are not suitable. There's
more information on the motivations for (and limitations of) each function
in the included documentation.
2024-02-27 16:13:48 -08:00
James Bardin
bdd5a2cd33 try to render some empty string -> null changes
Changes between empty strings and `null` were hidden in the CLI output,
because the SDK could not reliably detect the difference and may return
either value depending on the situation.

This legacy behavior can be confusing for authors of new provider which
can correctly handle `null`, and it would be preferable to be able to
render those changes in the CLI.

While we don't have enough information to detect when the legacy
behavior is required, we can detect a number of cases where it's
certain that we are not dealing with a legacy schema and should output
the full diff.
2024-02-27 16:59:06 -05:00
Craig Wright
42aa821194
Merge pull request #33969 from sorenisanerd/document-socks5-support
Document support for ssh over SOCKS5
2024-02-27 10:59:05 -08:00
Martin Atkins
9c66eb6e10
Update CHANGELOG.md 2024-02-27 09:07:51 -08:00
Martin Atkins
2714e5c91b
Update CHANGELOG.md 2024-02-27 09:00:20 -08:00
James Bardin
300f66b71d
Merge pull request #34603 from hashicorp/jbardin/remove-provider-funtion-warnings
provider functions can only return an error
2024-02-27 09:53:48 -05:00
Soren L. Hansen
80f748f6f6
Apply suggestions from code review
Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2024-02-27 12:56:25 +01:00
Liam Cervante
31a7fa88d5
stacks: validate provider configurations during static analysis (#34730) 2024-02-27 08:43:58 +01:00
Alisdair McDiarmid
1459825e53
Merge pull request #34725 from hashicorp/alisdair/configs-sourcebundle-parser
Add and use a source bundle aware configuration parser for stacks
2024-02-26 16:39:33 -05:00
Alisdair McDiarmid
2c22c213e9 stackeval: More robust absolute source addrs
Instead of relying on the module call's source being unique, we now use
the entire path as the key for looking up the parent's absolute source
address.
2024-02-26 14:48:29 -05:00
Alisdair McDiarmid
7a043fe54a stackeval: Another module source test case
If multiple submodules of a given component share the same relative
source, they should result in distint source addresses in the
diagnostics. This commit introduces an example with the following
structure:

- component.remote_invalid_grandchildren
  - module.first_child
    - module.child (source = "./child")
  - module.second_child
    - module.child (source = "./child")

Both of these use the same invalid module as the rest of the examples in
this test, so we should (and do) see equivalent diagnostics differing
only in filename.
2024-02-26 14:16:03 -05:00
Alisdair McDiarmid
7d956bbc11 stackeval: Fix module loader source addr building
The source bundle aware module loader requires "absolute" source
addresses, which are fully qualified rather than relative. We generate
these during the module loading process.

The previous implementation assumed that any local module source address
should be parented by the root module source, but this is incorrect when
a descendant module targets a remote or registry source. This commit
addresses this by tracking each module request's generated absolute
source address, and using it as the base for any descendant local module
requests.
2024-02-26 13:29:15 -05:00
Martin Atkins
a45d4467f1 stackeval: Don't fail when data resource is removed
Due to an oversight in our handling of resource instance objects that are
neither in configuration nor plan -- which is true for data resources that
have since been removed from the configuration -- we were generating plan
change objects that were lacking a provider configuration address, which
made them syntactically invalid and thus not reloadable using the
raw plan parser.

This is a bit of a strange situation since we don't technically _need_ a
provider configuration address for these; all we're going to do is just
unceremoniously delete them from the state during apply anyway. However,
we always have the provider configuration address available anyway, so
adding this in here is overall simpler than changing the parser, the
models it populates, and all of the downstream users of those models to
treat this field as optional.

This commit is more test case than it is fix, since the fix was relatively
straightforward once I had a test case to reproduce the problem it's
fixing.
2024-02-26 08:14:16 -08:00