Tag: google cloud

  • How to Recover Deleted Project in Google Cloud

    How to Recover Deleted Project in Google Cloud

    When you delete a Google Cloud Project (GCP), Google will shut down the project, and keep it for 30 days. If you need the project restored, you can do this within 30 days of deletion.

    To recover a project, go to Project Settings

    Google Cloud Project Settings

    On the left menu, click on the “Resource Manager” link.

    Google Cloud Resource Manager

    It will take you to the page

    https://console.cloud.google.com/cloud-resource-manager

    On this page, you will see all available projects. Below that you will see “Resources pending deletion”, click on it to see all the projects deleted in the last 30 days.

    GCP projects pending deletion

    To restore a project, click on the checkbox left side of the project name, then click on the “RESTORE” button on the top.

    Restore Deleted Project

    Once clicked, the project will be restored within a few minutes. You need to start Virtual Machines, for this, go to disks, click on the associated virtual machine, then click start. If you go directly to the Virtual Machine page, you won’t see your Virtual machines.

    Once the project is restored, you will need to set up billing.

    Back to Google Cloud

  • Google Cloud SQL

    To create a Google Cloud SQL database, run

    gcloud sql instances create INSTANCE_NAME_HERE --activation-policy=ALWAYS --tier=db-n1-standard-1
    

    INSTANCE_NAME_HERE = this can be anything, lowercase letters, 0-9, for identification purpose only.

    db-n1-standard-1 => this is size of the server, you can change it as needed.

    To create a Database, run

    gcloud sql databases create DB_NAME_HERE --instance INSTANCE_NAME_HERE
    

    To create a User, run

    gcloud sql users set-password root --host=%  --instance INSTANCE_NAME_HERE  --password=PASSWORD_HERE
    

    To list all google cloud SQL instances, run

    gcloud sql instances list
    

    Google Cloud SQL

    To list all databases in a Google Cloud SQL server, run

    gcloud sql  databases list --instance INSTANCE_NAME_HERE
    

    list databases in google cloud sql

    To connect to Google Cloud SQL database, run

    gcloud sql connect INSTANCE_NAME_HERE
    

    This will open firewall rule and add your IP so you can connect to Google Cloud SQL server.

  • Google Cloud apt signatures couldn’t be verified

    When i run apt update, i get error

    W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com cloud-sdk-jessie InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB

    W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com google-compute-engine-jessie-stable InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB

    W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com google-cloud-packages-archive-keyring-jessie InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB

    W: Failed to fetch http://packages.cloud.google.com/apt/dists/cloud-sdk-jessie/InRelease

    W: Failed to fetch http://packages.cloud.google.com/apt/dists/google-compute-engine-jessie-stable/InRelease

    W: Failed to fetch http://packages.cloud.google.com/apt/dists/google-cloud-packages-archive-keyring-jessie/InRelease

    W: Some index files failed to download. They have been ignored, or old ones used instead.

    To fix this, run

    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    

    apt gcloud

  • Install Google Cloud SDK

    To install Google Cloud SDK on Ubuntu/Debian, add repo

    export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
    echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list
    

    Add Key

    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    

    Install with

    apt-get update
    apt-get install google-cloud-sdk
    

    Before you can use gcloud command, you need to run

    gcloud init
    

    gsutil
    Google Cloud
    Google Cloud Storage

  • Enable Static External IP in Google Cloud

    Enable Static External IP in Google Cloud

    By default when you create a Compute Engine virtual machine in Google Cloud, you get public IP address. This IP address changes when you ever shutdown down your instance.

    To avoid IP getting changed, you need to reserve the IP address to do this, you need to change type of IP address from Ephemeral to Static.

    Go to

    Google Cloud Platform > Networking > VPC Network > External IP addresses

    You will see list of all IP associated with your instances here.

    Under Type column, set type to Static. You will be asked to enter a name and description. Once you do this, IP will not release even if you shutdown a VM.