Requirements
- Cloud SQL for PostgreSQL version 10 or above.
- Connect to the primary instance. Logical replication only works on the primary.
- Tables with a
PRIMARY KEY.
Enable logical replication
Open the Cloud SQL instance
In the Google Cloud Console, select the project that contains your Cloud SQL instance.
Add the cloudsql.logical_decoding flag
Edit the instance, open the Flags section, add 

cloudsql.logical_decoding and set it to ON, then save your changes.

Grant the replication role
After creating the sync user (see the common setup), grant the replication attribute:Next: common setup
Continue with the canonical PostgreSQL setup for the remaining steps — sync user privileges (USAGE, SELECT, REFERENCES), heartbeat table, publication, and replication slot:
