mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-16 15:51:15 +00:00
add modules 5-9
This commit is contained in:
21
08-testing/tests/bash/hello_world_test.sh
Executable file
21
08-testing/tests/bash/hello_world_test.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user