-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FWB: update to support latest AzureRM provider
- Loading branch information
Showing
12 changed files
with
477 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
#!/bin/bash | ||
echo " | ||
############################################################################################################## | ||
# | ||
# FortiWeb VM | ||
# Terraform deployment template for Microsoft Azure | ||
# | ||
############################################################################################################## | ||
" | ||
|
||
# Stop running when command returns error | ||
set -e | ||
|
||
############################################################################################################## | ||
# FortiWeb variables | ||
# | ||
# FortiWeb version | ||
# Default = latest | ||
# | ||
############################################################################################################## | ||
#export TF_VAR_FWB_IMAGE_SKU="" | ||
#export TF_VAR_FWB_VERSION="" | ||
#export TF_VAR_FWB_BYOL_LICENSE_FILE="" | ||
|
||
PLAN="terraform.tfplan" | ||
|
||
if [ -z "$DEPLOY_LOCATION" ] | ||
then | ||
# Input location | ||
echo -n "Enter location (e.g. eastus2): " | ||
stty_orig=`stty -g` # save original terminal setting. | ||
read location # read the location | ||
stty $stty_orig # restore terminal setting. | ||
if [ -z "$location" ] | ||
then | ||
location="eastus2" | ||
fi | ||
else | ||
location="$DEPLOY_LOCATION" | ||
fi | ||
export TF_VAR_location="$location" | ||
echo "" | ||
echo "--> Deployment in $location location ..." | ||
echo "" | ||
|
||
if [ -z "$DEPLOY_PREFIX" ] | ||
then | ||
# Input prefix | ||
echo -n "Enter prefix: " | ||
stty_orig=`stty -g` # save original terminal setting. | ||
read prefix # read the prefix | ||
stty $stty_orig # restore terminal setting. | ||
if [ -z "$prefix" ] | ||
then | ||
prefix="FORTI" | ||
fi | ||
else | ||
prefix="$DEPLOY_PREFIX" | ||
fi | ||
export TF_VAR_prefix="$prefix" | ||
echo "" | ||
echo "--> Using prefix $prefix for all resources ..." | ||
echo "" | ||
rg_cgf="$prefix-RG" | ||
|
||
if [ -z "$DEPLOY_USERNAME" ] | ||
then | ||
# Input username | ||
echo -n "Enter username (default: azureuser): " | ||
stty_orig=`stty -g` # save original terminal setting. | ||
read username # read the prefix | ||
stty $stty_orig # restore terminal setting. | ||
if [ -z "$USERNAME" ] | ||
then | ||
username="azureuser" | ||
fi | ||
else | ||
username="$DEPLOY_USERNAME" | ||
fi | ||
echo "" | ||
echo "--> Using username '$username' ..." | ||
echo "" | ||
|
||
if [ -z "$DEPLOY_PASSWORD" ] | ||
then | ||
# Input password | ||
echo -n "Enter password: " | ||
stty_orig=`stty -g` # save original terminal setting. | ||
stty -echo # turn-off echoing. | ||
read passwd # read the password | ||
stty $stty_orig # restore terminal setting. | ||
echo "" | ||
else | ||
passwd="$DEPLOY_PASSWORD" | ||
echo "" | ||
echo "--> Using password found in env variable DEPLOY_PASSWORD ..." | ||
echo "" | ||
fi | ||
password="$passwd" | ||
|
||
if [ -z "$DEPLOY_SUBSCRIPTION_ID" ] | ||
then | ||
detected_id=`az account show | jq ".id" -r` | ||
# Input username | ||
echo -n "Enter subscription ID (press enter for detected id: '$detected_id'): " | ||
stty_orig=`stty -g` # save original terminal setting. | ||
read subscription_id # read the subscription id | ||
stty $stty_orig # restore terminal setting. | ||
if [ -z "$subscription_id" ] | ||
then | ||
subscription_id="$detected_id" | ||
fi | ||
else | ||
subscription_id="$DEPLOY_SUBSCRIPTION_ID" | ||
fi | ||
export TF_VAR_subscription_id="$subscription_id" | ||
echo "" | ||
echo "--> Using subscription id '$subscription_id' ..." | ||
echo "" | ||
|
||
SUMMARY="summary.out" | ||
|
||
echo "" | ||
echo "==> Starting Terraform deployment" | ||
echo "" | ||
cd terraform/ | ||
|
||
echo "" | ||
echo "==> Terraform init" | ||
echo "" | ||
terraform init | ||
|
||
echo "" | ||
echo "==> Terraform plan" | ||
echo "" | ||
terraform plan --out "$PLAN" \ | ||
-var "username=$username" \ | ||
-var "password=$password" | ||
|
||
echo "" | ||
echo "==> Terraform apply" | ||
echo "" | ||
terraform apply "$PLAN" | ||
if [[ $? != 0 ]]; | ||
then | ||
echo "--> ERROR: Deployment failed ..." | ||
exit $result; | ||
fi | ||
|
||
echo "" | ||
echo "==> Terraform output deployment summary" | ||
echo "" | ||
terraform output deployment_summary > "../output/$SUMMARY" | ||
|
||
cd ../ | ||
cat "output/$SUMMARY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
echo " | ||
############################################################################################################## | ||
# | ||
# FortiWeb VM | ||
# Terraform deployment template for Microsoft Azure | ||
# | ||
############################################################################################################## | ||
" | ||
|
||
# Stop running when command returns error | ||
set -e | ||
|
||
PLAN="terraform.tfplan" | ||
STATE="terraform.tfstate" | ||
|
||
cd terraform/ | ||
echo "" | ||
echo "==> Starting Terraform destroy" | ||
echo "" | ||
|
||
echo "" | ||
echo "==> Terraform init" | ||
echo "" | ||
terraform init | ||
|
||
echo "" | ||
echo "==> terraform destroy" | ||
echo "" | ||
terraform destroy -auto-approve | ||
if [[ $? != 0 ]]; | ||
then | ||
echo "--> ERROR: Destroy failed ..." | ||
rg=`grep -m 1 -o '"resource_group_name": "[^"]*' "$STATE" | grep -o '[^"]*$'` | ||
echo "--> Trying to delete the resource group $rg..." | ||
az group delete --resource-group "$rg" | ||
exit $rc; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.