Skip to content

Commit dbb6816

Browse files
Merge pull request #219 from IBM/limit-setup-to-valid-regions
add the limit to run the script only on valid regions
2 parents b198190 + 6c2a705 commit dbb6816

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

experimental/serverless-fleets/init-fleet-sandbox

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22

3+
#### Global vars
4+
# vsi_images hashmap contains the list of valid vsi-images that can be used within fleets
5+
# The fleet sandbox can be setup on regions with a valid vsi-image, only.
6+
declare -A vsi_images
7+
vsi_images["eu-de"]=r010-e7b25759-7857-455a-aec0-904b65c3c4cb
8+
vsi_images["eu-gb"]=r018-31655c46-96e7-4d38-b61a-2ab1b66b9bbd
9+
vsi_images["us-east"]=r014-b7f47448-72db-4012-b018-bb120518b078
10+
311
# Env vars
412
CLEANUP_ON_ERROR=${CLEANUP_ON_ERROR:=false}
513
CLEANUP_ON_SUCCESS=${CLEANUP_ON_SUCCESS:=false}
@@ -146,6 +154,14 @@ echo "Please note: This script will install various IBM Cloud resources within t
146154
print_msg "\nChecking prerequisites ..."
147155
check_prerequisites
148156

157+
# checking if a there is a valid vsi-image in the region available
158+
vsi_image_id=${vsi_images[${REGION}]}
159+
160+
if [[ $vsi_image_id == "" || $vsi_image_id == null ]]; then
161+
echo " Fleet sandbox setup is currently not supported in region ($region), exiting setup... "
162+
exit -1
163+
fi
164+
149165
# Ensure that latest versions of used IBM Cloud ClI is installed
150166
print_msg "\nPulling latest IBM Cloud CLI release ..."
151167
ibmcloud update --force
@@ -409,16 +425,15 @@ ibmcloud ce secret create --name fleet-registry-secret --format registry --serve
409425

410426
# using the common base VSI image "jwe-ubuntu24-gpu" enabled for GPU and including podman and s3fs
411427
print_msg "\nCreating a Code Engine configmap 'fleet-vpc-config' to access the new VPC ..."
412-
# retrieve the best fitting ubuntu vsi base image by selection from available image list
413-
vsi-image-id=$(ibmcloud is images --output JSON|jq -r 'first( .[]|select(.name | startswith("ibm-ubuntu-24")) ) | .id')
428+
414429
print_msg "\nSelected the ubuntu-24 vsi image for fleets with the image-id = $vsi-image-id"
415430
ibmcloud ce configmap create --name fleet-vpc-config \
416431
--from-literal NETWORK_ZONE="${REGION}-1" \
417432
--from-literal SSH_SECRET_NAME="fleet-ssh-secret" \
418433
--from-literal VPC_ID="$(ibmcloud is vpc ${vpc_name} --output json | jq -r '.id')" \
419434
--from-literal SUBNET_ID="$(ibmcloud is subnet ${vpc_name}-subnet --output json | jq -r '.id')" \
420435
--from-literal SECURITY_GROUP_ID="$(ibmcloud is security-group ${vpc_name}-group --output json | jq -r '.id')" \
421-
--from-literal VSI_IMAGE_ID="$vsi-image-id" \
436+
--from-literal VSI_IMAGE_ID="$vsi_image_id" \
422437
--from-literal VSI_PREFERRED_PROFILE="cx2-2x4"
423438

424439
# alternative to fetch the latest stock image:

0 commit comments

Comments
 (0)