openvidu-deployment: Don't rely on aws http endpoint to update KMS AMI

pull/553/head
cruizba 2020-11-04 22:42:04 +01:00
parent 42e14a9610
commit c9235e64cf
1 changed files with 3 additions and 4 deletions

View File

@ -315,10 +315,8 @@ upgrade_ov() {
[ ! -z "${OLD_MODE}" ] && sed -i -r "s/Installation Mode:.+/Installation Mode: ${OLD_MODE}/" "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml" [ ! -z "${OLD_MODE}" ] && sed -i -r "s/Installation Mode:.+/Installation Mode: ${OLD_MODE}/" "${OPENVIDU_PREVIOUS_FOLDER}/docker-compose.yml"
# In Aws, update AMI ID # In Aws, update AMI ID
CHECK_AWS=$(curl -s -o /dev/null -w "%{http_code}" http://169.254.169.254)
if [[ ${CHECK_AWS} == "200" ]]; then
AWS_REGION=$(grep -E "AWS_DEFAULT_REGION=.*$" "${OPENVIDU_PREVIOUS_FOLDER}/.env" | cut -d'=' -f2) AWS_REGION=$(grep -E "AWS_DEFAULT_REGION=.*$" "${OPENVIDU_PREVIOUS_FOLDER}/.env" | cut -d'=' -f2)
[[ -z ${AWS_REGION} ]] && fatal_error "Error while getting AWS_REGION" if [[ ! -z ${AWS_REGION} ]]; then
NEW_AMI_ID=$(curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/CF-OpenVidu-Pro-${OPENVIDU_VERSION//v}.yaml --silent | NEW_AMI_ID=$(curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/CF-OpenVidu-Pro-${OPENVIDU_VERSION//v}.yaml --silent |
sed -n -e '/KMSAMIMAP:/,/Metadata:/ p' | sed -n -e '/KMSAMIMAP:/,/Metadata:/ p' |
grep -A 1 ${AWS_REGION} | grep AMI | tr -d " " | cut -d":" -f2) grep -A 1 ${AWS_REGION} | grep AMI | tr -d " " | cut -d":" -f2)
@ -326,6 +324,7 @@ upgrade_ov() {
sed -i "s/.*AWS_IMAGE_ID=.*/AWS_IMAGE_ID=${NEW_AMI_ID}/" "${OPENVIDU_PREVIOUS_FOLDER}/.env" || fatal_error "Error while updating new AWS_IMAGE_ID for Media Nodes" sed -i "s/.*AWS_IMAGE_ID=.*/AWS_IMAGE_ID=${NEW_AMI_ID}/" "${OPENVIDU_PREVIOUS_FOLDER}/.env" || fatal_error "Error while updating new AWS_IMAGE_ID for Media Nodes"
fi fi
# Ready to use # Ready to use
printf '\n' printf '\n'
printf '\n' printf '\n'