Will be executed only on trigger change
resource "null_resource" "first" {
}
resource "null_resource" "sleep" {
provisioner "local-exec" {
command = "sleep 10"
}
triggers = {
res_id = null_resource.first.id
}
}
resource "null_resource" "second" {
id = null_resource.sleep.triggers.res_id
}
Will be executed each time
resource "null_resource" "first" {
}
data "external" "echo_sleep" {
program = ["python3", "./echo-sleep.py"]
query = {
echo = null_resource.first.id
sleep = 30
}
}
resource "null_resource" "second" {
id = data.external.echo_sleep.result.echo
}
import json
import sys
import time
def handler(arg):
echo = arg['echo']
ret = {
'echo' : echo
}
time.sleep(int(arg['sleep']))
print("{}".format(json.dumps(ret)))
if __name__ == '__main__':
data = json.load(sys.stdin)
handler(data)
exit(0)