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.
resource "execute_command" "command" {
command "/path/to/command"
destroy_command "/path/to/command"
}
command
- (Required) Command to execute on terraform Createdestroy_command
- (Optional) Command to execute on terraform destroyonly_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.
The below example will create a 'testfile' file when you run 'terraform apply' and delete the 'testfile' file when you run 'terraform destroy'
resource "execute_command" "commands" {
command = "touch testfile"
destroy_command = "rm testfile"
}
$ git clone https://github.com/samsung-cnct/terraform-provider-execute.git
$ cd terraform-exec-provider
$ go get; go build
Then copy the resulting binary to where terraform binary is.
$ brew tap 'samsung-cnct/terraform-provider-execute'
$ brew install terraform-provider-execute
This is a manual release process, we may automate it in the future if there is a need.
Steps:
- build linux executable:
GOOS=linux GOARCH=amd64 go build
- tar linux executable
tar -cf terraform-provider-execute_linux_amd64.tar terraform-provider-execute
- gzip linux executable
gzip terraform-provider-execute_linux_amd64.tar
- repeat above for darwin build
- click 'Draft a new release' on releases page
- fill out form
- Add both tar.gz files
Reccomended:
- update https://github.com/samsung-cnct/homebrew-terraform-provider-execute with new version information