mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-10 12:51:14 +00:00
22 lines
499 B
Bash
Executable File
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
|