Commit Graph

29377 Commits

Author SHA1 Message Date
James Bardin 9b62dd6901
Merge pull request #29648 from hashicorp/jbardin/tfproto6.1
tfproto version 6.1
2021-10-28 16:00:02 -04:00
James Bardin 583e3a5f0b use 11 for the panic exit code 2021-10-28 15:34:02 -04:00
James Bardin bd37f43daa add note about calling PanicHandler first 2021-10-28 13:56:18 -04:00
James Bardin d2d2508f5c write provider panics to error
We no longer have to hide these from panicwrap
2021-10-28 11:51:39 -04:00
James Bardin f031fcaa97 no need for TF_FORK=0 2021-10-28 11:51:39 -04:00
James Bardin d03a037567 insert panic handlers 2021-10-28 11:51:39 -04:00
James Bardin 3f31533f86 logging.PanicHandler can now be for internal use
Repurpose logging.PanicHandler to recover internal panics and print a
message to users similar to panicwrap.
2021-10-28 11:51:39 -04:00
James Bardin 42742c173d remove wrapped streams and readline 2021-10-28 11:51:39 -04:00
James Bardin 622c4df14c remove the use of panicwrap
Stop using panicwrap, and execute terraform in the main process.
2021-10-28 11:51:39 -04:00
Alisdair McDiarmid ded4f1a0fd
Merge pull request #29805 from hashicorp/alisdair/fix-init-workspace-select-input-false
command/init: Fail if -input=false but required
2021-10-26 11:37:22 -04:00
Laura Pacilio 0ef4fe0aab
Merge pull request #29691 from ramj9/patch-1
replace an with a
2021-10-26 09:49:46 -04:00
Krista LaFentres (she/her) 9bb5a58e3c
Merge pull request #29798 from hashicorp/lafentres/clarify-trim-docs
Clarify the way the trim() function works
2021-10-25 15:09:58 -05:00
Krista LaFentres 1f08f7dba8 Clarify the way the trim() function works and add some more examples 2021-10-25 14:13:15 -05:00
Alisdair McDiarmid ecb98e1c43 command/init: Fail if -input=false but required
When running `terraform init` against a backend with multiple
workspaces, none of which are the currently indicated local workspace,
Terraform prompts the user to choose a workspace from the list. In
automation, using the `-input=false` argument should disable asking for
input, but previously would hang instead.
2021-10-25 15:08:10 -04:00
Alisdair McDiarmid 6d0521e6be
Merge pull request #29803 from hashicorp/alisdair/init-backend-provider-errors
cli: Fix backend init failure with deleted cache
2021-10-25 13:57:45 -04:00
Alisdair McDiarmid 22923f9873
Merge pull request #29793 from hashicorp/alisdair/fix-remote-backend-migrate-version-check
backend/remote: Fix version check when migrating
2021-10-25 12:50:27 -04:00
Alisdair McDiarmid d42d83572b cli: Fix backend init failure with deleted cache
When an explicit backend is configured with a configuration which has
not yet been initialized, running `terraform init` performs a state
migration to fetch the remotely stored state in order to operate on it.
Like the previous bug introduced by the recent provider diagnostics
change, this code path was not correctly configured to enable init mode
for the backend, which resulted in a fatal error during init when the
cache dir is deleted.

Setting the `Init` backend option allows this code path to continue
without error when first initializing the backend for state migration.
The new e2e test fails without this change.
2021-10-25 12:45:35 -04:00
Martin Atkins 5ca21afa75
Update CHANGELOG.md 2021-10-23 07:28:42 -07:00
Alisdair McDiarmid 92a9aa9b39
Merge pull request #29792 from hashicorp/alisdair/init-missing-cache
cli: Fix init failure with deleted cache
2021-10-22 09:23:19 -04:00
Alisdair McDiarmid 1729431520 backend/remote: Fix version check when migrating
When migrating state to an existing Terraform Cloud workspace using the
remote backend, we check the remote version is compatible with the local
one by default.

This commit fixes two bugs in this code:

- If using the "name" strategy for the remote backend, the list of
  destination workspaces is empty. This resulted in no version checking
  of the remote workspace, and we fell back to the string equality
  check.
