Commit Graph

276 Commits

Author SHA1 Message Date
Elbaz
2cdedaf734 added combined tests 2023-08-27 15:32:14 +03:00
RLRabinowitz
cf1640bc10 Change terraform doc website links to be a placeholder for now 2023-08-27 15:11:45 +03:00
Elbaz
092d34b055 sort imports 2023-08-27 14:49:32 +03:00
Elbaz
23d5d4daff move import 2023-08-27 14:45:49 +03:00
Elbaz
9cb0e43e9d fix references 2023-08-27 14:07:37 +03:00
Elbaz
6bca34e28d rollback 2023-08-27 13:55:39 +03:00
Elbaz
7723d93946 export more commons 2023-08-27 13:55:04 +03:00
Elbaz
7078034160 update backend to use common user agent 2023-08-27 13:48:30 +03:00
Elbaz
6c86f6ba51 update 2023-08-27 13:46:13 +03:00
Elbaz
57b05912e1 test 2023-08-27 13:43:29 +03:00
Elbaz
7563a92e1e remove deprecated function 2023-08-27 12:21:47 +03:00
Elbaz
77c668de0c export to useragent 2023-08-27 12:17:01 +03:00
Elbaz
32156899de rollback some chagnes 2023-08-27 12:03:53 +03:00
Elbaz
116af60275 rename user agent 2023-08-27 11:58:02 +03:00
Marcin Wyszynski
68e0b50085
Remove user-facing mentions of Hashi TFE/TFC (#154) 2023-08-23 18:04:21 +02:00
Elbaz
6e17054f15 enterprise 🌈 2023-08-22 14:48:33 +03:00
Elbaz
b3080211d0 rollback protocol namings 2023-08-22 14:20:40 +03:00
Elbaz
ecea3e2591 missed that 2023-08-22 14:15:25 +03:00
Elbaz
080385c86a tf cloud comment 2023-08-22 14:15:14 +03:00
Elbaz
d80141255c last fixes 2023-08-22 12:49:16 +03:00
Elbaz
2bae75c3f9 rollback 2023-08-22 11:15:00 +03:00
Elbaz
841025ba26 renames 2023-08-22 11:12:20 +03:00
Elbaz
141e72246d fix tests + english 2023-08-21 19:33:20 +03:00
Elbaz
c10a300b58 s3 2023-08-21 18:24:40 +03:00
Elbaz
15ae0bc167 oss 2023-08-21 18:23:08 +03:00
Elbaz
e6d0a90db5 k8s 2023-08-21 18:22:37 +03:00
Elbaz
44da5b5e3a more 2023-08-21 18:21:16 +03:00
Elbaz
a8d998fd9e remote folder 2023-08-21 18:19:35 +03:00
Elbaz
da73538433 local folder 2023-08-21 16:32:46 +03:00
Elbaz
a017e8f57d init folder 2023-08-21 16:21:27 +03:00
Elbaz
5626ac6926 backend folder 2023-08-21 16:19:40 +03:00
Kuba Martin
ebcf7455eb
Rename root module name. (#4)
* Rename module name from "github.com/hashicorp/terraform" to "github.com/placeholderplaceholderplaceholder/opentf".

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Gofmt.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Regenerate protobuf.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comments.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo issue and pull request link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo comment changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix comment.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Undo some link changes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* make generate && make protobuf

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
2023-08-17 14:45:11 +02:00
Graham Davison
84edaaed57
Merge pull request #33571 from hashicorp/s3/add-legacy-acceptance-tests
S3 Backend: Add legacy authentication flow tests
2023-07-31 13:27:02 -07:00
Sebastian Rivera
dceb8453af
Merge pull request #33492 from hashicorp/cli-team/saved-cloud-plans
Implement saved cloud plans
2023-07-25 10:29:19 -04:00
Sebastian Rivera
08e58fd484 Fix saved plan test regressions, fixtures 2023-07-25 10:22:46 -04:00
Graham Davison
5588603822
Merge pull request #33534 from hashicorp/s3/update-configschema
S3 Backend: Converts from `legacy/helper/schema` to `configschema`
2023-07-24 17:46:09 -07:00
Graham Davison
8564a5bf0e Fixes type of parameter skip_credentials_validation 2023-07-24 17:36:51 -07:00
Graham Davison
47fc769da9 Adds tests for region 2023-07-24 17:20:16 -07:00
Graham Davison
f3ce646756 Adds authentication tests 2023-07-24 16:23:52 -07:00
Sebastian Rivera
31cf55fe12 Reword error message when using local exec 2023-07-24 14:12:44 -04:00
Nick Fagerlund
f9d937a4dd Apply a confirmable run when given a saved cloud plan (#33270)
It displays a run header with link to web UI, like starting a new plan does, then confirms the run
and streams the apply logs. If you can't apply the run (it's from a different workspace, is in an
unconfirmable state, etc. etc.), it displays an error instead.

Notable points along the way:

* Implement `WrappedPlanFile` sum type, and update planfile consumers to use it instead of a plain `planfile.Reader`.

* Enable applying a saved cloud plan

* Update TFC mocks — add org name to workspace, and minimal support for includes on MockRuns.ReadWithOptions.
2023-07-24 14:12:40 -04:00
Brandon Croft
c1a730314d
Relocate localterraform.com aliasing to backend configurators
Previously, remote and cloud backends would automatically alias localterraform.com as the configured hostname during configuration. This turned out to be an issue with how backends could potentially be used within the builtin terraform_remote_state data source. Those data sources each configure the same service discovery with different targets for localterraform.com, and do so simultaneously, creating an occasional concurrent map read & write panic when multiple data sources are defined.

localterraform.com is obviously not useful for every backend configuration. Therefore, I relocated the alias configuration to the callers, so they may specify when to use it. The modified design adds a new method to backend.Enhanced to allow configurators to ask which aliases should be defined.
2023-07-21 09:55:41 -06: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
Graham Davison
344e9de6b9 Linting fixes 2023-07-17 11:34:33 -07:00
Liam Cervante
f74a8d16cf
[testing framework] implement expect_failures functionality (#33443) 2023-07-10 11:30:44 +01:00
Graham Davison
d179b686d9 Consolidates endpoint tests 2023-07-06 16:05:52 -07:00
Graham Davison
2f00c86255 Adds endpoint tests when configured in configuration 2023-07-06 16:05:52 -07:00
Graham Davison
90c10ebbe9 Removes redundant ARN parsing 2023-07-06 16:05:52 -07:00
Graham Davison
29e14d148b Reorders skip_... parameters 2023-07-06 16:05:52 -07:00
Graham Davison
c3f4f9cedd Fixes region validation 2023-07-06 16:05:52 -07:00
Graham Davison
454eed63e7 Adds KMS Key validation 2023-07-06 16:05:52 -07:00
Graham Davison
2fda09aab2 Updates attribute validation messages 2023-07-06 16:05:52 -07:00
Graham Davison
e8c7722d3e Restores conflict between kms_key_id and envvar AWS_SSE_CUSTOMER_KEY 2023-07-06 16:05:52 -07:00
Graham Davison
827d7bd384 Combines sse_customer_key and AWS_SSE_CUSTOMER_KEY validation 2023-07-06 16:05:52 -07:00
Graham Davison
4eaa44c5a5 Adds functions for clearing all envvars 2023-07-06 16:05:52 -07:00
Graham Davison
2d12f242c7 Adds checks for not getting validation errors when they are expected 2023-07-06 16:05:52 -07:00
Graham Davison
95eb523c02 Sets service endpoints from envvar and adds tests 2023-07-06 16:05:52 -07:00
Graham Davison
8d018cfef3 Adds test for setting region from envvars 2023-07-06 16:05:52 -07:00
Graham Davison
9bea21e8b2 Moves schema to ConfigSchema and removes references to legacy schema 2023-07-06 16:05:52 -07:00
Graham Davison
467e6256da Moves configuration to Configure 2023-07-06 16:05:52 -07:00
Graham Davison
381006742b Moves validation to PrepareConfig 2023-07-06 16:05:52 -07:00
Graham Davison
b5de540643 Fully populates schema values 2023-07-06 16:05:52 -07:00
Graham Davison
9257dfa8a7 S3 backend: Adds tests for defaults and validation 2023-07-06 16:05:52 -07: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
James Bardin
4e8dd5866c update schemas type 2023-07-06 10:37:35 -04:00
James Bardin
53901a7e62 Add basic global schema cache
Add a single global schema cache for providers. This allows multiple
provider instances to share a single copy of the schema, and prevents
loading the schema multiple times for a given provider type during a
single command.

This does not currently work with some provider releases, which are
using GetProviderSchema to trigger certain initializations. A new server
capability will be introduced to trigger reloading their schemas, but
not store duplicate results.
2023-07-06 10:37:35 -04:00
Alisdair McDiarmid
ad2298b114
Merge pull request #33108 from unRob/patch-1
Return debuggable CAS errors on consul state put
2023-06-30 09:50:11 -04:00
Roberto Hidalgo
8e5a66b2f5
use multierror.Append instead of append
Co-authored-by: Chris Thain <32781396+cthain@users.noreply.github.com>
2023-06-26 13:02:58 -04:00
Roberto Hidalgo
787cc693cd
use go-multierror instead of manually joining error reasons
Co-authored-by: Chris Thain <32781396+cthain@users.noreply.github.com>
2023-06-24 11:04:55 -06:00
Brandon Croft
19b17ad0a2
remote: when saving state, create a pending state version then upload 2023-06-21 12:30:33 -06:00
guimin.hgm
ce8790c939 backend/oss: Removes the deprecated warning for configuraion variable assume_role 2023-06-12 12:34:47 -07:00
CJ Horton
8a3f4e903b generating configuration is not allowed with the remote backend 2023-05-31 11:51:39 -07:00
CJ Horton
cdce4c4a6d write generated config when using the cloud integration 2023-05-30 00:17:02 -07:00
Liam Cervante
07aa7ee1d5
Propagate generated config filename into the Terraform graph (#33255) 2023-05-24 13:58:26 +02:00
Martin Atkins
efdc6e52bc cloud: Skip intermediate state snapshots in Terraform Cloud/Enterprise
We've seen some concern about the additional storage usage implied by
creating intermediate state snapshots for particularly long apply phases
that can arise when managing a large number of resource instances together
in a single workspace.

This is an initial coarse approach to solving that concern, just restoring
the original behavior when running inside Terraform Cloud or Enterprise
for now and not creating snapshots at all.

This is here as a solution of last resort in case we cannot find a better
compromise before the v1.5.0 final release. Hopefully a future commit
will implement a more subtle take on this which still gets some of the
benefits when running in a Terraform Enterprise environment but in a way
that will hopefully be less concerning for Terraform Enterprise
administrators.

This does not affect any other state storage implementation except the
Terraform Cloud integration and the "remote" backend's state storage when
running inside a TFC/TFE-driven remote execution environment.
2023-05-23 15:25:48 -07:00
Martin Atkins
8884bef59d backend/local: Allow storage impls to customize intermediate persistence
Previously we just always used the same intermediate state persistence
behavior for all state storages. However, some storages might have access
to additional information that allows them to tailor when they persist,
such as reacting to API rate limit status headers in responses, or just
knowing that a particular storage isn't suited to intermediate snapshots
at all for some reason.

This commit doesn't actually change any observable behavior yet, but it
introduces an optional means for a state storage to customize the behavior
which we may make use of in certain storage implementations in future
commits.
2023-05-23 15:25:48 -07:00
kmoe
b4d1146f58
plannable import: improve gen config human plan output (#33194)
* renderer: remove hard-coded config gen path

* mention config gen file in plan next steps
2023-05-15 15:21:41 +01:00
Liam Cervante
d5fed58fc5
plannable import: write generated config to out flag (#33186)
* plannable import: write generated config to out flag

* Add example command to diagnostic
2023-05-12 23:05:00 +01:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
Roberto Hidalgo
1b7f772f8b
fix breaking code
this is what i get for submitting PRs late at night
2023-04-27 10:13:38 -06:00
Roberto Hidalgo
0dda1d5c61
Return debuggeble CAS errors on consul state put
ran into this error while running terraform on a container and saving state to Consul. I suspect my policy needs tweaking but it's impossible to tell with an error like this:

```
╷
│ Error: Failed to save state
│ 
│ Error saving state: consul CAS failed with transaction errors:
│ [0xc0006e93c8]
╵
```

This PR makes the will include the error messaage in the details so I can continue debugging
2023-04-26 23:44:39 -06:00
Alisdair McDiarmid
0ffdd07980 Fix goimports discrepancies 2023-04-26 14:33:13 -04:00
Rémi Lapeyre
af571b2642
Improve environment variable support for the pg backend (#33045)
* Improve environment variable support for the pg backend

This patch does two things:
  - it adds environment variable support to the parameters that did
    not have it (and uses `PG_CONN_STR` instead of `PGDATABASE` which is
    actually more appropriate to match the behavior of other PostgreSQL
    utilities)
  - better documents how to give the connection parameters as environment
    variables for the ones that were already supported based on the
	recommendation of @bsouth00

I will prepare a backport of the documentation part of this once it is
merged.

Closes https://github.com/hashicorp/terraform/issues/33024

* Remove global variable in test of the PG backend
2023-04-21 08:39:19 +02:00
Glenn Sarti
7e2e834aff
Emit warnings for certain run events in cloud backend (#33020)
The cloud backend, which communicates with TFC like APIs, can create
runs which may have one more configuration parameters altered. These
alterations are emitted as run-events on the run so that API clients
can consume and display them to users. This commit adds a step in
plan operation to query the run-events once a run is created and then
emit specific run-event descriptions to the console as warnings for
the user.
2023-04-17 08:53:47 -07:00
Liam Cervante
9c87006c34
checks: hide check diagnostics during plans that will not wait for approval (#32938)
* checks: filter out check diagnostics during certain plans

* wrap diagnostics produced by check blocks in a dedicated check block diagnostic

* address comments
2023-04-11 10:54:30 +02:00
janaurka
1f603b1a7f
backend/pg: Accept connection string in PGDATABASE environment variable 2023-04-05 15:42:44 -07:00
James Bardin
c02e7e8754 return early from opPlan when the plan is nil
While the returned plan is checked for nil in most cases, there was
a single point where the plan was dereferenced which could panic. Rather
than always guarding the dereferences, return early when the plan is
nil.
2023-03-10 09:34:47 -05:00
Martin Atkins
f0de9b60c1 backend/local: Periodically persist intermediate state snapshots
Terraform Core emits a hook event every time it writes a change into the
in-memory state. Previously the local backend would just copy that into
the transient storage of the state manager, but for most state storage
implementations that doesn't really do anything useful because it just
makes another copy of the state in memory.

We originally added this hook mechanism with the intent of making
Terraform _persist_ the state each time, but we backed that out after
finding that it was a bit too aggressive and was making the state snapshot
history much harder to use in storage systems that can preserve historical
snapshots.

However, sometimes Terraform gets killed mid-apply for whatever reason and
in our previous implementation that meant always losing that transient
state, forcing the user to edit the state manually (or use "import") to
recover a useful state.

In an attempt at finding a sweet spot between these extremes, here we
change the rule so that if an apply runs for longer than 20 seconds then
we'll try to persist the state to the backend in an update that arrives
at least 20 seconds after the first update, and then again for each
additional 20 second period as long as Terraform keeps announcing new
state snapshots.

This also introduces a special interruption mode where if the apply phase
gets interrupted by SIGINT (or equivalent) then the local backend will
try to persist the state immediately in anticipation of a
possibly-imminent SIGKILL, and will then immediately persist any
subsequent state update that arrives until the apply phase is complete.
After interruption Terraform will not start any new operations and will
instead just let any already-running operations run to completion, and so
this will persist the state once per resource instance that is able to
complete before being killed.

This does mean that now long-running applies will generate intermediate
state snapshots where they wouldn't before, but there should still be
considerably fewer snapshots than were created when we were persisting
for each individual state change. We can adjust the 20 second interval
in future commits if we find that this spot isn't as sweet as first
assumed.
2023-02-14 15:17:56 -08:00
Yin Luo
e9b066f514
Support assume role for cos backend (#32631)
* go get github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sts/v20180813@v1.0.588

* feat:support assume_role for COS backend

* update go.mod and go.sum

* change secret_id and secret_key from required to optional

* update cos doc

* update logic by comments

* rm sensitive info in log
2023-02-13 10:25:58 +01:00
megan07
d7d8a2262c
Merge pull request #32557 from bharathkkb/gcs-backend-impersonate-envvar
Add a GCS backend specific env var for impersonation
2023-02-09 09:28:26 -06:00
James Bardin
1307317457
Merge pull request #32614 from yardbirdsax/fix/30670
make remote state initial behavior the same as local state
2023-02-07 17:43:28 -05:00
Joshua Feierman
d45ebfbdef chore: clean-up tests & logging 2023-02-01 13:54:59 -05:00
Joshua Feierman
2576544db8 fix: remote state behavior
This makes the behavior of remote state consistent with local state in regards to the initial serial number of the generated / pushed state. Previously remote state's initial push would have a serial number of 0, whereas local state had a serial of > 0. This causes issues with the logic around, for example, ensuring that a plan file cannot be applied if state is stale (see https://github.com/hashicorp/terraform/issues/30670 for example).
2023-02-01 13:54:40 -05:00
Brandon Croft
81a4e5ae44
Backport support for generic hostname to backend/remote 2023-01-31 15:10:53 -07:00
Sheridan C Rawlins
75e5ae27a2
[fixes 31700] Add mTLS support for http backend by way of client cert & key, as well as enterprise cacert. (#31699)
* Add mTLS support for http backend by way of client cert & key, as well as enterprise cacert.

* Fix style.

* Skip cert validation to be sure error is related to missing client cert; not untrusted server cert.

* Remove misplaced err check.

* Fix the size of test using http backend.

* Just for correctness, include all certs in the pem encoded cert - sometimes certs come with a chain of their signers.

* Adjusted names as recommended in PR comments.

* Adjusted names to be full-length and more descriptive.

* Added full-fledged testing with mTLS http server

* Fix goimports.

* Fix the names of the backend config.

* Exclusive lock for write and delete.

* Revert "Fix goimports."

This reverts commit 7d40f6099fbbb675fb2e25e35ee40aeafe3d0a22.

* goimports just for server test.

* Added the go:generation for the mock.

* Move the TLS configuration out to make it more readable - don't replace the HTTPClient as the retryablehttp already creates one - just configure its TLS.

* Just switch the client/data params - felt more natural this way.

* Update internal/backend/remote-state/http/backend.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* Update internal/backend/remote-state/http/testdata/gencerts.sh

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* Update internal/backend/remote-state/http/backend.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* Update internal/backend/remote-state/http/backend.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* Update internal/backend/remote-state/http/backend.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* Update internal/backend/remote-state/http/backend.go

Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>

* the location of the file name is not sensitive.

* Added error if only one of client_certificate_pem and client_private_key_pem are set.

* Remove testify from test cases; use t.Error* for assert and t.Fatal* for require.

* Fixed import consistency

* Just use default openssl.

* Since file(...) is so trivial to use, changed the client cert, key, and ca cert to be the data.

See also https://github.com/hashicorp/terraform-provider-http/pull/211

Co-authored-by: Sheridan C Rawlins <scr@ouryahoo.com>
Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>
2023-01-26 14:08:07 +00:00
bharathkkb
05ff3c3278 Add a GCS backend specific env var for impersonation 2023-01-21 05:20:31 +00:00
James Bardin
721df0e68d
Merge pull request #32395 from hashicorp/jbardin/plan-output-on-error
Always show and store planned actions and checks even when planning fails
2023-01-04 12:44:52 -05:00
James Bardin
3cda7a0269
Merge pull request #29520 from ComBin/main
Don't show symbols while input if variable marked as sensitive
2022-12-16 13:13:33 -05:00
James Bardin
5aa088e385 remove -always-out
Make writing a plan file the default. We already create plans which have
no changes so the plan result would need to be checked in automation, so
having plans with errors should not pose a problem.

If we find workflows which cannot handle a plan that can't be applied,
we can reevaluate the need for a specialized flag. In the meantime, it
feels more logical that the plan output would always describe the result
of the plan, even if that included errors.
2022-12-14 11:09:34 -05:00