How to allow Google cloudsql only from selected IP address

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

To restrict access to a Google Cloud SQL instance so that it is only accessible from selected IP addresses, you can use the Cloud SQL instance’s authorized networks feature. This allows you to specify one or more IP address ranges that are allowed to connect to your database instance. Here’s how you can set this up:

Using Google Cloud Console:

  1. Navigate to the Cloud SQL Instances page:
    • Go to the Google Cloud Console.
    • Navigate to the “SQL” section to see a list of your Cloud SQL instances.
  2. Select the instance you want to configure:
    • Click on the instance name to go to its overview page.
  3. Access the Connections settings:
    • Find the “Connections” section in the left-hand menu.
    • Click on it to open the connections settings.
  4. Manage authorized networks:
    • In the “Public IP” section, you’ll find the “Authorized networks” setting.
    • Click on “Add network” to add a new IP address or range.
    • Enter a name for the network and the IP address or range in CIDR notation (e.g., 192.168.1.0/24 for a range or 192.168.1.1 for a single IP address).
    • Click “Done” to add the network to the list of authorized networks.
  5. Save your changes:
    • Make sure to click “Save” to apply the changes to your Cloud SQL instance.

Using gcloud Command Line:

If you prefer using the command line, you can update the authorized networks for your Cloud SQL instance using the gcloud command. Here’s how:

  1. Set the authorized networks for your instance:
    • Use the following command, replacing [INSTANCE_NAME] with your Cloud SQL instance name, and [IP_RANGE] with the IP address or range you wish to allow in CIDR notation.
    bash
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x