The ALTER EXTERNAL CONNECTION statement allows you to change the storage/sink URI that an external connection references.
You can use external connections to specify and interact with resources that are external to CockroachDB. When creating an external connection, you must define a name for the external connection while passing the provider URI and query parameters.
You can use ALTER EXTERNAL CONNECTION to update the connection string for an external connection to use a new authentication token. This allows you to rotate your auth token before the old token expires.
You can also use the following SQL statements to work with external connections:
CREATE EXTERNAL CONNECTIONSHOW EXTERNAL CONNECTIONSHOW CREATE EXTERNAL CONNECTIONDROP EXTERNAL CONNECTION
Required privileges
To update an external connection, a user must have the UPDATE privilege on that connection.
For example:
GRANT UPDATE ON EXTERNAL CONNECTION backup_bucket TO user;
Synopsis
Parameters
| Parameter | Description |
|---|---|
connection_name |
The name of the existing external connection. |
connection_uri |
The new storage/sink URI that the external connection will be updated to reference. |
Supported external storage and sinks
| Storage or sink | Operation support |
|---|---|
| Amazon MSK | Changefeeds |
| Amazon S3 | Backups, restores, imports, exports, changefeeds |
| Amazon S3 KMS | Encrypted backups |
| Azure Storage | Backups, restores, imports, exports, changefeeds |
| Confluent Cloud | Changefeeds |
| Confluent Schema Registry | Changefeeds |
| Google Cloud Pub/Sub | Changefeeds |
| Google Cloud Storage | Backups, restores, imports, exports, changefeeds |
| Google Cloud Storage KMS | Encrypted backups |
| HTTP(S) | Changefeeds |
| Kafka | Changefeeds |
| Nodelocal | Backups, restores, imports, exports, changefeeds |
| PostgreSQL connections | Physical cluster replication |
| Userfile | Backups, restores, imports, exports, changefeeds |
| Webhook | Changefeeds |
For more information on authentication and forming the URI that an external connection will represent, refer to the storage or sink pages linked in the table.
Examples
Update the URI of an external connection
In this example, you update the backup_bucket external connection to a new Amazon S3 URI to rotate your auth token.
ALTER EXTERNAL CONNECTION backup_bucket AS 's3://bucket name?AWS_ACCESS_KEY_ID={new access key}&AWS_SECRET_ACCESS_KEY={new secret access key}';