This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
# terraform-provider-exec | ||
|
||
Provides an ability to execute arbitrary commands | ||
# terraform-provider-execute | ||
|
||
Terraform plugin mostly based on https://github.com/gosuri/terraform-exec-provider (thanks!!!). Provides an ability to execute arbitrary commands on Terraform create and destroy. | ||
|
||
## Usage | ||
|
||
resource "exec" "command" { | ||
command "/path/to/command" | ||
destroy_command "/path/to/command" | ||
} | ||
|
||
### Attribute reference | ||
|
||
* `command` - (Required) Command to execute | ||
* `only_if` - (Optional) Guard attribute, to create the resource (Execute) the command only if this guard is satisfied. If the command returns 0, the guard is applied. If the command returns any other value, then the guard attribute is not applied. | ||
|
||
|
||
### Examples | ||
* `command` - (Required) Command to execute on terraform Create | ||
* `destroy_command` - (Optional) Command to execute on terraform destroy | ||
* `only_if` - (Optional) Guard attribute, to create the resource (Execute) the command only if this guard is satisfied. If the command returns 0, the guard is applied. If the command returns any other value, then the guard attribute is not applied. | ||
* `timeout` - (Optional) Create/Destroy max timeout | ||
|
||
The below example will run the command after creating VPCs, where `commands/peer-vpc` is shell script to add peering connection between VPCs and will be executed after the VPCs are created when `depends_on` attribute is specified. | ||
|
||
resource "aws_vpc" "primary" { | ||
cidr_block = "10.0.0.0/16" | ||
} | ||
### Examples | ||
|
||
resource "aws_vpc" "app" { | ||
cidr_block = "10.1.0.0/16" | ||
} | ||
The below example will create a 'testfile' file when you run 'terraform apply' and delete the 'testfile' file when you run 'terraform destroy' | ||
|
||
resource "exec", "peer_vpcs" { | ||
command = "commands/peer-vpc ${aws_vpc.primary.id} ${aws_vpc.app.id}" | ||
depends_on = ["aws_vpc.primary.id","aws_vpc.app"] | ||
resource "execute_command" "commands" { | ||
command = "touch testfile" | ||
destroy_command = "rm testfile" | ||
} | ||
|
||
## Installation | ||
|
||
$ git clone https://github.com/gosuri/terraform-exec-provider.git | ||
$ cd terraform-exec-provider | ||
$ make install | ||
$ go get |