Skip to content

Instantly share code, notes, and snippets.

@JBirdVegas
Created November 21, 2017 16:59
Show Gist options
  • Save JBirdVegas/9e508d2ce4266fd7c242c3f080f5368f to your computer and use it in GitHub Desktop.
Save JBirdVegas/9e508d2ce4266fd7c242c3f080f5368f to your computer and use it in GitHub Desktop.
Gist to showcase configuration to trigger error in terraform
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