Commit Graph

96 Commits

Author SHA1 Message Date
James Bardin 718ede0636 have Meta.Backend use a Config rather than loading
Instead of providing the a path in BackendOpts, provide a loaded
*config.Config instead. This reduces the number of places where
configuration is loaded.
2017-06-09 14:03:59 -07:00
James Bardin 6ef7c83ec5 add data-loss warning to SIGINT handler in apply
Warning user about data loss after receiving an interrupt.
2017-04-25 11:43:59 -04:00
James Bardin 5eca913b14 add cli flags for -lock-timeout
Add the -lock-timeout flag to the appropriate commands.
Add the -lock flag to `init` and `import` which were missing it.
Set both stateLock and stateLockTimeout in Meta.flagsSet, and remove the
extra references for clarity.
2017-04-01 17:09:21 -04: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 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 a157ebbccd add -lock-state usage to plan/refresh/apply/destr 2017-02-03 14:17:17 -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
Mitchell Hashimoto ad7b063262
command: convert to use backends 2017-01-26 14:33:49 -08:00
Mitchell Hashimoto 785cc7b78a
terraform: default new graphs on, old graphs behind -Xlegacy-graph
This turns the new graphs on by default and puts the old graphs behind a
flag `-Xlegacy-graph`. This effectively inverts the current 0.7.x
behavior with the new graphs.

We've incubated most of these for a few weeks now. We've found issues
and we've fixed them and we've been using these graphs internally for
awhile without any major issue. Its time to default them on and get them
part of a beta.
2016-11-10 21:53:20 -08:00
Mitchell Hashimoto 57c0cadc79 Merge pull request #9666 from hashicorp/jbardin/debug
preliminary debug output
2016-11-04 09:03:58 -07:00
James Bardin 797a1b339d DebugInfo and DebugGraph
Implement debugInfo and the DebugGraph

DebugInfo will be a global variable through which graph debug
information can we written to a compressed archive. The DebugInfo
methods are all safe for concurrent use, and noop with a nil receiver.
The API outside of the terraform package will be to call SetDebugInfo
to create the archive, and CloseDebugInfo() to properly close the file.
Each write to the archive will be flushed and sync'ed individually, so
in the event of a crash or a missing call to Close, the archive can
still be recovered.

The DebugGraph is a representation of a terraform Graph to be written to
the debug archive, currently in dot format. The DebugGraph also contains
an internal buffer with Printf and Write methods to add to this buffer.
The buffer will be written to an accompanying file in the debug archive
along with the graph.

This also adds a GraphNodeDebugger interface. Any node implementing
`NodeDebug() string` can output information to annotate the debug graph
node, and add the data to the log. This interface may change or be
removed to provide richer options for debugging graph nodes.

The new graph builders all delegate the build to the BasicGraphBuilder.
Having a Name field lets us differentiate the actual builder
implementation in the debug graphs.
2016-11-04 11:30:51 -04:00
Mitchell Hashimoto d429e82661
command: show shadow errors to the user 2016-11-03 18:14:07 -07:00
Mitchell Hashimoto 6c801d0386
command/apply: add additional nil check to loading state for outputs 2016-11-02 22:33:49 -07:00
Mitchell Hashimoto af82be19ea
helper/experiment: a helper for setting, making experiments
This creates a standard package and interface for defining, querying,
setting experiments (`-X` flags).

I expect we'll want to continue to introduce various features behind
experimental flags. I want to make doing this as easy as possible and I
want to make _removing_ experiments as easy as possible as well.

The goal with this packge has been to rely on the compiler enforcing our
experiment references as much as possible. This means that every
experiment is a global variable that must be referenced directly, so
when it is removed you'll get compiler errors where the experiment is
referenced.

