The Custom Endpoint Plugin adds support for RDS custom endpoints. When the Custom Endpoint Plugin is in use, the driver will analyse custom endpoint information to ensure instances used in connections are part of the custom endpoint being used. This includes connections used in failover and read-write splitting.
The plugin lives in its own module. Add it and import it for its side effects, so the plugin registers itself:
go get github.com/aws/aws-advanced-go-wrapper/custom-endpointimport (
_ "github.com/aws/aws-advanced-go-wrapper/custom-endpoint"
)Without that import the driver returns an unknown-plugin-code error when customEndpoint appears in plugins. The required AWS SDK modules are added as indirect dependencies.
Important
The credentials the wrapper resolves must be allowed to call rds:DescribeDBClusterEndpoints. This applies regardless of how your application authenticates to the database — the plugin always calls the RDS control plane, whether or not the IAM Authentication Plugin is enabled.
If the permission is missing, every connection attempt, every statement and every transaction commit to that endpoint fails after waitForCustomEndpointInfoTimeoutMs (default 5000 ms), for as long as the permission is absent. Recovery is automatic once the policy is attached, within 5 minutes, with no restart required.
Tx.Rollback, Conn.IsValid and Conn.ResetSession are deliberately not gated on endpoint information, so an application can always abort a transaction and the connection pool keeps working normally. None of the three selects a host, so gating them could not prevent a connection from reaching an instance outside the endpoint - it would only prevent a rollback from reaching the server and add the wait to every pool checkout and release.
Both of these are DSN or property changes, so neither needs a rebuild:
- Set
waitForCustomEndpointInfo=falseto stop connections and statements failing while endpoint information is unavailable. Filtering still applies whenever information is available, so you keep the feature; the cost is that connections may reach instances outside the custom endpoint during the window before the first successful fetch. - Remove
customEndpointfrompluginsto disable the feature entirely.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "rds:DescribeDBClusterEndpoints",
"Resource": "*"
}
]
}Verify with the same credentials your application uses:
aws rds describe-db-cluster-endpoints --db-cluster-endpoint-identifier <your-custom-endpoint-id>- If needed, create a custom endpoint using the AWS RDS Console:
- If needed, review the documentation about creating a custom endpoint.
- Add the plugin code
customEndpointto thepluginsvalue.pluginsreplaces the default plugin list rather than adding to it. Settingplugins=customEndpointalone therefore disablesfailoverandefm, and leaves nothing that consumes the filtered host list. Include the plugins you want, for exampleplugins=auroraConnectionTracker,customEndpoint,failover,efm.
- If you are using the failover plugin, set the failover parameter
failoverModeaccording to the custom endpoint type. For example, if the custom endpoint you are using is of typeREADER, you can setfailoverModetostrict-reader, or if it is of typeANY, you can setfailoverModetoreader-or-writer. - Specify parameters that are required or specific to your case.
| Parameter | Value | Required | Description | Default Value | Example Value |
|---|---|---|---|---|---|
customEndpointRegion |
String | No | The region of the cluster's custom endpoints. If not specified, the region will be parsed from the URL. | "" |
us-west-1 |
customEndpointInfoRefreshRateMs |
Integer | No | Controls how frequently custom endpoint monitors fetch custom endpoint info, in milliseconds. A non-positive value is replaced by the default. | 30000 |
20000 |
customEndpointInfoRefreshRateBackoffFactor |
Integer | No | Exponential backoff factor for the custom endpoint monitor. When the RDS API throttles the monitor, the interval between fetches is multiplied by this factor, and divided by it again after a successful call. A value below 1 is replaced by 1, which disables backoff. | 2 |
3 |
customEndpointInfoMaxRefreshRateMs |
Integer | No | Ceiling for the backed-off refresh interval, in milliseconds. A value below customEndpointInfoRefreshRateMs is raised to it, which disables backoff. |
300000 |
120000 |
customEndpointEnforceRoleFiltering |
Boolean | No | Controls whether a READER-type endpoint with an exclusion member list restricts host selection to readers. Defaults to false so upgrading does not change routing. This default is deprecated and becomes true in the next major version. |
false |
true |
customEndpointMonitorExpirationMs |
Integer | No | Controls how long a monitor should run without use before expiring and being removed, in milliseconds. | 900000 (15 minutes) |
600000 |
waitForCustomEndpointInfo |
Boolean | No | Controls whether to wait for custom endpoint info to become available before connecting or executing a method. Waiting is only necessary if a connection to a given custom endpoint has not been opened or used recently. Note that disabling this may result in occasional connections to instances outside of the custom endpoint. | true |
true |
waitForCustomEndpointInfoTimeoutMs |
Integer | No | Controls the maximum amount of time that the plugin will wait for custom endpoint info to be made available by the custom endpoint monitor, in milliseconds. | 5000 |
7000 |
While the plugin is enabled, the driver restricts the hosts it will choose for itself to the members of
the custom endpoint, as reported by rds:DescribeDBClusterEndpoints. This covers failover and
read/write splitting.
Note
initialConnection is not covered by default. By default it engages only for a cluster endpoint
(.cluster-). To enable it for a custom endpoint (.cluster-custom-), set verifyInitialConnectionType.
Note that verifyInitialConnectionType=writer picks the writer from the unfiltered topology, so it can land
on a writer the endpoint excludes; reader selects from the filtered list and stays inside the
endpoint. For more information, see Endpoint Compatibility.
The member list comes from the endpoint's own configuration, in one of two forms:
| Member list | Meaning |
|---|---|
| static | Only the listed instances are used, a writer included if it is listed. |
| exclusion | Every instance in the cluster is used except the listed ones. |
Two consequences:
- The member list comes from AWS-side data, not from your configuration, so changing the endpoint's
member list changes your driver's routing without a deploy, within one
customEndpointInfoRefreshRateMsinterval. - An exclusion list that names the writer leaves the driver with no writer to select. Reader failover,
and switching out of read-only mode with
awsctx.SetReadOnly, then have no valid target and return an error. If that is not what you want, do not exclude the writer.
A READER-type endpoint that uses an exclusion member list also implies a role: only readers should
serve it. Set customEndpointEnforceRoleFiltering=true to have the driver enforce that, which removes the
writer from failover and read/write splitting for that endpoint.
| Endpoint type | Member list | With enforcement on |
|---|---|---|
READER |
exclusion | Readers only. The writer is excluded from host selection. |
READER |
static | No role requirement; a listed writer stays eligible. |
WRITER |
either | No role requirement. |
ANY |
either | No role requirement. |
A static member list routes to all of its listed members, a writer included, which is why it carries no
role requirement even when the endpoint's type is READER. The requirement holds even when the exclusion
list is empty.
Important
The default is false, so nothing changes when you upgrade. That default is deprecated and becomes
true in the next major version. Enable it now if you want reader-only routing, and be aware that
excluding the writer leaves reader failover and switching out of read-only mode with no valid target.
The rds:DescribeDBClusterEndpoints permission described above is required whether or not you use IAM authentication. When you do use IAM authentication, make sure the same credentials also carry the rds-db:connect permission your cluster requires.