Files
devops-directive-terraform-…/08-testing/tests/bash/hello_world_test.sh
2021-05-27 14:35:03 -07:00

22 lines
499 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Change directory to example
cd ../../examples/hello-world
# Create the resources
terraform init
terraform apply -auto-approve
# Wait while the instance boots up
# (Could also use a provisioner in the TF config to do this)
sleep 60
# Query the output, extract the IP and make a request
terraform output -json |\
jq -r '.instance_ip_addr.value' |\
xargs -I {} curl http://{}:8080 -m 10
# If request succeeds, destroy the resources
terraform destroy -auto-approve