mirror of
https://github.com/ghndrx/terraform.git
synced 2026-02-10 14:55:06 +00:00
``` for code block
This commit is contained in:
@@ -436,20 +436,24 @@ Alternatives to Provisioners:
|
|||||||
* environment (optional)
|
* environment (optional)
|
||||||
* A map of environment variables to set prior to execution. This is useful for passing secret values to scripts.
|
* A map of environment variables to set prior to execution. This is useful for passing secret values to scripts.
|
||||||
|
|
||||||
|
```
|
||||||
resource "aws_instance" "web" {
|
resource "aws_instance" "web" {
|
||||||
# ...
|
# ...
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
command = "echo ${aws_instance.web.private_ip} >> private_ips.txt"
|
command = "echo ${aws_instance.web.private_ip} >> private_ips.txt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
resource "null_resource" "example2" {
|
resource "null_resource" "example2" {
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
command = "Get-Date > completed.txt"
|
command = "Get-Date > completed.txt"
|
||||||
interpreter = ["PowerShell", "-Command"]
|
interpreter = ["PowerShell", "-Command"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
```
|
||||||
resource "aws_instance" "web" {
|
resource "aws_instance" "web" {
|
||||||
# ...
|
# ...
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
@@ -461,6 +465,7 @@ Alternatives to Provisioners:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Remote-Exec
|
## Remote-Exec
|
||||||
* Remote-Exec allows you to execute commands on a target resource after a resource is provisioned
|
* Remote-Exec allows you to execute commands on a target resource after a resource is provisioned
|
||||||
|
|||||||
Reference in New Issue
Block a user