Commit Graph

688 Commits

Author SHA1 Message Date
Mitchell Hashimoto 03493f7d46
command: validate backend config
The validation itself was added a couple weeks ago but I forgot to
actually call it. :sad:
2017-03-02 14:07:49 -08:00
Mitchell Hashimoto d1b930d5b5
command: remove unused test 2017-03-02 11:21:48 -08:00
Mitchell Hashimoto 0224a12a00
command: fix go vet 2017-03-02 11:19:54 -08:00
Mitchell Hashimoto 5086f9f568
command: remove log 2017-03-02 11:15:38 -08:00
Mitchell Hashimoto 866de2776e
command: trigger still applying cancellations from a channel 2017-03-02 11:15:02 -08:00
Radek Simko 17c9a403f2
WIP 2017-03-02 18:43:27 +00:00
Radek Simko 08283f077b
command: Fix crash caused by empty state 2017-03-02 10:58:01 +00:00
Radek Simko 2e2b8686dd command: Display state ID in PreApply+PostApply (#12261) 2017-03-01 22:16:22 +00:00
Mitchell Hashimoto 868230ee60
command/state-push: fix go vet 2017-03-01 13:19:44 -08:00
Mitchell Hashimoto ee985a606c Merge pull request #12350 from hashicorp/b-state-push-stdin
command/state-push: support pushing from stdin
2017-03-01 13:17:44 -08:00
Mitchell Hashimoto f735205677 Merge pull request #12349 from hashicorp/b-ux
command: color changes, trimming newlines
2017-03-01 13:11:00 -08:00
Mitchell Hashimoto a6b2eca613
command/state-push: support pushing from stdin 2017-03-01 13:10:48 -08:00
Mitchell Hashimoto 1f614bd4d6
command: color changes, trimming newlines 2017-03-01 12:59:40 -08:00
Mitchell Hashimoto e1a63e6b7f Merge pull request #12348 from hashicorp/b-state-pull-crash
command: fix crash on state pull with empty state
2017-03-01 12:59:16 -08:00
Mitchell Hashimoto bdde7d845a Merge pull request #12347 from hashicorp/b-env-migrate
command: migrating envs when changing backends
2017-03-01 12:58:40 -08:00
Mitchell Hashimoto 7f6a99404d
command: fix crash on state pull with empty state
When you have no state (no local state or you just switched to a new
env) and run `terraform state pull`, it would crash.
2017-03-01 12:47:36 -08:00
Mitchell Hashimoto 549d525487 Merge pull request #12320 from hashicorp/b-legacy-state
command: fix loading legacy remote state + migration guide
2017-03-01 12:39:17 -08:00
Mitchell Hashimoto 1e3d452613
command: multistate to multistate conversions 2017-03-01 12:35:59 -08:00
Mitchell Hashimoto c82d7dd56c
command: multi-state (non-default env) to single state 2017-03-01 11:40:28 -08:00
Mitchell Hashimoto e75b666591
command: test multi-state to single state 2017-03-01 11:34:45 -08:00
Mitchell Hashimoto 3ef82e6b5f
command: test multi-state with default only to single state 2017-03-01 11:08:39 -08:00
Mitchell Hashimoto 1d8b76c89d
command: initial work on migrating envs, basic cases first 2017-03-01 10:59:17 -08:00
James Bardin 39a5ddd381 Split Meta back out of StateMeta
Removing the call to StateMeta.Env, so that it doesn't need an embedded
Meta field. Embed Meta and StateMeta separately in all State commands.
2017-03-01 10:20:32 -05:00
Mitchell Hashimoto 2c19aa69d9
command: legacy remote state should load from backendinit 2017-02-28 19:29:19 -08:00
James Bardin 4dac986a91 Local.StatePaths doesn't need to reutrn an error
add a test to ensure we have consistent output
2017-02-28 19:18:16 -05:00
James Bardin dc675540de fix rebased tests 2017-02-28 16:35:46 -05:00
James Bardin b53704ed87 Thread the environment through all commands
Add Env and SetEnv methods to command.Meta to retrieve the current
environment name inside any command.

Make sure all calls to Backend.State contain an environment name, and
make the package compile against the update backend package.
2017-02-28 16:35:46 -05:00
James Bardin 2a73331c62 use State.HasResources rather than State.Empty
Destroying a terraform state can't always create an empty state, as
outputs and the root module may remain. Use HasResources to warn about
deleting an environment with resources.
2017-02-28 16:07:07 -05:00
James Bardin 06663991d1 Add config path argument to env commands
In order to operate in parity with other commands, the env command
should take a path argument to locate the configuration.

This however introduces the issue of a possible name conflict between a
path and subcommand, or printing an incorrect current environment for
the bare `env` command. In favor of simplicity this removes the current
env output and only prints usage when no subcommand is provided.
2017-02-28 16:07:06 -05:00
James Bardin c8526484b3 split the env command into subcommands 2017-02-28 16:07:06 -05:00
James Bardin 31f033827f Add basic env commands
Used a single command with flags for now. We may refactor this out to
subcommands.
2017-02-28 16:07:06 -05:00
James Bardin 1ea9413c07 Remove state path handling from commands
The Local backend is now responsible for handling the paths to the local
state files, since they are dependent on the current environment.
2017-02-28 16:06:14 -05:00
Mitchell Hashimoto 3cedfa00f4
command: use backend.CLIIinit
I made this interface way back with the original backend work and I
guess I forgot to hook it up! This is becoming an issue as I'm working
on our 2nd enhanced backend that requires this information and I
realized it was hardcoded before.

This propertly uses the CLIInit interface allowing any backend to gain
access to this data.
2017-02-28 10:58:29 -08:00
James Bardin 80389375b5 Fix the Push test outputs
Change the expected outputs in the Push tests to match the quotes map
keys.
2017-02-24 18:37:06 -05:00
James Bardin 71c541c65c always quote hcl map keys
HCL identifiers may need to be quoted, so always quote them to be safe.
2017-02-24 18:32:59 -05:00
James Bardin d596d6e761 Revert "always quote hcl map keys"
This reverts commit 43f62d2630.
2017-02-24 18:31:48 -05:00
James Bardin 43f62d2630 always quote hcl map keys
HCL identifiers may need to be quoted, so always quote them to be safe.
2017-02-24 18:22:36 -05:00
James Bardin 43c7bd648c fix sorting of module resources during state mv
Module resource were being sorted lexically by name by the state filter.
If there are 10 or more resources, the order won't match the index
order, and resources will have different indexes in their new location.

Sort the FilterResults by index numerically when the names match.

Clean up the module String output for visual inspection by sorting
Resource name parts numerically when they are an integer value.
2017-02-23 18:27:16 -05:00
Mitchell Hashimoto 4c7c46bf40
command: fix test for new Meta type 2017-02-23 10:51:29 -08:00
Mitchell Hashimoto 8f11068ab2 Merge pull request #12173 from hashicorp/b-remote-state-ds
providers/terraform: remote state data source supports backends
2017-02-22 18:43:06 -08:00
Mitchell Hashimoto d2d87bccf0 Merge pull request #12155 from hashicorp/b-state-backend
command: refresh state in old commands for backend
2017-02-22 18:40:55 -08:00
Mitchell Hashimoto ebb22d3ecd
backend/local: don't RefreshState on State API 2017-02-22 13:01:16 -08:00
Liran Polak f37800ae62 New Provider: Spotinst (#5001)
* providers/spotinst: Add support for Spotinst resources

* providers/spotinst: Fix merge conflict - layouts/docs.erb

* docs/providers/spotinst: Fix the resource description field

* providers/spotinst: Fix the acceptance tests

* providers/spotinst: Mark the device_index as a required field

* providers/spotinst: Change the associate_public_ip_address field to TypeBool

* docs/providers/spotinst: Update the description of the adjustment field

* providers/spotinst: Rename IamRole to IamInstanceProfile to make it more compatible with the AWS provider

* docs/providers/spotinst: Rename iam_role to iam_instance_profile

* providers/spotinst: Deprecate the iam_role attribute

* providers/spotinst: Fix a misspelled var (IamRole)

* providers/spotinst: Fix possible null pointer exception related to "iam_instance_profile"

* docs/providers/spotinst: Add "load_balancer_names" missing description

* providers/spotinst: New resource "spotinst_subscription" added

* providers/spotinst: Eliminate a possible null pointer exception in "spotinst_aws_group"

* providers/spotinst: Eliminate a possible null pointer exception in "spotinst_subscription"

* providers/spotinst: Mark spotinst_subscription as deleted in destroy

* providers/spotinst: Add support for custom event format in spotinst_subscription

* providers/spotinst: Disable the destroy step of spotinst_subscription

* providers/spotinst: Add support for update subscriptions

* providers/spotinst: Merge fixed conflict - layouts/docs.erb

* providers/spotinst: Vendor dependencies

* providers/spotinst: Return a detailed error message

* provider/spotinst: Update the plugin list

* providers/spotinst: Vendor dependencies using govendor

* providers/spotinst: New resource "spotinst_healthcheck" added

* providers/spotinst: Update the Spotinst SDK

* providers/spotinst: Comment out unnecessary log.Printf

* providers/spotinst: Fix the acceptance tests

* providers/spotinst: Gofmt fixes

* providers/spotinst: Use multiple functions to expand each block

* providers/spotinst: Allow ondemand_count to be zero

* providers/spotinst: Change security_group_ids from TypeSet to TypeList

* providers/spotinst: Remove unnecessary `ForceNew` fields

* providers/spotinst: Update the Spotinst SDK

* providers/spotinst: Add support for capacity unit

* providers/spotinst: Add support for EBS volume pool

* providers/spotinst: Delete health check

* providers/spotinst: Allow to set multiple availability zones

* providers/spotinst: Gofmt

* providers/spotinst: Omit empty strings from the load_balancer_names field

* providers/spotinst: Update the Spotinst SDK to v1.1.9

* providers/spotinst: Add support for new strategy parameters

* providers/spotinst: Update the Spotinst SDK to v1.2.0

* providers/spotinst: Add support for Kubernetes integration

* providers/spotinst: Fix merge conflict - vendor/vendor.json

* providers/spotinst: Update the Spotinst SDK to v1.2.1

* providers/spotinst: Add support for Application Load Balancers

* providers/spotinst: Do not allow to set ondemand_count to 0

* providers/spotinst: Update the Spotinst SDK to v1.2.2

* providers/spotinst: Add support for scaling policy operators

* providers/spotinst: Add dimensions to spotinst_aws_group tests

* providers/spotinst: Allow both ARN and name for IAM instance profiles

* providers/spotinst: Allow ondemand_count=0

* providers/spotinst: Split out the set funcs into flatten style funcs

* providers/spotinst: Update the Spotinst SDK to v1.2.3

* providers/spotinst: Add support for EBS optimized flag

* providers/spotinst: Update the Spotinst SDK to v2.0.0

* providers/spotinst: Use stringutil.Stringify for debugging

* providers/spotinst: Update the Spotinst SDK to v2.0.1

* providers/spotinst: Key pair is now optional

* providers/spotinst: Make sure we do not nullify signals on strategy update

* providers/spotinst: Hash both Strategy and EBS Block Device

* providers/spotinst: Hash AWS load balancer

* providers/spotinst: Update the Spotinst SDK to v2.0.2

* providers/spotinst: Verify namespace exists before appending policy

* providers/spotinst: Image ID will be in a separate block from now on, so as to allow ignoring changes only on the image ID. This change is backwards compatible.

* providers/spotinst: user data decoded when returned from spotinst api, so that TF compares the two states properly, and does not update without cause.
2017-02-22 22:57:16 +02:00
Mitchell Hashimoto 478a7dbfe7
command: convert to using backend/init 2017-02-22 11:17:27 -08:00
Mitchell Hashimoto e4d2193ed6
command/state: mv and rm -backup works
Fixes #12154

The "-backup" flag before for "state *" CLI had some REALLY bizarre behavior:
it would change the _destination_ state and actually not create any
additional backup at all (the original state was unchanged and the
normal timestamped backup still are written). Really weird.

This PR makes the -backup flag work as you'd expect with one caveat:
we'll _still_ create the timestamped backup file. The timestamped backup
file helps make sure that you always get a backup history when using
these commands. We don't want to make it easy for you to overwrite a
state with the `-backup` flag.
2017-02-21 21:10:03 -08:00
Mitchell Hashimoto 6e1dc9c77d
command: extra RefreshState calls 2017-02-21 20:35:43 -08:00
Mitchell Hashimoto ad1ba7c2b1
command/state list: test against backend 2017-02-21 19:43:05 -08:00
James Bardin c080334c3f Merge pull request #12069 from hashicorp/jbardin/state-locking
Add inmem remote backend
2017-02-21 19:00:21 -05:00
James Bardin d710ecbd4d Fix regression from not having an real unlock test
args were sliced incorrectly.
2017-02-20 14:50:31 -05:00
James Bardin 5095d7c6a7 Add complete unlock test
Test actual unlock failure and success through the the unlock command.
2017-02-20 14:50:31 -05:00
clint shryock be6ae20ac1 Merge branch 'pr-8299'
* pr-8299:
  Patch up website docs
  provider/dns: DNS dynamic updates (RFC 2136)
  vendor: Capture new dependency miekg-dns
2017-02-17 17:02:37 -06:00
Chris Paris 5812bae27f RefreshState in output command 2017-02-16 18:44:43 -08:00
Mitchell Hashimoto 716132431a
command/init: initialize backend even if not set in the config
We need to initialize the backend even if the config has no backend set.
This allows `init` to work when unsetting a previously set backend.
Without this, there was no way to unset a backend.
2017-02-15 15:44:53 -08:00
James Bardin a372e9c54b fix state migration lock info 2017-02-15 17:00:54 -05:00
James Bardin ec00564be6 Clean up LockInfo and LockError and use them
Gove LockInfo a Marshal method for easy serialization, and a String
method for more readable output.

Have the state.Locker implementations use LockError when possible to
return LockInfo and an error.
2017-02-15 14:44:43 -05:00
James Bardin f2e496a14c Have backend operations properly unlock state
Make sure unlock is called with the correct LockID during operations
2017-02-15 14:41:55 -05:00
James Bardin f5ed8cd288 Use NewLockInfo to get a pre-populated value
Using NewLockInfo ensure we start with all required fields filled.
2017-02-15 14:41:55 -05:00
James Bardin 4f0c465187 make command tests pass with new state.Locker 2017-02-15 14:41:55 -05:00
James Bardin 67dc16c9ca Make backend/local test pass 2017-02-15 14:41:55 -05:00
Mitchell Hashimoto b7a143fffb
command/state: improved error message on state lock fail 2017-02-14 11:44:43 -08:00
Mitchell Hashimoto 18bc77c359
command/state: up the threshold for showing lock info 2017-02-14 11:36:21 -08:00
Mitchell Hashimoto 90f3d40c1f
command: use new state lock/unlock helpers for better UX 2017-02-14 11:33:55 -08:00
Mitchell Hashimoto 34f438b635
command/state: helpers for UX with lock/unlock state 2017-02-14 11:17:18 -08:00
Kazumichi Yamamoto cd7f69ab11 New provider arukas (#11171)
* Add a Arukas provider

* Add dependencies for the Arukas provider

* Add documents for the Arukas
2017-02-13 19:11:30 +00:00
George Hartzell e39f4e1993 Typo: determien -> determine (#11888) 2017-02-12 19:46:32 +00:00
Roberto Jung Drebes e3934c23c8 provider/dns: DNS dynamic updates (RFC 2136) 2017-02-10 21:38:26 +01:00
James Bardin 0c1b138719 Add state locking during backend init
During backend initialization, especially during a migration, there is a
chance that an existing state could be overwritten.

Attempt to get a locks when writing the new state. It would be nice to
always have a lock when reading the states, but the recursive structure
of the Meta.Backend config functions makes that quite complex.
2017-02-09 15:47:27 -05:00
James Bardin 5c2e945b3c Fix format string and typos 2017-02-09 10:27:42 -05:00
Mitchell Hashimoto a5ab6e447b command/apply: update help text to be "parallel" instead of concurrent 2017-02-08 11:49:08 -08:00
James Bardin 5ca5a3c78a Merge pull request #11724 from hashicorp/jbardin/state-locking
add force-unlock command
2017-02-08 10:19:15 -05:00
James Bardin 65abe98047 Remove lock command and rename lock/force-unlock
Remove the lock command for now to avoid confusion about the behavior of
locks. Rename lock to force-unlock to make it more aparent what it does.

Add a success message, and chose red because it can be a dangerous
operation.

Add confirmation akin to `destroy`, and a `-force` option for
automation and testing.
2017-02-07 18:28:48 -05:00
Mitchell Hashimoto 0c97c5a3d9
command: tests should move to temporary cwd
This fixes any issues where rogue tfstate files may appear in the cwd
otherwise.
2017-02-07 09:11:48 -08:00
James Bardin 015198ca11 Add lock/unlock commands 2017-02-06 13:50:01 -05:00
James Bardin b80ae5e13e Add source path argument to testLockState
The new test pattern is to chdir into a temp location for the test, but
the prevents us from locating the testdata directory in the source. Add
a source path to testLockState so we can find the statelocker.go source.
2017-02-06 13:50:01 -05:00
James Bardin eb8e5ac739 Change CLI flag to '-lock' 2017-02-06 10:07:32 -05:00
James Bardin 07903189f1 s/Meta.lockState/Meta.stateLock/g 2017-02-06 09:58:04 -05:00
James Bardin cd96bb5aca Add test/untaint tests with locked state
add missing lock-state flag to untaint
2017-02-03 16:13:42 -05:00
James Bardin 82e59cd826 Add test for destroy with locked state 2017-02-03 16:06:01 -05:00
James Bardin 9fa436e0bd Add test for locked state in plan 2017-02-03 16:02:22 -05:00
James Bardin f3e4c05250 build the statelocker binary before running
this way we can signal it directly to amke sure it exits cleanly.
2017-02-03 15:59:24 -05:00
James Bardin bd65ddbcaa Add test for apply/refresh on locked state files
Verify that these operations fail when a state file is locked.
2017-02-03 15:32:40 -05:00
James Bardin fb60b6f6f2 Add separate program for locking state files
Depending on the implementation, local state locks may be reentrant
within the same process. Use a separate process to test locked state
files.
2017-02-03 15:31:21 -05:00
James Bardin 6a20c35d61 apply-test 2017-02-03 14:55:21 -05:00
James Bardin 91608843a4 Add state locking in taint/untaint 2017-02-03 14:55:21 -05:00
James Bardin a157ebbccd add -lock-state usage to plan/refresh/apply/destr 2017-02-03 14:17:17 -05:00
James Bardin 94f2f4d6ae Create state files first for backup tests
Previously when runnign a plan with no exitsing state, the plan would be
written out and then backed up on the next WriteState by another
BackupState instance. Since we now maintain a single State instance
thoughout an operation, the backup happens before any state exists so no
backup file is created.

This is OK, as the backup state the tests were checking for is from the
plan file, which already exists separate from the state.
2017-02-03 13:07:34 -05:00
James Bardin dd19cb202d add locking to plan and refresh commands 2017-02-02 18:08:28 -05:00
James Bardin 9cdba1f199 enable local state locking for apply
Have the LocalBackend lock the state during operations, and enble this
for the apply comand.
2017-02-02 18:08:28 -05:00
James Bardin 9acb86a182 Merge pull request #11187 from hashicorp/jbardin/state-locking
State Locking initial implementations
2017-02-01 14:35:55 -05:00
Seth Vargo 0d39123cb0
Update error message when no outputs are defined
Terraform can't tell the difference between an empty output and an
undefined output. This is often confusing for folks using interpolation.
As much as it would be great to fix upstream, changing this error
message to be a bit more helpful is a good stop-gap to avoid
frustration.
2017-01-31 15:20:11 -08:00
Seth Vargo 037d4b6c87
Suggest refresh instead of apply
Suggesting an apply could actually change remote resources whereas a
refresh will at-worst modify local state.
2017-01-31 15:12:11 -08:00
James Bardin 11d601ad6d TestRefresh_badState can be re-enabled
Refactored the code to maintain the behavior.
2017-01-30 18:06:30 -05:00
James Bardin 1380bbedb2 don't print err in Fatalf when it's nil 2017-01-30 18:02:35 -05:00
James Bardin b8bd4846db fix test despite original comments
Original comments were incorrect, and the test was checking for the
absence of state
2017-01-30 17:55:49 -05:00
James Bardin 39ca4fa2f8 Ensure that backend tests check for data in state
Test should not simply check for the existence of a file for state, but
make sure that file also contains data.
2017-01-30 17:48:39 -05:00
James Bardin 8f7f1917f2 Remove state file data when writing a nil state
The old behavior in this situation was to simply delete the file. Since
we now have a lock on this file we don't want to close or delete it, so
instead truncate the file at offset 0.

Fix a number of related tests
2017-01-30 17:16:57 -05:00
James Bardin eb59b5925e Fix some tests, and make rest fail with good errs
Having the state files always created for locking breaks a lot of tests.
Most can be fixed by simple checking for state within a file, but a few
still might be writing state when they shouldn't.
2017-01-30 17:16:57 -05:00
Mitchell Hashimoto 61881d2795 Merge pull request #10934 from hashicorp/f-provisioner-stop
core: stoppable provisioners, helper/schema for provisioners
2017-01-30 12:53:15 -08:00
Mitchell Hashimoto b8c310c61e
command: update test failure to correct message 2017-01-27 21:24:58 -08:00
Mitchell Hashimoto 09242fab09
terraform: remove legacy graph builder 2017-01-26 15:18:42 -08:00