How to Efficiently Add IP Addresses to Your GCP SQL Instance for AppSheet Integration
Hello Insiders,
For those of you integrating Google Cloud SQL instances with your AppSheet applications, managing IP address whitelisting can sometimes become cumbersome, especially when dealing with multiple addresses.
- If you’re like me, you find the GCP console interface slow for adding each IP address individually.
Here’s a streamlined method using the Cloud Shell and gcloud
command-line tool to batch update your authorized networks list.
Steps to Follow
To use this method of updating the IP address list for your instance, follow these steps:
1. Open your Google Cloud Console and start the Cloud Shell.
2. Update the code with your IDs for your instance and project
(all regions) IPs
# Set your instance and project specifics
INSTANCE_ID="YOUR_INSTANCE_ID_HERE"
PROJECT_ID="YOUR_PROJECT_ID_HERE"
# Define your comma-separated list of IPs with CIDR notation
AUTHORIZED_IPS="34.30.208.22/32,34.48.143.3/32,34.31.98.215/32,34.71.7.214/32,34.82.138.241/32,34.83.133.82/32,34.83.174.97/32,34.83.247.7/32,34.86.96.199/32,34.86.235.230/32,34.87.102.230/32,34.87.103.64/32,34.87.131.237/32,34.87.159.166/32,34.87.233.115/32,34.90.174.231/32,34.90.249.137/32,34.91.84.88/32,34.91.142.99/32,34.91.161.74/32,34.91.186.92/32,34.116.117.132/32,34.123.81.112/32,34.135.161.164/32,34.141.153.125/32,34.141.206.242/32,34.145.159.146/32,34.170.144.166/32,35.185.223.113/32,35.189.26.70/32,35.194.89.186/32,35.197.185.203/32,35.199.162.121/32,35.203.182.241/32,35.203.191.15/32,35.204.85.7/32,35.204.102.20/32,35.204.159.159/32,35.204.213.55/32,35.221.38.52/32,35.221.44.98/32,35.222.253.144/32,35.230.32.44/32,35.232.30.149/32,35.232.144.158/32,35.233.206.57/32,35.239.112.17/32,35.239.203.99/32,35.240.241.182/32,35.240.247.148/32,35.244.107.184/32,35.244.126.141/32,35.245.45.144/32,35.245.185.255/32,35.245.209.204/32,35.245.210.44/32,35.245.229.252/32,35.247.40.210/32,35.247.56.116/32,35.247.115.29/32,104.154.218.192/32,104.199.122.182/32,34.48.143.3/32,34.83.174.97/32,34.91.84.88/32,34.141.153.125/32,34.170.144.166/32,35.221.44.98/32,35.185.223.113/32,35.232.144.158/32"
# Update the instance with the new authorized networks
gcloud sql instances patch $INSTANCE_ID \
--project=$PROJECT_ID \
--quiet \
--authorized-networks=$AUTHORIZED_IPS \
(EU region) IPs
# Set your instance and project specifics
INSTANCE_ID="YOUR_INSTANCE_ID_HERE"
PROJECT_ID="YOUR_PROJECT_ID_HERE"
# Define your comma-separated list of IPs with CIDR notation
AUTHORIZED_IPS="34.34.98.59/32,34.90.234.200/32,34.91.95.77/32,34.91.131.47/32,34.91.113.123/32,34.91.205.83/32,35.204.29.52/32,35.204.48.89/32,35.204.197.150/32,35.204.224.165/32,34.34.98.59/32,35.204.197.150/32"
# Update the instance with the new authorized networks
gcloud sql instances patch $INSTANCE_ID \
--project=$PROJECT_ID \
--quiet \
--authorized-networks=$AUTHORIZED_IPS \
3. Run the code by pasting it into the terminal, and hitting enter.
NOTE: use
ctrl + shift + v
to paste the contents into the terminal.
- This is a special paste that pastes your clipboard contents as raw text, which prevents any line breaks from having any sort of special effect.
Important Notice For First Try
- The first time you run the command above, you might encounter an error if the Cloud SQL Admin API is not enabled.
- The error message will provide a link to enable the API directly.
- Click the link, enable the API, wait a minute or two, then run the command again.