An attempt to remove the address in a GCP instance failed - google-compute-engine

I was trying to create a new VM instance and instead of creating a Static External IP, i wrongly created a Static Internal IP. When i do
gcloud compute addresses list
I get my internal IP listed. Then i use:
gcloud compute addresses delete [address-name]
It asks for confirmation to delete. But once I type 'Y' as a confirmation, I get the following error stating that the resource itself is not found:
ERROR: (gcloud.compute.addresses.delete) Could not fetch resource: - The resource "[MY_RESOURCE_NAME]" was not found
I am confused. I hope I am not being charged for this.

If you want to delete a static internal IP address from a GCP Instances you could use the following documentaion and do it with the Cloud Console:
Go to the VM instances page.
Select your project.
Select the VM instance from the project list.
Select the Edit tool at the top of the page.
Click the edit tool for Network Interfaces.
Change the Internal IP type from Static to Ephemeral.
Select Release to release your static IP address.
Click Done to save your changes.
Your instance continues to use the static IP address until the
instance is deleted or restarted. After that occurs, the IP address is
returned to the subnet's default pool of available internal IP
addresses.

Related

Google Compute Engine How to bind new external IP address to the instance

I need to get new external IP address every time when I recreate my instance.
Current implementation may use previous ips.
How can I achieve the goal with static or ephemeral ips?
Or how can I get GCE ips pool?
I am adding bellow information with Kolban.
For the external IP Google cloud has two categories:
Static external IP addresses
Ephemeral external IP addresses
The basic difference between these two are Static one is long term assignment until hey are explicitly released from that assignment, and remain attached to a resource until they are explicitly detached. Where, Ephemeral remain attached to a VM instance only until the VM is stopped and restarted or the instance is terminated. If an instance is stopped, any ephemeral external IP addresses that are assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects.
As you are wishing for the new IP address for your instance, it seems Ephemeral external IP addresses is a better choice. But you can use the Static external IP addresses to create an IP pool anyway and rotate your reserved static external IP address, which has cost implications.
The external IP are configured in the accessConfigs. You can see accessConfigs if you describe your instance by below command in cloud shell.
$ gcloud compute instances describe [INSTANCE_NAME] --zone=[ZONE]
You can create a new VM and assign a static IP with the help of the Document and below command.
$ gcloud compute instances create [INSTANCE_NAME] --private-network-ip [IP_ADDRESS]
OR
You can change or assign an external IP in your existing VM following the steps of the document (GCLOUD), which are:
[Optional] Reserve a static external IP address (if you want to have the reserve external IP and this has cost implications).
Delete existing access configs.
Add the new external IP address.
When you create a Compute Engine instance and give it a public IP address you have two choices for that IP. It can either be ephemeral ... this means that the IP address is assigned (randomly) by Google and may change the next time the Compute Engine is restarted. The alternative is that it is static. These are IP addresses that Google fixes for you and are explicitly yours until you release them. There is no charge for a static IP address if it is actively being used (eg has a Compute Engine running that is using it). However if unused, you are charged 24 cents a day (1 cent an hour).
If, for some reason, you need a new IP address for a compute engine on demand, you can reserve a new static IP address and associate that with your compute engine.
See also:
Reserving a static external IP address

Google Cloud - Adding additional Internal IP to VM

I'm trying to build a webserver in Google Cloud Platform that hosts multiple websites (GBP, IE, FR, DK etc.)
Generally, we assign a range of IPs to the server statically, set the bindings in IIS, then loadbalance using a virtual IP.
It seems near enough impossible to assign another internal IP in GCP. Lots of guides about additional external IPs, but we don't want a public facing webserver like this.
Anybody have any idea on how to add additional internal IPs to a VM / Instance?
Also, I have tried changing the internal address I have assigned to the Instance to static in network adapter settings, next thing I know I can't access my VM for love nor money, had to delete and re-create. If I go into advanced settings to add additional static IPs, w'ere set to DHCP apparently, so can't add additional IPs.
Thanks all.
Answer that I recieved from GCE discussion group, in Google Groups:
"You can add additional internal IP addresses to a VM instance. This is possible by enabling IP forwarding for the VM, creating a static network route, adding appropriate firewall rules, and setting additional internal IP addresses to network adapter of Windows. These steps are described in this article for Linux machines (https://cloud.google.com/compute/docs/networking#set_a_static_target_ip_address). The same steps are valid for Windows VMs. You will need to keep the initial internal IP address, subnet mask, gateway address and DNS settings of the adapter and manually enter them in properties of IPv4 of the network adapter. The below is a screenshot of my configuration on a VM instance (Windows 2008 R2) that perfectly works."
Update:
Now, you can create instances with multiple network interfaces On Google Compute Engine and assign IPs. For more information, refer to this public documentation link. However, currently it has following limitations:
Alias IP ranges are not supported on any network interface on a VM
that has multiple network interfaces enabled.
You cannot modify or delete the network interfaces after the VM has
been created.

Gcloud, Relase external IP

So I'm currently really new to google cloud platform and I have an issue to be solved.
I've already created a compute engine in gcloud. When it was created, it automatically assigned an external IP. I'd prefer the instances to not have any external IP.
I saw that you could put --no-address argument when creating the instances so it wouldn't be assigned an external IP, but how to release the external IP when the instance has already created?
> gcloud compute addresses list
NAME REGION ADDRESS STATUS
webserver europe-west1 130.211.70.XXX IN_USE
gcloud compute addresses delete 130....
Or use use 'network' tab in the web interface if it's a one-off need.

Querying GCE instance properties from the VM itself

I want to be able to query the external IP address of a GCE instance when the instance starts up. I'm planning to use that to fix up some configs which are copied to multiple similar instances. Is there a way to automatically discover an instance's external IP(s) or other properties from the instance itself? I see there are some things you can query with the gcloud tool, but for that you have to know the instance name, and it's not clear where to get that from.
See Querying metadata in GCE public documentation. For example, for the instance's external IP:
curl http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip/ -H "Metadata-Flavor: Google"
This command will query the instance's private metadata server. Another option is configuring the instance's service account with the right scopes as described at Preparing an instance to use service accounts in the public documentation. This way, gcloud command can be used directly in the instance to get information from the project without authentication.

Google Cloud SQL Add Authorized Network

Trying to connect to my Google Cloud SQL Instance. I'm at the part where I have to add an authorized subnet. I keep trying to add a new subnet but whenever I do the page tells me it couldn't complete the operation. I'm putting my IP address in CIDR format like "192.168.103.202/24", but it just won't get accepted. And I can't connect to the SQL instance without this piece. Help? Is it a bug or am I doing something wrong???
if I try to connect to my google cloud sql instance without the subnet added I get the error:
I keep getting the error 'If Google Cloud SQL rejects the connection, for example, because the IP address your client is connecting from is not authorized, the error you receive will be'
which is expected as per the docs
reference:
https://developers.google.com/cloud-sql/docs/access_control
192.168.103.202 is your internal IP address, which is not publicly accessible, you need to enter your public IP address into the authorized network dialog.
The easiest way to get this is to enter "whats my ip" into Google and it will tell you "Your public IP address is x.x.x.x".