- The user-specified CLI flag `-ignore-remote-version` was not being
  applied for the state migration version checking.
2021-10-21 14:10:25 -04:00
Alex Khaerov 6f1eceb0e2
Revert autoupdate 2021-10-21 21:42:13 +08:00
Alisdair McDiarmid 39de3ebec7 cli: Fix init failure with deleted cache
The init command needs to initialize a backend, in order to access
state, in turn to derive provider requirements from state. The backend
initialization step requires building provider factories, which
previously would fail if a lockfile was present without a corresponding
local provider cache.

This commit ensures that in this situation only, errors with the
provider factories are temporarily ignored. This allows us to continue
to initialize the backend, fetch providers, and then report any errors
as necessary.
2021-10-21 08:44:26 -04:00
Alisdair McDiarmid 1190b95fe2 command/e2etest: Ensure init fixes missing cache
We test that a deleted provider cache results in an error when running
terraform plan, but previously did not test that running init (as
instructed) would resolve the issue. This (failing) e2e test adds that
step.
2021-10-21 08:41:01 -04:00
James Bardin 0fcb75020f
Merge pull request #29784 from xiaozhu36/xiaozhu
backend/oss: Fixes the nil pointer panic error when missing access key or secret key
2021-10-20 16:32:13 -04:00
hc-github-team-tf-core 00a1b7ffb9 Cleanup after v1.1.0-alpha20211020 release 2021-10-20 17:42:49 +00:00
hc-github-team-tf-core 4bb675059d
Release v1.1.0-alpha20211020 2021-10-20 17:27:51 +00:00
Martin Atkins a1092ecd19
Update CHANGELOG.md 2021-10-20 06:44:03 -07:00
Martin Atkins 5b266dd5ca command: Remove the experimental "terraform add" command
We introduced this experiment to gather feedback, and the feedback we saw
led to us deciding to do another round of design work before we move
forward with something to meet this use-case.

In addition to being experimental, this has only been included in alpha
releases so far, and so on both counts it is not protected by the
Terraform v1.0 Compatibility Promises.
2021-10-20 06:42:47 -07:00
xiaozhu36 7afaea4cf2 backend/oss: Fixes the nil pointer panic error when missing access key or secret key 2021-10-20 16:05:00 +08:00
Alisdair McDiarmid cdd5ee6fb3
Merge pull request #29773 from hashicorp/alisdair/init-lock-flags
cli: Restore -lock and -lock-timeout init flags
2021-10-19 09:45:15 -04:00
Alisdair McDiarmid 1bc3e593f5
Merge pull request #29776 from hashicorp/alisdair/fix-flaky-init-cancel-test
cli: Fix flaky init cancel test
2021-10-19 09:34:00 -04:00
Alisdair McDiarmid c587384dff cli: Restore -lock and -lock-timeout init flags
The -lock and -lock-timeout flags were removed prior to the release of
1.0 as they were thought to have no effect. This is not true in the case
of state migrations when changing backends. This commit restores these
flags, and adds test coverage for locking during backend state
migration.