This also unifies and makes it easy to grab CLI flags to enable/disable
experiments as well as env vars! This way defining an experiment is just
a couple lines of code (documented on the package).
2016-10-26 15:47:58 -04:00
Mitchell Hashimoto 1a418c1452
command/apply: -Xnew-destroy 2016-10-22 12:36:47 -07:00
Mitchell Hashimoto e8516f259d
command/apply: Xnew-apply 2016-10-19 13:39:28 -07:00
Radek Simko 8494cad8c4 Output 'destroy complete' when it's destroy (was: apply) (#8453) 2016-08-25 22:26:40 +01:00
James Nugent 0e4e94a86f core: Fix -module for terraform output command
The behaviour whereby outputs for a particular nested module can be
output was broken by the changes for lists and maps. This commit
restores the previous behaviour by passing the module path into the
outputsAsString function.

We also add a new test of this since the code path for indivdual output
vs all outputs for a module has diverged.
2016-07-29 16:39:59 -05:00
James Nugent 3ea3c657b5 core: Use OutputState in JSON instead of map
This commit forward ports the changes made for 0.6.17, in order to store
the type and sensitive flag against outputs.

It also refactors the logic of the import for V0 to V1 state, and
fixes up the call sites of the new format for outputs in V2 state.

Finally we fix up tests which did not previously set a state version
where one is required.
2016-05-18 13:25:20 -05:00
James Nugent 6a20e8927d core: Fix issues from rebasing dev-0.7 onto master
- Fix sensitive outputs for lists and maps
- Fix test prelude which was missed during conflict resolution
- Fix `terraform output` to match old behaviour and not have outputs
  header and colouring
- Bump timeout on TestAtlasClient_UnresolvableConflict
2016-05-10 15:43:50 -04:00
James Nugent e57a399d71 core: Use native HIL maps instead of flatmaps
This changes the representation of maps in the interpolator from the
dotted flatmap form of a string variable named "var.variablename.key"
per map element to use native HIL maps instead.

This involves porting some of the interpolation functions in order to
keep the tests green, and adding support for map outputs.

There is one backwards incompatibility: as a result of an implementation
detail of maps, one could access an indexed map variable using the
syntax "${var.variablename.key}".

