Skip to content

Commit 52c421f

Browse files
committed
updated docs
1 parent 98bd080 commit 52c421f

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ terraform {
2929
## Usage
3030
```hcl
3131
resource "vagrant_vm" "my_vagrant_vm" {
32+
name = "vagrantbox"
3233
vagrantfile_dir = "path/to/dir"
3334
env = {
3435
KEY = "value",
@@ -37,17 +38,21 @@ resource "vagrant_vm" "my_vagrant_vm" {
3738
}
3839
```
3940

41+
**name** (optional) if the name changes, it will force the resource to destroy
42+
and recreate. Defaults to "vagrantbox".
43+
4044
**vagrantfile_dir** is the path to a directory where a Vagrantfile lives. The
4145
Vagrantfile must exist when terraform runs or else it will throw an error. This
4246
option defaults to `.`, ie, the current directory and you may set this value to
4347
absolute or relative paths.
4448

45-
**env** is a map of additional environment variables to pass to the Vagrantfile.
46-
The environment variables set by the calling process are always passed.
49+
**env** (optional) is a map of additional environment variables to pass to the
50+
Vagrantfile. The environment variables set by the calling process are always
51+
passed.
4752

48-
**get_ports** if `true`, information about forwarded ports will be filled in
49-
(see `ports` below). This is `false` by default because it may take some time
50-
to run.
53+
**get_ports** (optional) if `true`, information about forwarded ports will be
54+
filled in (see `ports` below). This is `false` by default because it may take
55+
some time to run.
5156

5257
If you have multiple Vagrantfiles, provide an `alias` in the `provider` block
5358
and use the `provider` meta-argument in the resource/data-source
@@ -103,6 +108,12 @@ resource "vagrant_vm" "my_vagrant_vm" {
103108
When the file changes, the hash will change, and terraform will ask for an
104109
update.
105110

111+
### Really Forcing an Update
112+
Changing an environment variable, as suggested above, essentially runs `vagrant
113+
reload`. Sometimes this isn't enough. If the resource's `name` changes, it will
114+
signal to terraform that it needs to completely destroy the resource and
115+
recreate it.
116+
106117
## Removing Machines
107118
Sadly, due to some limitations in vagrant, it's not possible to automatically
108119
remove a portion of machines from a Vagrantfile. In other words, if your

docs/resources/vm.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ In the example below, a environment variable, `VAGRANTFILE_HASH`, is set to
1515
the md5 hash of the Vagrantfile. When the file changes, the hash will change,
1616
and terraform will ask for an update.
1717

18+
### Really Forcing an Update
19+
Changing an environment variable, as suggested above, essentially runs `vagrant
20+
reload`. Sometimes this isn't enough. If the resource's `name` changes, it will
21+
signal to terraform that it needs to completely destroy the resource and
22+
recreate it.
23+
1824
## Example Usage
1925

2026
```terraform
@@ -33,6 +39,7 @@ resource "vagrant_vm" "my_vagrant_vm" {
3339

3440
### Optional
3541

42+
- **name** (String) If the name changes, it will force terraform to destroy and recreate the resource. Defaults to "vagrantbox".
3643
- **env** (Map of String) Environment variables to pass to the Vagrantfile.
3744
- **get_ports** (Boolean) Whether or not to retrieve forwarded port information. See `ports`. Defaults to `false`.
3845
- **id** (String) The ID of this resource.

resource_vagrant_vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func resourceVagrantVM() *schema.Resource {
3737
SchemaVersion: 1,
3838
Schema: map[string]*schema.Schema{
3939
"name": {
40-
Description: "Name of the Vagrant resource",
40+
Description: "Name of the Vagrant resource. Forces resource to destroy/recreate if changed.",
4141
Type: schema.TypeString,
4242
Optional: true,
4343
Default: "vagrantbox",

0 commit comments

Comments
 (0)