Overview:

We are going to use AlloyDB as our main database service which is Google’s fully managed PostgreSQL-compatible database. It is designed to be a cluster by default.

AlloyDB is in the beta version and has some limitations, it does not have APIs to control logical databases and users.

Implementation:

The implementation is straightforward, we are using the official Google Beta provider to deploy the cluster and its configuration.

The Terraform configuration is in the TF dispatcher’s applications-infra directory. Here we are creating the AlloyDB cluster and the primary DB instance for applications.

The most important thing is the shared VPC configuration which must include Private connections peering to Google’s API endpoint and export_custom_routes config.

Also, we need to add provide network view access to the service account which is going to apply the AlloyDB configuration in our case applications-infra TF SA should have network view access in the Shared VPC project.

To Do:

As we know already the AlloyDB is in beta and it does not have APIs for Postgres management.
Currently, the only option to have a database for every application is using a PSQL TF provider or client.

The AlloyDB has been tested using our Template Service:

  • Created a user and database for template service.

  • Built and run the service in a Docker container using the created database and AlloyDB endpoint.

  • Added various dummy migrations in the application, upgraded and downgraded the database using Flyway, and verified them in the database.

  • Tested the application API and Swagger UI.

But still more research and testing is encouraged mainly from:

  • applications perspective (test using real microservices)

  • TM (test ThoughtMachine integration)

  • kms / encryption

  • backup

  • HA

  • scaling

  • monitoring & logging

Useful Links:

Terraform Provider Documentation
Configure connectivity to AlloyDB