This is no longer possible - instead HIL native syntax -
"${var.variablename["key"]}" must be used. This was previously
documented, (though not heavily used) so it must be noted as a backward
compatibility issue for Terraform 0.7.
2016-05-10 14:49:13 -04:00
James Nugent b62f6af158 core: Add support for marking outputs as sensitive (#6559)
* core: Add support for marking outputs as sensitive

This commit allows an output to be marked "sensitive", in which case the
value is redacted in the post-refresh and post-apply list of outputs.

For example, the configuration:

```
variable "input" {
    default = "Hello world"
}

output "notsensitive" {
    value = "${var.input}"
}

output "sensitive" {
    sensitive = true
    value = "${var.input}"
}
```

Would result in the output:

```
terraform apply

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

  notsensitive = Hello world
  sensitive    = <sensitive>
```

The `terraform output` command continues to display the value as before.

Limitations: Note that sensitivity is not tracked internally, so if the
output is interpolated in another module into a resource, the value will
be displayed. The value is still present in the state.
2016-05-09 15:46:07 -04:00
David Glasser b44f7f28e0 Document saved plan use in `terraform apply -help` (#6126)
Wording borrowed from the website docs.
2016-04-11 12:24:08 -05:00
Jake Champlin 39e7f42490 Clear up `destroy --target` message
When destroying infrastructure with `--target`, print out which
infrastructure will be destroyed instead of saying `Terraform will
delete all your managed infrastructure`.

```
 terraform destroy --target aws_instance.test2 --target aws_instance.test1
Do you really want to destroy?
  Terraform will delete the following infrastructure:
        aws_instance.test2
        aws_instance.test1
  There is no undo. Only 'yes' will be accepted to confirm
```

Omitting `--target` arguments will use the default input description.

```
$ terraform destroy
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.
```
2015-11-11 12:04:58 -05:00
Mitchell Hashimoto 344e7c26b5 fix a bunch of tests from go-getter import 2015-10-15 13:48:58 -07:00
Paul Hinze 374070d066 website: docs for parallelism setting
/cc @stack72 @knuckolls @mitchellh
2015-10-05 17:21:29 -05:00
Paul Hinze e1a46904d6 command: pull parallelism default up to CLI layer
/cc @knuckolls @josephholsten
2015-10-05 15:06:08 -05:00
Kevin Nuckolls f59c71b35a works for apply, no tests yet 2015-09-29 22:41:26 -07:00
Anthony Scalisi 198e1a5186 remove various typos 2015-09-11 11:56:20 -07:00
Paul Hinze ad680b1832 core: show outputs after `terraform refresh`
closes #25
2015-06-15 10:41:42 -05:00
Paul Hinze 18924d24fe command/apply: flatten multierrors
Before:

```
Error applying plan:

1 error(s) occurred:

* 1 error(s) occurred:

* 1 error(s) occurred:

* 1 error(s) occurred:

* Error creating ...
```

After:

```
Error applying plan:

1 error(s) occurred:

* Error creating ...
```

Muuuch better! :D
2015-06-07 21:32:00 -05:00
Paul Hinze 97acccd3ed core: targeted operations
Add `-target=resource` flag to core operations, allowing users to
target specific resources in their infrastructure. When `-target` is
used, the operation will only apply to that resource and its
dependencies.

The calculated dependencies are different depending on whether we're
running a normal operation or a `terraform destroy`.

Generally, "dependencies" refers to ancestors: resources falling
_before_ the target in the graph, because their changes are required to
accurately act on the target.

For destroys, "dependencies" are descendents: those resources which fall
_after_ the target. These resources depend on our target, which is going
to be destroyed, so they should also be destroyed.
2015-03-31 14:49:38 -05:00
Mitchell Hashimoto 95cf69aa32 command: StateHook for continous state updates 2015-02-23 21:57:17 -08:00
Mitchell Hashimoto fb3f10efb0 command/apply: ask for user variables before validation [GH-736] 2015-01-16 10:46:38 -08:00
Mitchell Hashimoto 90138825a2 command/apply: don't init if no args given [GH-780]
I really don't know how to unit test this since I don't know what input
triggers this except that it has been reporting a few times in the wild.
2015-01-16 10:22:20 -08:00
Armon Dadgar 0fb87e499d command: Meta provides the state output path 2014-12-10 13:27:09 -08:00
Armon Dadgar bf10111745 command/apply: Move state persistence to Meta 2014-12-10 13:27:09 -08:00
Armon Dadgar 5b745e5d46 command: Run validation before asking for input. Fixes #602 2014-12-08 18:32:03 -08:00
Panagiotis Moustafellos 3d51bae4b2 switch phrasing 2014-10-15 18:57:24 +03:00
Panagiotis Moustafellos 08515edc43 fixed typo on terraform destroy 2014-10-15 11:17:56 +03:00
Mitchell Hashimoto 8fc134caa1 command/destroy: don't show outputs 2014-10-11 17:37:28 -07:00
Mitchell Hashimoto 0914e17a2a command/apply: more than one ctrl-c properly exits immediately 2014-10-11 13:23:15 -07:00
Mitchell Hashimoto 16b023bd2b command: ask for the proper level of input 2014-10-08 10:29:54 -07:00
Mitchell Hashimoto a5f70ead2d command: destroy should ask for confirmation always 2014-10-03 16:08:50 -07:00
Mitchell Hashimoto 95f43d8230 command/apply: if with plan, don't ask for input [GH-346] 2014-10-01 08:43:00 -07:00
Mitchell Hashimoto 817f0d9f30 command: don't ask for input if terraform.tfvars file given [GH-346] 2014-10-01 08:37:57 -07:00
Mitchell Hashimoto 2131e4ffd2 command: fix failing tests 2014-09-30 22:11:55 -07:00
Mitchell Hashimoto 245c1ce05a command: enable destroy 2014-09-30 22:01:11 -07:00
Mitchell Hashimoto ab9dd71bcb command/destroy: first steps 2014-09-30 21:49:24 -07:00