-->

DEVOPSZONES

  • Recent blogs

    How to fetch Database Flags from CLOUD SQL instance in GCP?

     If you want to create an replica from main PostgreSQL CloudSQL Instance and then want to apply the database flags from Primary Instance to replica. If yes, This post is for you.

    1. Install yq(It is an utility to parse yaml data

    #brew install yq

    2. Get Database Flags

    CLOUDSQL_DB_FLAGS=`gcloud sql instances describe $DATABASE_ID --project $PROJECT_ID | yq ea '.settings.databaseFlags | map(.name + "=" + .value) | join(",")'`
    echo $CLOUDSQL_DB_FLAGS

    3. Applying Flags

    During Creation of Instance

    gcloud sql instances create $INSTANCE_NAME --master-instance-name=$MASTER_INSTANCE_NAME --project $PROJECT_NAME --region=$REGION --availability-type=regional --no-assign-ip --network=$NETWORK --database-flags $CLOUDSQL_DB_FLAGS
    

    After Creation of an Instance

    gcloud sql instances patch $INSTANCE_NAME --database-flags $CLOUDSQL_DB_FLAGS --project $PROJECT_NAME


    No comments