Created
November 21, 2017 16:59
-
-
Save JBirdVegas/9e508d2ce4266fd7c242c3f080f5368f to your computer and use it in GitHub Desktop.
Gist to showcase configuration to trigger error in terraform
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
resource "null_resource" "write_py" { | |
triggers { | |
time = "${timestamp()}" | |
} | |
provisioner "local-exec" { | |
command = <<PYTHON | |
echo "import json | |
from concurrent.futures import ThreadPoolExecutor | |
from time import sleep | |
def long_running(): | |
sleep(10) | |
def do_some_work(): | |
with ThreadPoolExecutor(2) as worker: | |
worker.submit(long_running) | |
worker.submit(long_running) | |
return True | |
def notify_terraform(status: bool = False): | |
print(json.dumps({ | |
'status': status | |
})) | |
if __name__ == "__main__": | |
work_result = do_some_work() | |
notify_terraform(work_result) | |
">${path.module}/something.py | |
PYTHON | |
} | |
} | |
data "external" "test_python" { | |
program = [ | |
"python3", | |
"${path.module}/something.py" | |
] | |
depends_on = [ | |
"null_resource.write_py" | |
] | |
} | |
output "result_of_python_test" { | |
value = "${data.external.test_python.result.status}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment