Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adding function to render AWS Ec2 Types based on selection #88

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 28 additions & 145 deletions examples/zsec
Original file line number Diff line number Diff line change
Expand Up @@ -503,30 +503,33 @@ first_run="yes"

# AWS EC2 type selection
PS3="${CYAN}Select AWS EC2 instance type for $cc_instance_size Cloud Connector: ${RESET}"
# Function handles string manuplation so that we don't render something like
# "t3a.medium - Not recommended for production use" as a TF_VAR
# when a user select this instance type

function select_instance_type {
local vm_sizes=("$@")
echo "Please select a CC VM instance type:"
select description in "${vm_sizes[@]}"
do
if [[ -n "$description" ]]; then
vm_size=$(echo "$description" | awk '{print $1}')
echo -e "CC EC2 type: ${GREEN}${vm_size}${RESET}"
echo "export TF_VAR_ccvm_instance_type='${vm_size}'" >> .zsecrc
break
else
echo -e "${RED}Invalid response. Please enter a number selection${RESET}"
fi
done
}

if [[ "$cc_instance_size" == "small" ]]; then
if [[ "$aws_region" == "eu-south-2" || "$aws_region" == "ap-southeast-4" ]]; then
vm_sizes=(
"c6in.large - Recommended"
"t3.medium - Not recommended for production use"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}c6in.large${RESET}"
echo "export TF_VAR_ccvm_instance_type='c6in.large'" >> .zsecrc
break
;;
2)
echo "CC EC2 type: ${GREEN}c6in.large${RESET}"
echo "export TF_VAR_ccvm_instance_type='c6in.large'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
select_instance_type "${vm_sizes[@]}"
else
vm_sizes=(
"m6i.large - Recommended"
Expand All @@ -535,62 +538,15 @@ first_run="yes"
"c6in.large"
"t3.medium - Not recommended for production use"
"t3a.medium - Not recommended for production use"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}m6i.large${RESET}"
echo "export TF_VAR_ccvm_instance_type='m6i.large'" >> .zsecrc
break
;;
2)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
3)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
4)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
5)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
6)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
)
select_instance_type "${vm_sizes[@]}"
fi
elif [[ "$cc_instance_size" == "medium" ]]; then
if [[ "$aws_region" == "eu-south-2" || "$aws_region" == "ap-southeast-4" ]]; then
vm_sizes=(
"c6in.4xlarge"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}m6i.4xlarge${RESET}"
echo "export TF_VAR_ccvm_instance_type='m6i.4xlarge'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
select_instance_type "${vm_sizes[@]}"
else
vm_sizes=(
"m6i.4xlarge - Recommended"
Expand All @@ -599,99 +555,26 @@ first_run="yes"
"c6in.4xlarge"
"c5.4xlarge"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}m6i.4xlarge${RESET}"
echo "export TF_VAR_ccvm_instance_type='m6i.4xlarge'" >> .zsecrc
break
;;
2)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
3)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
4)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
5)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
select_instance_type "${vm_sizes[@]}"
fi
elif [[ "$cc_instance_size" == "large" ]]; then
if [[ "$aws_region" == "eu-south-2" || "$aws_region" == "ap-southeast-4" ]]; then
vm_sizes=(
"c6in.4xlarge"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}m6i.4xlarge${RESET}"
echo "export TF_VAR_ccvm_instance_type='m6i.4xlarge'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
select_instance_type "${vm_sizes[@]}"
else
vm_sizes=(
"m6i.4xlarge - Recommended"
"m5n.4xlarge"
"c6i.4xlarge"
"c6in.4xlarge"
"c5.4xlarge"
)
select ccvm_instance_type in "${vm_sizes[@]}"
do
case $REPLY in
1)
echo "CC EC2 type: ${GREEN}m6i.4xlarge${RESET}"
echo "export TF_VAR_ccvm_instance_type='m6i.4xlarge'" >> .zsecrc
break
;;
2)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
3)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
4)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
5)
echo "CC EC2 type: ${GREEN}$ccvm_instance_type${RESET}"
echo "export TF_VAR_ccvm_instance_type='$ccvm_instance_type'" >> .zsecrc
break
;;
*)
echo "${RED}Invalid response. Please enter a number selection${RESET}"
esac
done
)
select_instance_type "${vm_sizes[@]}"
fi
fi

read -r -p "${CYAN}Enter CC Provisioning URL${RESET} (E.g. connector.zscaler.net/api/v1/provUrl?name=aws_prov_url): " cc_vm_prov_url
echo "Provisioning URL entered is: ${GREEN}$cc_vm_prov_url${RESET}. ${YELLOW}Make sure this matches the CC Instance Size $cc_instance_size chosen${RESET}"
echo "export TF_VAR_cc_vm_prov_url=${cc_vm_prov_url}" >> .zsecrc
Expand Down
Loading