Also update the help output describing other boolean flags, showing the
argument as the user would type it rather than the default behavior.
2021-10-19 09:32:30 -04:00
Alisdair McDiarmid fb58f9e6d2 cli: Fix flaky init cancel test
There is a race between the MockSource and ShutdownCh which sometimes
causes this test to fail. Add a HangingSource implementation of Source
which hangs until the context is cancelled, so that there is always time
for a user-initiated shutdown to trigger the cancellation code path
under test.
2021-10-19 09:10:49 -04:00
Alex Khaerov 14f366dbf4
Update documentation 2021-10-18 12:54:40 +08:00
Alex Khaerov f32702c5c2
Support deprecated assume_role block 2021-10-18 12:32:57 +08:00
Alex Khaerov de8810cdd9
Merge branch 'hashicorp:main' into main 2021-10-18 11:42:37 +08:00
Martin Atkins 7d3074df46 go.mod: go get github.com/mitchellh/go-wordwrap@v1.0.1 2021-10-15 17:13:03 -07:00
Chris Griggs e111c103b8
[Website]Terraform Integration Program (#29763)
* add new guide doc

* update word doc

* assign imange files

* add fmting changes

* formatting

* some more changes

* Fix Title

* Update website/guides/terraform-integration-program.html.md

We can remove, I was hoping to have "*Currently, pre-apply..." be in Bbold, but it looks like it doesnt render that way. So we can exclude the asterisk

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>

* Fix spacing and remove unused html paragraph

* Update website/guides/terraform-integration-program.html.md

Good changes, thanks for simplifying it.

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Agreed

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Agreed

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Agreed

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>

* Adding suggested changes from PR. 

Removing example sentence. (Internal request)

* Move note section above badge

* Add spacing

* Update website/guides/terraform-integration-program.html.md

Approved

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>

Co-authored-by: Jeff Escalante <jescalan@users.noreply.github.com>
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2021-10-15 10:55:07 -07:00
James Bardin 3c64b9b604 update CHANGELOG.md 2021-10-14 14:43:48 -04:00
Martin Atkins 39779e7021 backend/remote-state/cos: Don't use github.com/likexian/gokit
We don't use this library anywhere else in Terraform, and this backend was
using it only for trivial helpers that are easy to express inline anyway.
The new direct code is also type-checkable, whereas these helper functions
seem to be written using reflection.

This gives us one fewer dependency to worry about and makes the test code
for this backend follow a similar assertions style as the rest of this
codebase.
2021-10-14 10:50:05 -07:00
James Bardin ef3c98466d
Merge pull request #29755 from hashicorp/jbardin/first-plan-lineage
Check for stale plan with no state metadata
2021-10-14 13:31:30 -04:00
dependabot[bot] 8946d7ff20 build(deps): bump github.com/golang/protobuf from 1.5.0 to 1.5.2
Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.5.0 to 1.5.2.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](https://github.com/golang/protobuf/compare/v1.5.0...v1.5.2)

---
updated-dependencies:
- dependency-name: github.com/golang/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-13 18:12:51 -07:00
Martin Atkins 88bddd7143 go.mod: go get go get golang.org/x/tools@v0.1.7
This also transitively upgrades golang.org/x/sys and golang.org/x/net,
but there do not seem to be any significant changes compared to the
commits we were previously using.
2021-10-13 17:37:37 -07:00
James Bardin 9c80574417 test planfile may need to have a specific lineage
In order to test applying a plan from an existing state, we need to be
able to inject the state meta into the planfile.
2021-10-13 17:28:14 -04:00
James Bardin 5ffa0839f9 only check serial when applying the first plan
Ensure that we still check for a stale plan even when it was created
with no previous state.

Create separate errors for incorrect lineage vs incorrect serial.

To prevent confusion when applying a first plan multiple times, only
report it as a stale plan rather than different lineage.
2021-10-13 17:17:51 -04:00
Martin Atkins c76f54781a
Update CHANGELOG.md 2021-10-13 13:56:47 -07:00
Martin Atkins bee7403f3e command/workspace_delete: Allow deleting a workspace with empty husks
Previously we would reject attempts to delete a workspace if its state
contained any resources at all, even if none of the resources had any
resource instance objects associated with it.

Nowadays there isn't any situation where the normal Terraform workflow
will leave behind resource husks, and so this isn't as problematic as it
might've been in the v0.12 era, but nonetheless what we actually care
about for this check is whether there might be any remote objects that
this state is tracking, and for that it's more precise to look for
non-nil resource instance objects, rather than whole resources.

This also includes some adjustments to our error messaging to give more
information about the problem and to use terminology more consistent with
how we currently talk about this situation in our documentation and
elsewhere in the UI.

We were also using the old State.HasResources method as part of some of
our tests. I considered preserving it to avoid changing the behavior of
those tests, but the new check seemed close enough to the intent of those
tests that it wasn't worth maintaining this method that wouldn't be used
in any main code anymore. I've therefore updated those tests to use
the new HasResourceInstanceObjects method instead.
2021-10-13 13:54:11 -07:00
megan07 968f422681
Merge pull request #29753 from hashicorp/megan_update_msg
update error message for invalid json
2021-10-13 14:04:24 -05:00
Megan Bang 9b9b26a3cd update error message for invalid json 2021-10-13 13:51:07 -05:00
Martin Atkins 765bff1dd5
Update CHANGELOG.md 2021-10-13 10:53:27 -07:00