ETLMCPData Conveyance Works
Log in Start free
Guides

Connect etlmcp to AlloyDB for PostgreSQL: public IP, authorized networks and SSL

What to change on an AlloyDB instance so etlmcp can load it: inbound public IP, an authorized external network, SSL on and connector-only mTLS off.

An AlloyDB for PostgreSQL instance can only be reached from outside your VPC once you turn on public IP, and Google offers the AlloyDB Auth Proxy and the AlloyDB Language Connectors as ways in. etlmcp uses neither. Its PostgreSQL destination opens a plain PostgreSQL connection, over SSL, to the host you type. So before etlmcp can load AlloyDB, you have to give the primary instance an inbound public IP, put etlmcp's address on the instance's authorized external networks, keep SSL on, and leave the connector-only mTLS option off.

Turn on inbound public IP

AlloyDB offers two kinds of public IP. Inbound public IP gives the instance a public IPv4 address that outside clients can reach; outbound public IP gives the database static addresses for connections it starts itself, for example during a migration. etlmcp needs the inbound kind.

On an existing instance, open the cluster's Overview page in the Google Cloud console, choose Instance actions, then Edit, tick Enable Public IP, and click Update instance. On a new primary instance the same box sits under Connectivity in the create form.

AlloyDB will not assign a public IP unless the database flag password.enforce_complexity is on. The console turns the flag on for you when you tick the box. With the gcloud CLI you set it yourself: pass --database-flags=password.enforce_complexity=on when you create the instance, and --assign-inbound-public-ip=ASSIGN_IPV4 to request the address. With the flag on, the database user's password has to meet AlloyDB's complexity rules, so pick a strong one for the user etlmcp signs in as.

Authorize etlmcp's address

Public IP alone is not enough. Google's page explains that authorized external networks are what let a client reach the public address directly, and that they are not needed only when the client goes through the Auth Proxy or a Language Connector. etlmcp connects directly, so its address must be on the list.

The address to add is shown on etlmcp's destinations page. When the server has a published address, the note under your destinations ends with "Behind a firewall? Allow connections from" and the address. Enter it as a CIDR block of one address, such as 203.0.113.10/32. Do not press Use my IP: it fills in the address of the browser you are using, not etlmcp's.

Three rules on the list catch people out:

  • Public IP has to be on before you can add any network.
  • There is no way to add one entry on its own. Every update, in the console, gcloud (--authorized-external-networks) or the API, replaces the whole list, so include every range you want to keep.
  • Private ranges are not accepted. An organization administrator can also cap the number and size of entries with a custom organization policy, so if your entry is refused, ask them.

Use the public address as the host

On the PostgreSQL destination form, put the instance's public IP in Host and the instance's PostgreSQL port in Port. gcloud alloydb instances describe prints the assigned public IP along with the authorized networks. Do not enter the instance's private VPC address: before it connects, etlmcp resolves the host and refuses any address that is not public. The rest of the form takes the database, user, schema, table and password. For the grants the user needs, see PostgreSQL privileges.

Keep SSL on and connector mTLS off

AlloyDB requires SSL on every connection unless you clear Only allow SSL connections under Advanced configuration options. By default etlmcp connects with SSL mode require, which means the connection is encrypted or not made, so leave the box ticked.

The option in the same panel that does matter is Enforce mTLS via AlloyDB connectors. When it is on, AlloyDB accepts only connections made through the Auth Proxy or Google's connector libraries. etlmcp is neither, and its destination has no field for a client certificate, so with this option on every etlmcp run is refused. Leave it off on any instance etlmcp writes to. For what require does and does not check, see PostgreSQL SSL modes and etlmcp.

If you turn public IP off later

Disabling inbound public IP removes the address, and every inbound connection to it fails, etlmcp's included. The console and gcloud also empty the authorized networks list at the same time. If you turn public IP back on, add etlmcp's network again before the next scheduled run.

Test the destination

Save the destination and run its test. For a database, the test inserts one sample row and rolls it back, so it exercises the public IP, the authorized network, SSL, the password and the user's rights together. If it fails, check in that order. The form's fields are described on the PostgreSQL destination page, and the Cloud SQL version of this setup is in Connect etlmcp to Cloud SQL for PostgreSQL.

Related

Sources

  1. Connect using public IP — docs.cloud.google.com, checked