When trying to run the shell script “setup_psc.sh” to setup a private endpoint between mongodb atlas and GCP I get the following errors:
root@UserPC:/home/username# sh setup_psc.sh
Updated property [core/project].
ERROR: (gcloud.compute.addresses.create) Could not fetch resource:
- Invalid value for field 'resource.name': 'chosenName-ip-{0..49}'. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
ERROR: (gcloud.compute.addresses.describe) Could not fetch resource:
- Invalid value for field 'address': 'chosenName-ip-{0..49}'. Must be a match of regex '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}'
setup_psc.sh: 11: [: !=: unexpected operator
ERROR: (gcloud.compute.forwarding-rules.create) Could not fetch resource:
- Invalid value for field 'resource.name': 'chosenName-{0..49}'. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
WARNING: The following filter keys were not present in any resource : name, region
WARNING: The following filter keys were not present in any resource : name, region
For the record this is the script:
#!/bin/bash
gcloud config set project projectName
for i in {0..49}
do
gcloud compute addresses create endpointName-ip-$i --region=us-central1 --subnet=default
done
for i in {0..49}
do
if [ $(gcloud compute addresses describe endpointName-ip-$i --region=us-central1 --format="value(status)") != "RESERVED" ]; then
echo "endpointName-ip-$i is not RESERVED";
exit 1;
fi
done
for i in {0..49}
do
gcloud compute forwarding-rules create endpointName-$i --region=us-central1 --network=default --address=endpointName-ip-$i --target-service-attachment=projects/p-xuggng5phsozafushbhsgaiz/regions/us-central1/serviceAttachments/sa-us-central1-621c96dcfcf5d71f84355fd6-$i
done
if [ $(gcloud compute forwarding-rules list --regions=us-central1 --format="csv[no-heading](name)" --filter="name:endpointName" | wc -l) -gt 50 ]; then
echo "Project has too many forwarding rules that match prefix endpointName. Either delete the competing resources or choose another endpoint prefix."
exit 2;
fi
gcloud compute forwarding-rules list --regions=us-central1 --format="json(IPAddress,name)" --filter="name:endpointName" > atlasEndpoints-endpointName.json
I am running this on Windows Subsystem for Linux - Ubuntu