Enabled of using existing security group
This commit is contained in:
parent
0e00cffe4d
commit
c298cc7ae1
|
@ -58,7 +58,7 @@ function prepare_geny_aws() {
|
|||
echo $ami
|
||||
echo $sg
|
||||
|
||||
#TODO: remove this dirty hack (this version will be ignored anyway!)
|
||||
#TODO: remove this dirty hack
|
||||
if [[ $android_version == null ]]; then
|
||||
echo "[HACK] Version cannot be empty! version will be added!"
|
||||
android_version="6.0"
|
||||
|
@ -69,6 +69,9 @@ function prepare_geny_aws() {
|
|||
echo "Custom security group is found!"
|
||||
security_group=""
|
||||
|
||||
is_array=$(echo "${sg}" | jq 'if type=="array" then true else false end')
|
||||
if [ $is_array == "true" ]; then
|
||||
echo "New security group with given rules will be created"
|
||||
for i in $(echo "${sg}" | jq -r '.[] | @base64'); do
|
||||
get_value() {
|
||||
echo ${i} | base64 --decode | jq -r ${1}
|
||||
|
@ -99,6 +102,20 @@ _EOF
|
|||
)
|
||||
done
|
||||
done
|
||||
else
|
||||
#TODO: remove this dirty hack
|
||||
echo "Given security group will be used!"
|
||||
is_array="false"
|
||||
security_group=$(cat <<_EOF
|
||||
ingress {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
_EOF
|
||||
)
|
||||
fi
|
||||
else
|
||||
echo "Custom security is not found! It will use default security group!"
|
||||
security_group=$(cat <<_EOF
|
||||
|
@ -215,11 +232,17 @@ _EOF
|
|||
echo "$aws_tf_content" > /root/aws_tf_$index.tf
|
||||
|
||||
if [[ $ami != null ]]; then
|
||||
echo "Custom AMI is found!"
|
||||
echo "Using given AMI!"
|
||||
sed -i "s/.*ami=.*/ ami=\"$ami\"/g" /root/aws_tf_$index.tf
|
||||
else
|
||||
echo "Custom AMI is not found. It will use the latest AMI!"
|
||||
fi
|
||||
|
||||
if [[ $sg != null ]] && [[ $is_array == "false" ]]; then
|
||||
echo "Using given security group: $sg"
|
||||
sed -i "s/.*vpc_security_group_ids=.*/ vpc_security_group_ids=[\"$sg\"]/g" /root/aws_tf_$index.tf
|
||||
fi
|
||||
|
||||
echo "---------------------------------------------------------"
|
||||
|
||||
((index++))
|
||||
|
|
Loading…
Reference in a new issue