Google Cloud SQL External IP not static? - google-cloud-sql

I've got a micro instance of a Postgresql database on Google Cloud SQL, but the external IP seems to change occasionally. I've seen no documentation that says this is going to happen. It's only inconvenient while developing, but I need to understand how to make sure it won't happen when I want to go live with a larger instance. Any info appreciated.

I'm inferring when you say "External IP" you are referring to the Public IP. The Public IP assigned to your instance will not change unless you disable the Public IP and enable it again. You can read the Documentation to know more, it says:
When you disable public IP for an instance, you release its IPv4
address. If you later reenable public IP for this instance, it will
get a different IPv4 address, and all applications that use the public
IP address to connect to this instance must be modified.
Have an eye on your instance and double check that you are not unintentionally disabling the public IP.

Related

Does google cloud SQL instance use static IP Address by default?

When I created an sql instance in google cloud sql, it gave me an IP address. Will that IP address ever change, if so how to make it static so that it never changes?
The Google CloudSQL docs indicate that the IP address will remain static until the instance is deleted:
When you enable public IP for your instance, it is configured with a public, static IPv4 address.
This is consistent for private IPs as well.

How to access REST APIs hosted locally on Alexa

I am developing a custom Alexa Skill and have a requirement where I want Alexa to access REST APIs that are hosted locally on http://localhost:8080? Any idea how to do this?
Thanks!
If you really want to do this, and I’m assuming you are hosting the skill on AWS Lambda, it would involve quite a bit of work.
Your local endpoints need to be accessible from outside of your network, which requires port forwarding in your router to your machine where the endpoints are hosted. This needs to be configured in your router.
An easier way is to deploy your project containing the API to something like Heroku, which can be done easily. They give you a domain and make the endpoints accessible to Lambda. This should be possible within their free tier.
Here' a link to a pretty good article about how IP addresses work.
Allowing a device sitting on your local network (eg. a laptop computer or Raspberry Pi connected to your wifi) to be accessed from outside your local network (eg. from a service running on AWS) will involve mapping 2 separate IP addresses:
The IP address assigned to your router (your public IP)
The private IP addresses assigned by your router to your devices (laptop, iPhone, RPi, etc).
You have a couple options for allowing your router's IP (#1) to be accessible from outside your local network:
a. Pay your internet provider to provide you with a static IP address
b. Use a dynamic DNS service such as DuckDNS or No-IP.
Once you have a fixed public IP that can be used to access your router, you will then need to map a port on your router (#1) to the device IP on your local network (#2). This is usually referred to as "port forwarding". Most routers will support configuring this. In effect, your tell your router "when you get a message to : pass it to my laptop :"
Your local private IP address will typically have an IP value like 192.168.0.23 (where the 23 can be anything from 1 to 254).
An outside IP will start with something other than 192. Refer to the first link above regarding IP ranges.
You can google "port forwarding" and "public IP" for more info on how IP addresses and port forwarding work, but hopefully this will help get you started. It may seem a bit complicated at first, but if I can understand it, then anyone can :-)

strange behaviour Pinging Public IP

I've tried this on 2 different networks:
Set router to respond to ping on internet port.
Lookup public IP on www.whatsmyip.com
Use PuTTy to ssh into another server and pinging the public IP from there.
In one network 1 this works, in network 2 it won't. So the question is. What can cause this behaviour?
The public IP address (the address that external sites see your requests coming from, i.e. what whatismyip will tell you) may not be one that the router is directly reachable on, for example if Carrier-Grade NAT is deployed.
ISPs may use CGNAT if they don't have enough IPv4 addresses, in order to share a single address between multiple clients.
One way to tell if this is happening would be to compare whatismyip.com to the address the router says it has on its WAN/internet interface. If they're different (and the router is connected straight to the ISP), it's probably CGNAT at play.

Google Cloud SQL "Idling IP Address"

