Provision loadbalancer with terraform and custom scripts

This commit is contained in:
Paul-Henri Froidmont 2019-08-17 23:58:36 +02:00
parent 01b7e79e55
commit 77a6ef36f3
8 changed files with 136 additions and 29 deletions

17
terraform/scripts/delete_lb.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
set -e
set -x
export TOKEN=`jq '.token' -r ~/.scwrc`
REGION="fr-par"
ORGANIZATION_ID=`jq '.organization' -r ~/.scwrc`
LB_IP=$1
IP_ID=$(http GET "https://api.scaleway.com/lb/v1/regions/$REGION/ips" X-Auth-Token:$TOKEN | jq -r ".ips[] | select(.ip_address == \"$LB_IP\") | .id")
echo "IP_ID: $IP_ID"
LB_ID=$(http GET "https://api.scaleway.com/lb/v1/regions/$REGION/lbs" X-Auth-Token:$TOKEN | jq -r ".lbs[] | select(.ip[0].id == \"$IP_ID\") | .id")
http DELETE "https://api.scaleway.com/lb/v1/regions/$REGION/lbs/$LB_ID" X-Auth-Token:$TOKEN