GithubHelp home page GithubHelp logo

mattes / gce-cloudsql-proxy-action Goto Github PK

View Code? Open in Web Editor NEW
32.0 6.0 43.0 9 KB

Github action which will start a Google Cloud SQL Proxy as Docker container.

License: The Unlicense

Shell 100.00%
google google-cloud google-cloud-sql google-cloud-sql-proxy docker cloudsql cloudsql-proxy github-action

gce-cloudsql-proxy-action's Introduction

Google Cloud SQL Proxy

Github action which will start a Google Cloud SQL Proxy as Docker container.

Prerequisites

Set up the following resources manually in the Cloud Console or use a tool like Terraform.

  • Running Cloud SQL instance with a public IP address
  • Create Service Account with Role Cloud SQL Client and export a new JSON key.

Github Action Inputs

Variable Description
creds Required Service Account JSON Key (not base64 encoded)
instance Required Cloud SQL connection name
port Listen on port, default 5432
proxy_version Cloud SQL Proxy version, default 1.21.0

Example Usage

uses: mattes/gce-cloudsql-proxy-action@v1
with:
  creds: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
  instance: my-project:us-central1:instance-1

gce-cloudsql-proxy-action's People

Contributors

mattes avatar taiki-okano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gce-cloudsql-proxy-action's Issues

Connect to multiple dbs?

I just tried connecting to multiple dbs but I am getting an error saying
docker: Error response from daemon: Conflict. The container name "/gce-cloudsql-proxy" is already in use by container "fa8e929a09fe5d01a6b80a73a35898e9a2c7a928447dcce915db3328551fed80". You have to remove (or rename) that container to be able to reuse that name. Could you let me know how to connect to multiple db's at the same time? Thank you so much for this wonderful project.

How to connect with unix sockets?

Hi-

When I use GCP cloud_sql_proxy, I connect to it like this using SQLalchemy:

  CLOUD_SQL_SOCKET_DIR = "/tmp/cloudsql"
  CLOUD_SQL_CONNECTION_NAME = some-gcp-project:us-central1:my-db
   DB_QUERY = {"unix_socket": "{}/{}".format(CLOUD_SQL_SOCKET_DIR, CLOUD_SQL_CONNECTION_NAME)}

    app.config['SQLALCHEMY_DATABASE_URI'] = sqlalchemy.engine.url.URL(
        drivername="mysql+pymysql",
        username=DB_USER,
        password=DB_USER,
        database=DB_NAME,
        query=DB_QUERY,
    )

but this action uses '/tmp' as it's directory

I guess this is more of a Github Action question, but in order to connect using the /tmp directory later in the job, what should CLOUD_SQL_SOCKET_DIR be?

Error when trying to connect

This is my action and it doesn't work. Getting:

Run psql "host=127.0.0.1 port=5432 sslmode=disable dbname=testdb user=postgres"
psql: error: connection to server at "127.0.0.1", port 5432 failed: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
Error: Process completed with exit code 2.

What am I missing?

name: proxy-test

on:
  workflow_dispatch:

jobs:
  scheduled-job:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v2
        with:
          node-version: "16"

      - uses: mattes/gce-cloudsql-proxy-action@v1
        with:
          creds: ${{ secrets.GCP_CREDENTIALS }}
          instance: myproj-1234:europe-west1:instance_name

      - name: Install postgresql-client
        run: sudo apt-get install -y postgresql-client

      - run: psql "host=127.0.0.1 port=5432 sslmode=disable dbname=testdb user=postgres"

How to use this action properly?

Hi

I've got this action set up within my workflow, I've set the creds and instance, but when the action runs it seems to connect then drop the connection straight away

image

I've got a action which runs after this one where I want to drop a database, but as this fails it never gets to it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.