I have been looking at the console’s billing as far as Cloud SQL and the VM Instance is concerned. I see that a lot of the cost comes from the idling hours of the Cloud SQL IP address. I am unsure as to where the settings are for this as i have tried to “unassign” the ip address that is associated with my Cloud SQL Instance. Are these charges static, as in am I always, no matter what, going to be charged for the ip address constantly or is there a way to turn this off when I am not using the Cloud SQL Instance? If so, how can I?
You will be charged $0.01 for every hour the instance is not active and has an IPv4 address assigned.
You can un-assign IP address using the Google Developers Console, go to your Cloud SQL instance, click on Edit and uncheck 'Assign an IPv4 address to my Cloud SQL instance' box.
Click your SQL instance to go to Instance details > Connections > Public IP - uncheck it.
https://cloud.google.com/sql/docs/mysql/configure-ip
Note: When you disable public IP for an instance, you release its IPv4
address. If you later reenable public IP for this instance, it will
get a different IPv4 address, and all applications that use the public
IP address to connect to this instance must be modified.
Basically if you remove the public connection to your instance the IP is released too.
A lot of answers, most of them partial (or old?), it seems. On top, Google's settings aren't very transparent either. I checked in early 2020 and it doesn't seem possible to switch off the IP address or avoid the charges on a stopped instance.
In more detail:
I was billed €6.55 for 600 hours of SKU IP address idling in seconds for DB
The Cloud SQL instance in question was turned off (most or all of) the month of December until right now
Both Private IP and Public IP were deselected under [Google Cloud Project] > SQL > Connections
I then started the instance; no IP selected still. I let it run for some minutes and stopped it.
In the instances overview (only visible when switching from some other section like Logging back to [Google Cloud Project] > SQL), there was an IP listed under Public IP Address now
In [Google Cloud Project] > SQL > Connections, Public IP was selected (I didn't select anything there!)
Starting the instance now doesn't let me deselect both IP address options at the same time anymore like I had it before.
I do have a number of Authorized Networks configured under option Public IP and used these in some earlier months. I cannot test whether removing all if these will let me disable the option right now, as I need them again real soon. So, that's an open question.
In summary, besides a glitch in the system where no IP address option is selected, yet one is set up anyways, the charge seems to be unavoidable for a non-running instance. It's not possible to switch the IP off as #Tony Tseng suggested.
Why is that again, Google?
https://cloud.google.com/sql/docs/mysql/configure-ip
Click the instance name to open its Instance details page.
Select the Connections tab.
Deselect the Public IP checkbox.
Click Save to update the instance.==> Save is disabled on unchecking Public IP checkbox. Looks like either Private IP or Public IP checkbox should be selected to enable Save button.

How to make a Google Cloud SQL Instance accessible for any IP address?

I have just created a Google Cloud SQL instance. When I was looking on the access control of my instance, I found that if I want to access my database, I should authorize my IP address to get the right to access the database, but the problem is that my application will be deployed anywhere where the clients need, and even if I know where they will run the application and also I authorized their IP address, it (the IP) will be changed at least one time every 24 hours because it is not static IP, and then I have to re-authorize the IP again and again!
Is there any way to make the instance accessible from any IP?
Thanks
You can whitelist any subnet. You just need to enter it using CIDR notation: http://en.wikipedia.org/wiki/Cidr
In particular, you can whitelist 0.0.0.0/0 which includes all possible IP Address.
Please note that this is not recommended for security reasons. You want your access to be as restricted as possible.
This is an older post, but I noticed it on the sidebar so I figured I would add my 2c.
If you're able to use Cloud SQL Second Gen (currently in Beta) there is a new feature which allows access to the database without having to whitelist any firewalls: https://cloud.google.com/sql/docs/sql-proxy
Today, I was looking for a way to set-up an MS-SQL server for development purpose and found the similiar problem (how to allow my laptop to access).
This guide, helps.
In short, you need to allow firewall to enable EXTERNAL access to your VM instance at port 1433.