Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Jul 31, 2021
1 parent 98bd080 commit 52c421f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ terraform {
## Usage
```hcl
resource "vagrant_vm" "my_vagrant_vm" {
name = "vagrantbox"
vagrantfile_dir = "path/to/dir"
env = {
KEY = "value",
Expand All @@ -37,17 +38,21 @@ resource "vagrant_vm" "my_vagrant_vm" {
}
```

**name** (optional) if the name changes, it will force the resource to destroy
and recreate. Defaults to "vagrantbox".

**vagrantfile_dir** is the path to a directory where a Vagrantfile lives. The
Vagrantfile must exist when terraform runs or else it will throw an error. This
option defaults to `.`, ie, the current directory and you may set this value to
absolute or relative paths.

**env** is a map of additional environment variables to pass to the Vagrantfile.
The environment variables set by the calling process are always passed.
**env** (optional) is a map of additional environment variables to pass to the
Vagrantfile. The environment variables set by the calling process are always
passed.

**get_ports** if `true`, information about forwarded ports will be filled in
(see `ports` below). This is `false` by default because it may take some time
to run.
**get_ports** (optional) if `true`, information about forwarded ports will be
filled in (see `ports` below). This is `false` by default because it may take
some time to run.

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

### Really Forcing an Update
Changing an environment variable, as suggested above, essentially runs `vagrant
reload`. Sometimes this isn't enough. If the resource's `name` changes, it will
signal to terraform that it needs to completely destroy the resource and
recreate it.

## Removing Machines
Sadly, due to some limitations in vagrant, it's not possible to automatically
remove a portion of machines from a Vagrantfile. In other words, if your
Expand Down
7 changes: 7 additions & 0 deletions docs/resources/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ In the example below, a environment variable, `VAGRANTFILE_HASH`, is set to
the md5 hash of the Vagrantfile. When the file changes, the hash will change,
and terraform will ask for an update.

### Really Forcing an Update
Changing an environment variable, as suggested above, essentially runs `vagrant
reload`. Sometimes this isn't enough. If the resource's `name` changes, it will
signal to terraform that it needs to completely destroy the resource and
recreate it.

## Example Usage

```terraform
Expand All @@ -33,6 +39,7 @@ resource "vagrant_vm" "my_vagrant_vm" {

### Optional

- **name** (String) If the name changes, it will force terraform to destroy and recreate the resource. Defaults to "vagrantbox".
- **env** (Map of String) Environment variables to pass to the Vagrantfile.
- **get_ports** (Boolean) Whether or not to retrieve forwarded port information. See `ports`. Defaults to `false`.
- **id** (String) The ID of this resource.
Expand Down
2 changes: 1 addition & 1 deletion resource_vagrant_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resourceVagrantVM() *schema.Resource {
SchemaVersion: 1,
Schema: map[string]*schema.Schema{
"name": {
Description: "Name of the Vagrant resource",
Description: "Name of the Vagrant resource. Forces resource to destroy/recreate if changed.",
Type: schema.TypeString,
Optional: true,
Default: "vagrantbox",
Expand Down

0 comments on commit 52c421f

Please sign in to comment.