CreateBlueGreenDeployment stages a green copy of a PostgreSQL, MySQL or
MariaDB instance with the target engine version, parameter group, class
and storage, linked to the blue instance as a read replica and loaded
from a dump of it. SwitchoverBlueGreenDeployment gives green the blue
identifier, ARN, endpoint and tags and renames blue to <name>-old<n>;
the container manager moves each running container to its new ARN so
stop and delete still find it. DescribeBlueGreenDeployments supports the
four documented filters and paging, and reports INVALID_CONFIGURATION
when a member is gone. DeleteBlueGreenDeployment honours DeleteTarget
before switchover. Deployments are taggable by their deployment ARN.
Closes#8069
Closesfloci-io/floci#8007
Persist whether a standalone instance has never initialized its database. Protect engine versions before backend startup so runtime loss and proxy failures cannot expose existing storage to a metadata-only version change. Update SDK compatibility assertions to reject unsupported upgrades and verify resizing separately.
Apply supported minor upgrades using the version-specific image on the existing volume and endpoint. Keep major upgrades, downgrades, and pinned-image changes blocked before mutation. Preserve the never-started case, report failed restarts honestly, and restore successful minor-upgrade coverage in the Java SDK compatibility suite.
* feat(rds): CreateDBSnapshot and RestoreDBInstanceFromDBSnapshot for MySQL and MariaDB
A snapshot of a MySQL or MariaDB instance is a mysqldump (mariadb-dump) of
every user schema, with routines, triggers and events, taken as the master
user, followed by every non-system account recreated from SHOW CREATE USER
and SHOW GRANTS. Restoring replays it into the new instance once its server
accepts the master user over TCP, so the copy is never loaded into the
image's initializing server. SQL Server is still refused.
* fix(rds): copy roles and names with spaces in MySQL and MariaDB snapshots
Roles are now part of a MySQL or MariaDB snapshot: MariaDB roles are
recreated with CREATE ROLE, and MySQL accounts used as roles are created
first, since SHOW CREATE USER names an account's default roles. Every role
and account exists before any grant is replayed, so a user granted a role
restores. Schema and account names are read one per line, so names with
spaces stay one argument. The integration test retries through one
Awaitility helper and covers a role and a schema name with a space.
* fix(rds): wait for the server before a MySQL dump, and share the snapshot script runner
CreateDBSnapshot straight after CreateDBInstance failed: Floci reports the
instance available while the image still initializes it on a server that
does not listen on TCP. The dump script now exits 2 until the master user
can log in over TCP and is run again, as the restore is; past that probe
any failure, mysqldump's own exit 2 included, exits 1 so it is not retried.
The PostgreSQL restore, the MySQL dump and the MySQL restore now share one
runner for the upload, the exit-2 retry and the error handling.
* fix(rds): rotate cluster managed credentials and secret versions together
* test(rds): load the PostgreSQL driver before the first DriverManager call
DriverManager only offers drivers the caller's class loader can see. After a
Quarkus restart, the first getConnection in
RdsPostgresStartupParametersIntegrationTest found none ("No suitable driver
found"), which has been failing CI shard 1 on main. Load PgJDBC through the
test's own loader first, as RdsBackendEndpointRefreshIntegrationTest already
does, and do the same in the new managed-password rotation Docker test.
---------
Co-authored-by: Priamo Germosen <priamo.germosen@starling.co>
* feat(rds): automated backups, kept after a delete and restored from
DescribeDBInstanceAutomatedBackups, DeleteDBInstanceAutomatedBackup,
DescribeDBClusterAutomatedBackups, DeleteDBClusterAutomatedBackup,
StartDBInstanceAutomatedBackupsReplication and
StopDBInstanceAutomatedBackupsReplication answered UnsupportedOperation, and
DeleteDBInstance and DeleteDBCluster ignored DeleteAutomatedBackups, so a
deleted database could not be restored to a point in time.
A live standalone instance with backups on now reports an active automated
backup. A delete with DeleteAutomatedBackups=false keeps a retained one, with
the PostgreSQL data saved outside mock mode, and RestoreDBInstanceToPointInTime
(by DbiResourceId or backups ARN) and RestoreDBClusterToPointInTime (by
DbClusterResourceId) restore from it. Replication to another Region is
metadata only: the replica is listed as replicating, the source lists it under
DBInstanceAutomatedBackupsReplications, and a stop or the source's delete keeps
it as retained.
Closes#6828
* fix(rds): restart stopped replication, use the replica's window, match the source ARN
A stopped replica kept as retained refused a second start of replication to
its Region; only a replica that is still replicating refuses it now, and a
retained one is replaced. A restore from a replicating backup checked the
time against the live source's window; it checks the replica's own window
now and still copies the live source. A replication source ARN naming
another account or service found this account's instance by identifier; the
whole ARN must now match the instance's.
The RDS count in the docs service matrix is 117, for the six new actions.
* fix(rds): report the RDS hosted zone id on clusters and instances
DescribeDBClusters omitted HostedZoneId and DB instance endpoints omitted
Endpoint.HostedZoneId, so Terraform's aws_rds_cluster.hosted_zone_id was
empty and Route 53 alias records pointing at RDS endpoints failed.
Add a per-region rdsHostedZoneId fact to region-facts.json through the
generator, with the us-east-1 value from the AWS CLI RDS documentation,
and read it through AwsRegionFacts.rdsHostedZoneId. Regions without a
captured value fall back to the us-east-1 zone; Floci's Route 53 resolves
alias targets by DNS name, so the fallback does not affect resolution.
The value is looked up when the response is built, so existing clusters
and instances report it too.
Closes#6778
* fix(rds): read the RDS hosted zone from the CLI example and keep the fallback in RDS
AwsRegionFacts.rdsHostedZoneId now returns an Optional like every other
accessor there, and RdsQueryHandler owns the fallback zone for regions with
no captured value, the way API Gateway keeps its own placeholder. A missing
us-east-1 entry can no longer break a describe call.
The generator reads the us-east-1 zone from a snapshot of the AWS CLI
describe-db-instances example under aws-docs/partition-guides, as the
GovCloud API Gateway zones come from the GovCloud guide, instead of a
typed-in constant. The parse is required and fails on a missing,
wrong-region or ambiguous example. Adding another region is now a data
change.
* feat(rds): DescribeCertificates, ModifyCertificates and an instance's CA certificate
DescribeCertificates lists the Region's RDS certificate authorities with the
thumbprint and validity AWS reports, vendored from the certificate bundles AWS
publishes by tools/aws/regen_rds_ca_certificates.py, and pages them.
ModifyCertificates sets or removes the account's default for new instances.
CreateDBInstance, ModifyDBInstance, the two instance restores and
CreateDBInstanceReadReplica take CACertificateIdentifier, and instances report
it with CertificateDetails. AWS::RDS::DBInstance takes the property and
resolves the two CertificateDetails attributes. The identifier is metadata:
the auth proxy keeps presenting Floci's own CA.
Closes#5806
* fix(rds): follow the user guide on CAs and leave a blank CA alone
- An instance stored without a CA reports rds-ca-rsa2048-g1, since an
override applies only to instances created after it.
- ap-south-1, ap-southeast-4, ca-west-1, eu-central-2, eu-south-2 and
il-central-1 offer only rds-ca-rsa2048-g1, as the user guide says.
- A blank CACertificateIdentifier on modify leaves the instance's CA.
- --download skips a Region only on 403 or 404 and exits 1 on other
failures.
- Reuse regionFromArn, add a createDbInstance stub helper and import
Executable in the tests.
* fix(rds): run MySQL and MariaDB with their parameter group values
A DB cluster parameter group or DB parameter group was stored but never
reached the engine: the container started with only the authentication
option, so the database kept MySQL's built-in defaults.
Every container start (create, reboot, stop and start, emulator restart)
now passes the group's overrides as --loose-<name>=<value> server options:
the cluster parameter group for a cluster, the DB parameter group for a
standalone instance. The loose prefix makes the server skip an Aurora-only
parameter with a warning. Formula values and the parameters that decide
where the server listens and keeps its data are left out, and Floci's
authentication options come last so the proxy keeps working.
DescribeDBClusters now reports DBClusterParameterGroup.
Fixes#5946
* fix(rds): layer the Aurora writer's parameter group and switch groups on modify
Review follow-up:
- require_secure_transport and skip_grant_tables are no longer passed to
the server, like port and socket: Floci's proxy talks to MySQL without
TLS, and skip_grant_tables turns networking off, so either would lock
every client out.
- An Aurora cluster's engine now runs with its DB cluster parameter group
and the writer instance's DB parameter group on top, so an
instance-level value such as max_connections reaches the database.
Creating the writer restarts the cluster's container when its group
changes the engine's options; every later start reads the writer's
group too.
- ModifyDBCluster takes DBClusterParameterGroupName and ModifyDBInstance
takes DBParameterGroupName. The group is checked against the engine
before anything else in the request is applied, recorded at once, and
used from the database's next start (a reboot), as on AWS.
* fix(rds): apply Aurora groups on a writer reboot and report incompatible-parameters
Review follow-up:
- RebootDBInstance on an Aurora cluster's writer restarts the database the
cluster's members share, which is how AWS applies a changed DB cluster
parameter group or writer DB parameter group. A reader's reboot still
only restarts its endpoint.
- time_zone reaches the server as --default-time-zone, since MySQL has no
time_zone option, and Aurora's binlog_format=OFF, which turns binary
logging off and which MySQL refuses as a value, as --skip-log-bin.
- A server that stops while starting with its parameter group's options
leaves no container, and its instance, or every member of its cluster,
reports incompatible-parameters until a reboot starts it with values the
server accepts. Floci logs the server's error lines.
- DescribeDBClusters names a default DB cluster parameter group only when
DescribeDBClusterParameterGroups lists it.
- The integration test reboots the writer rather than the cluster, checks
that binary logging is off, covers a refused value, and skips through
RdsRequests.assumeDocker.
---------
Co-authored-by: Priamo <pgermosen@gmail.com>
* feat(rds): DB proxy endpoints
CreateDBProxyEndpoint, DescribeDBProxyEndpoints, ModifyDBProxyEndpoint and
DeleteDBProxyEndpoint store endpoints per account and Region, checked against the
service model. Each endpoint reports its proxy's own host, so a client connects
through it as through the proxy. DescribeDBProxyEndpoints lists each proxy's
default endpoint first; it cannot be modified or deleted. Deleting a proxy
deletes its endpoints, and endpoint ARNs take tags.
Closes#5805
* fix(rds): report each proxy endpoint at the proxy's current host
A custom endpoint kept the proxy's host from when it was created, so after a
restore gave the proxy a new host, every custom endpoint still reported the
old one while default reported the new one. The host is no longer stored with
the endpoint: create, describe, modify and delete take it from the proxy when
they answer.
A missing DBProxyName, DBProxyEndpointName or VpcSubnetIds is now
MissingParameter, checked before the proxy is looked up.
* test(rds): import Executable and assertTrue instead of naming them inline
* fix(rds): require database role grants for PostgreSQL IAM login
* fix(rds): preserve standard proxy IAM authentication
* fix(rds): report PAM refusal for IAM member passwords
* feat(rds): add StartExportTask, DescribeExportTasks and CancelExportTask with the export task lifecycle
* docs(rds): document the snapshot export task API
* fix(rds): route the export task actions to RDS when a request has no signing scope
* fix(rds): refuse an export to a bucket outside the snapshot's region
* fix(rds): answer export task calls with a copy of the task taken under the lock
* fix(rds): refuse an unknown DescribeExportTasks filter name before matching any task
* fix(rds): fail an export to a bucket in another region as a task, as RDS does, rather than refuse it
* docs(rds): say that a bucket in another region fails an export in mock mode too
* fix(rds): serve a CA-signed proxy TLS leaf certificate
* fix(rds): renew proxy TLS leaves before expiry
* fix(rds): sign proxy leaves with the shared Floci CA
Reuse the canonical CA and preserve legacy SAN metadata without loading or modifying the old RDS-only certificate and key. Keep leaf renewal and expiry rejection unchanged.
* fix(rds): preserve legacy CA certificate paths
Refresh rds-ca.crt from the shared Floci root and remove the unused RDS-only key. Replace the certificate path atomically so legacy links cannot overwrite shared key material, and leave failed initialization retryable.
* feat(rds): DescribeDBLogFiles and DownloadDBLogFilePortion
Both answered UnsupportedOperation, so an instance's log could only be
read with docker logs, outside the AWS API.
An instance's log is now read from its database container and cut into
files the way RDS names them: hourly error/postgresql.log.* files for
PostgreSQL, error/mysql-error.log for MySQL and MariaDB, and log/ERROR
for SQL Server. DescribeDBLogFiles filters and pages them, and
DownloadDBLogFilePortion follows the API reference's marker rules with
a 1 MB block cap. Control characters XML cannot carry come back as
U+FFFD. In mock RDS mode an instance has no log files.
Closes#5733
* fix(rds): bound and validate log file reads
A log read now takes the most recent 100,000 lines instead of the whole
history, fails when Docker does not finish in time instead of returning
part of the log, and, when Docker no longer knows the container, finds
or starts the backend once before answering DBInstanceNotReady rather
than an empty log. A single line over 1 MB is cut at 1 MB like the rest
of the block. Negative FileSize, FileLastWritten and Marker values are
InvalidParameterValue; the shared offset paging refuses a negative
marker instead of starting over.
* fix(rds): close the Docker log stream when a log read times out
A timed-out read now closes its callback before failing, so the stream
stops and nothing writes into the buffer after the read gives up; the
buffer is also written and read under one lock.
* refactor(rds): keep portion's Javadoc on portion
truncateUtf8 had landed between portion's comment and portion itself. It now follows portion.
* test(rds): read log files on the first call, and import class names
CreateDBInstance returns once the database accepts connections, so the startup log is already in the container's output. The Docker and SDK log tests now assert on the first DescribeDBLogFiles and DownloadDBLogFilePortion call instead of polling. The timeout test and RdsLogFilesTest import the classes they had written out in full.
* feat(rds): EnableHttpEndpoint, DisableHttpEndpoint and HttpEndpointEnabled
EnableHttpEndpoint and DisableHttpEndpoint answered UnsupportedOperation
and DBCluster carried no HttpEndpointEnabled, so Terraform's
enable_http_endpoint and CDK's enableDataApi never read back what they
set.
Clusters now record the flag and report it. The two actions take the
cluster's ARN and raise ResourceNotFoundFault and
InvalidResourceStateFault as the model lists them; CreateDBCluster,
ModifyDBCluster and the AWS::RDS::DBCluster EnableHttpEndpoint property
set it too. Turning it on is refused for engines other than Aurora
PostgreSQL and Aurora MySQL. The Data API itself does not check the
flag, so existing callers keep working.
Closes#5732
* refactor(rds): one cluster ARN parser, and stricter Data API inputs
clusterForResourceArn repeated the ARN parsing, cluster: prefix and
account and Region check of clusterIdentifierFromArnOrName; both now
call clusterIdFromArn, each raising the error its API documents.
The Data API engine check takes aurora-postgresql, aurora-mysql and the
older aurora name exactly instead of any name starting with aurora, and
the AWS::RDS::DBCluster EnableHttpEndpoint property accepts true or
false only, so a malformed value fails instead of turning the endpoint
off.
* fix(rds): take only aurora-mysql and aurora-postgresql for the Data API
The API reference lists those two engines, and new clusters cannot carry
the bare aurora name, so the check no longer accepts it.
* feat(rds): refuse role feature names the engine does not support
AddRoleToDBInstance, AddRoleToDBCluster and CreateDBCluster
AssociatedRoles stored any FeatureName, so Lambda on a MySQL instance
was accepted although MySQL supports no role features.
A FeatureName now has to be one the engine lists in
SupportedFeatureNames, matched without regard to case, or the call is
InvalidParameterValue; CreateDBCluster refuses before any cluster
exists. A cluster role with no feature, and an engine the catalogue
does not list, are left alone. Aurora PostgreSQL also lists Bedrock,
which the Aurora user guide offers next to Comprehend and SageMaker.
Closes#5631
* refactor(rds): keep the two-argument cluster role check
Callers that check an AssociatedRoles list without knowing the engine,
such as the CloudFormation provisioner in #5656, keep the signature they
compile against; it runs the same checks without the feature check.
* fix(rds): match feature names without regard to case in every role check
The supported-feature check matched without regard to case, but the
instance duplicate check and both removal lookups compared exactly, so
an instance could take s3Import and then s3import as two roles. All of
them now match the same way. The two-argument cluster role check, which
nothing here calls, is removed.
* fix(rds): inherit cluster IAM settings for new members
* fix(rds): keep new member authentication in step with cluster changes
* fix(rds): allow metadata reads during member creation
* fix(rds): keep member creation consistent with lifecycle changes
* fix(rds): preserve metadata access during instance reboot
* fix(rds): use one cluster state for member creation
* test(rds): check IAM authentication consistently
* feat(rds): IAM role associations for DB clusters and instances
AddRoleToDBCluster, RemoveRoleFromDBCluster, AddRoleToDBInstance and
RemoveRoleFromDBInstance answered UnsupportedOperation, and DBCluster
and DBInstance carried no AssociatedRoles, so Terraform's
aws_rds_cluster_role_association and aws_db_instance_role_association
could not apply.
Clusters and instances now keep their associated roles and report them
as AssociatedRoles, ACTIVE as soon as they are added. The four actions
raise the faults the API model lists, and CreateDBCluster accepts
AssociatedRoles, checked before the cluster is created. Feature names
are not yet validated against the engine.
Closes#5343
* fix(rds): route the instance role actions, and refuse only a repeated cluster role
AddRoleToDBInstance and RemoveRoleFromDBInstance were missing from
RDS_ACTIONS, so a request with no credential scope reached SQS.
DBClusterRoleAlreadyExists covers the role ARN only, so a cluster now
takes a second role for a feature that already has one. Instances keep
refusing a repeated role or feature, as their fault documents.
CreateDBCluster reads every AssociatedRoles index, gaps included, and
refuses an entry without a RoleArn. It associates the roles in one step
and deletes the new cluster if that is refused.
* refactor(rds): import the types parseAssociatedRoles uses
The regex and sorted-set types were written with their packages inline;
AGENTS.md asks for imports. The role association compat test gains a
DisplayName like the others in its class.
* docs(rds): count the role association actions alongside the catalogue reads
#5196 and this branch each added four RDS actions, so the service matrix
count is 98.
* feat(rds): engine versions, engine defaults and valid modifications
Serve DescribeDBEngineVersions, DescribeEngineDefaultParameters,
DescribeEngineDefaultClusterParameters and
DescribeValidDBInstanceModifications.
A curated engine catalogue lists one representative version per major
version Floci knows through its managed parameter and option groups.
Each version carries the parameter group family the create path computes
for it, its major version and its upgrade targets; each engine's default
is the version Floci creates when a request names none.
DescribeDBEngineVersions serves it with Engine, EngineVersion (exact or
major), DBParameterGroupFamily, DefaultOnly, the documented filters and
paging, and DescribeOrderableDBInstanceOptions now reads the same
catalogue.
The engine default calls check the family against the catalogue and
return an empty list, as Floci's default parameter groups hold no
parameters. DescribeValidDBInstanceModifications reports the instance's
storage type with a range from its current allocation to the engine's
maximum, and nothing for an Aurora instance.
Closes#5186
* feat(rds): one source for engine defaults, and engine version capabilities
Create paths, the cluster parameter group family check and global
clusters each kept their own default engine version, and Aurora MySQL's
disagreed with the catalogue: 8.0.36 against 8.0.mysql_aurora.3.05.2.
All four now read the catalogue's default, so a create that names no
version gets what DescribeDBEngineVersions reports with DefaultOnly.
DescribeDBEngineVersions and DescribeDBClusterEndpoints share one
offset paging helper and one MaxRecords check, which
DescribeEventSubscriptions also uses.
Each engine version now reports ExportableLogTypes,
SupportsLogExportsToCloudwatchLogs, SupportsReadReplica,
SupportedFeatureNames, SupportsParallelQuery, SupportsGlobalDatabases
and SupportsBabelfish, following what Floci supports.
* fix(rds): route the catalogue reads to RDS without a credential scope
DescribeDBEngineVersions, DescribeEngineDefaultParameters,
DescribeEngineDefaultClusterParameters and
DescribeValidDBInstanceModifications were missing from RDS_ACTIONS, so a
request with no credential scope reached SQS.
* fix(rds): load the token role's ALTER ROLE defaults into IAM sessions
* fix(rds): open IAM sessions with the role's defaults as startup options so RESET keeps them
* fix(rds): reject malformed restore flags
* fix(rds): disable IAM authentication by default on restore
* fix(rds): honor IAM settings on instance snapshot restore
* fix(rds): apply PostgreSQL startup parameters to IAM sessions as the token's role
* fix(rds): refuse a session_authorization change and match PostgreSQL's parsing for IAM startup parameters
* test(rds): share the IAM integration tests' setup and document RESET for IAM startup parameters
* fix(rds,elasticache): decode IAM auth token parameters once
SigV4RequestValidator, which verifies the IAM auth tokens the RDS, Redshift,
ElastiCache and MemoryDB proxies receive, URL-decoded every query parameter
as it looked it up, then decoded X-Amz-Credential and X-Amz-Security-Token a
second time. Session tokens are drawn from an alphabet that includes '+',
'/' and '='. A presigner writes '+' as %2B; the first decode restored it and
the second turned it into a space, so the session no longer matched and the
token was refused with "password authentication failed". Every token signed
with a Lambda function's execution-role credentials failed this way, from
the AWS CLI, botocore and the Go SDK's feature/rds/auth alike, while
AssumeRole credentials passed only because their tokens are alphanumeric.
The second decode also let a token carrying %252B stand in for a session
whose token holds a literal '+'.
SigV4 defines the canonical query string as each parameter name and value
URI-encoded (only A-Z a-z 0-9 - . _ ~ left as they are, uppercase hex, a
space as %20, '/' encoded), sorted by encoded name and then by value. The
validator now decodes each parameter exactly once, keeping a literal '+' as
a plus as the API Gateway and EKS verifiers already do, looks the session
up with that value, and rebuilds the canonical query string from the
decoded parameters rather than hashing the bytes on the wire, so the token
is checked against the string its signer hashed whichever valid
percent-encoding it travelled in. Using the raw pairs as before would have
fixed the session lookup alone, but would still reject a token whose
credential travels with literal slashes or lowercase hex.
The test token helper encoded values with URLEncoder, whose form encoding
writes a space as '+' and leaves '*' unescaped, which no SDK presigner does;
it now applies SigV4's UriEncode. S3 presigned URLs do not go through this
validator and read X-Amz-Security-Token once already: a URL presigned with
a Lambda session's credentials is served, and one whose token reads a space
for the '+' is refused.
* fix(rds): authorize the key the token's signature was verified with
The signature check reads a token's parameters with their names
percent-decoded, and takes the first X-Amz-Credential it finds. The
rds-db:connect check read the credential again from the raw query, matching
the name byte for byte. A token that spelled its signer's credential as
X-Amz%2DCredential and added a plain X-Amz-Credential of a key IAM does not
know was verified with the signer's key and authorized on the unknown one,
which IAM enforcement waves through: the connection was allowed whatever
the signer's policy said.
SigV4RequestValidator.queryParameter reads a parameter exactly as the
signature check does, and RdsSigV4Validator takes the credential scope from
there, so the key authorized is the key that signed.
validateAuthorizesTheKeyTheSignatureWasVerifiedWith signs such a token as
SigV4 signs a query and expects it refused; it was accepted before.
RdsIamAuthLambdaSessionIntegrationTest now creates its database inside the
try whose finally deletes it, so a create that fails an assertion leaves no
container behind.
* fix(rds): forward PostgreSQL startup parameters through the proxy
The RDS proxy parsed the client's StartupMessage but opened the backend
session with only user and database, so options, application_name and
every other run-time parameter were silently dropped.
Forward them in the order the client sent them. The proxy keeps setting
user and database itself, and drops _pq_. protocol extension requests,
which it does not negotiate with the backend.
An IAM login for a role other than the master still sends only user and
database: its backend session is the master's until the handover, and a
startup "-c role=<master>" would outlive SET SESSION AUTHORIZATION, so
RESET ROLE would regain the master. Redshift keeps today's behaviour, as
its drivers send parameters PostgreSQL rejects.
* fix(rds): relay PostgreSQL's refusal of the backend login to the client
Forwarding startup parameters makes new backend refusals possible, such as
replication=true with no pg_hba.conf entry allowing it. PostgreSQL answers
those with an ErrorResponse where the proxy expected an Authentication
message, and the proxy reported only "Backend database authentication
failed". Every read that expects an Authentication message now reads a
refusal whole and the proxy sends it to the client unchanged, so the client
sees PostgreSQL's SQLSTATE and reason. This covers a refusal before the
password exchange and one after it. Other unexpected replies keep the
generic error.
* test(rds): reuse the IAM auth harness and the handler's startup parser
Fold the IAM startup-parameter check into iamSessionRunsAsTheRoleNamedInTheToken, let backendStartupFor start its auth thread through startIamAuth, and make PostgresProtocolHandler.parseStartupParams package-private so the test no longer keeps its own copy.
Serve CreateDBClusterEndpoint, DescribeDBClusterEndpoints,
ModifyDBClusterEndpoint and DeleteDBClusterEndpoint.
A custom endpoint is stored per Region with the rules from the API
reference and the Aurora user guide: type READER or ANY, a static or an
exclusion member list but not both, members that are instances of the
cluster, no writer in a READER endpoint, an RDS identifier stored lower
case and unique in the Region, and at most five per cluster. Its ARN
(cluster-endpoint:<id>) works with the tagging actions.
DescribeDBClusterEndpoints lists each cluster's built-in WRITER and
READER endpoints with its custom ones, and supports the cluster and
endpoint identifiers, the four documented filters and paging. Deleting a
cluster deletes its custom endpoints, and a deleted instance drops out of
the member lists.
Custom endpoints are modelled, not routed: one reports the cluster's own
endpoint host, so connections through it go where the cluster endpoint
sends them.
Closes#5072
Serve RestoreDBInstanceToPointInTime and RestoreDBClusterToPointInTime,
and report the restorable window: LatestRestorableTime on
DescribeDBInstances, EarliestRestorableTime and LatestRestorableTime on
DescribeDBClusters.
Requests are checked as the API reference describes: exactly one of
RestoreTime (RestoreToTime) and UseLatestRestorableTime, a time inside
the window or InvalidRestoreFault, PointInTimeRestoreNotEnabled for an
instance with backups off, and exactly one source. An instance source is
named by identifier or DbiResourceId, a cluster source by identifier, ARN
or DbClusterResourceId; automated backups ARNs answer
DBInstanceAutomatedBackupNotFound since no automated backups are kept.
Floci keeps no transaction log, so the target is seeded from a
pg_dumpall of the source taken when the request arrives, as read
replicas are. The restored data is the source's latest state for any
time in the window, and LatestRestorableTime is the current time. Only
PostgreSQL sources are accepted, as for CreateDBSnapshot.
Closes#4952
* fix(rds): honor requested port when restoring a cluster snapshot
Reserve an explicit RestoreDBClusterFromSnapshot port for the cluster endpoint and proxy, validate its AWS range, and reject local port collisions. Keep automatic allocation when Port is omitted.
* fix(rds): keep requested ports within published proxy range
* fix(rds): reject occupied requested ports and preserve handler calls
* feat(rds): add and remove a subscription's source identifiers
SourceIds was write-once. CreateEventSubscription accepts the list and
ModifyEventSubscription has no SourceIds member, so
AddSourceIdentifierToSubscription and RemoveSourceIdentifierFromSubscription
are the only way to change it and neither existed.
Adding an id the subscription already carries is a no-op. The model declares
only SourceNotFoundFault and SubscriptionNotFoundFault for these operations,
so no fault fits a duplicate. Removing an id the subscription does not carry is
SourceNotFound, which is the fault that does fit.
* fix(rds): refuse a missing SubscriptionName as a parameter error
SubscriptionName and SourceIdentifier are both required by the model, and only
the identifier was checked. A missing name fell through to the subscription
lookup and came back as SubscriptionNotFound, telling the caller the
subscription does not exist when the request simply did not name one. The two
required members now fail the same way on both operations.
Also imports assertEquals in the new test rather than qualifying it inline.
* feat(rds): manage event notification subscriptions
CreateEventSubscription, DescribeEventSubscriptions, ModifyEventSubscription
and DeleteEventSubscription were all missing, so the subscription resource
could not be created.
Constraints come from the model. A SubscriptionName under 255 characters, a
required SnsTopicArn, SourceType limited to the documented valid values, and a
SourceIds list that may only be supplied alongside the SourceType its ids
belong to. An omitted Enabled activates the subscription, which the model
describes only in the negative: a subscription that is not activated is
created but not active. Modify applies only the members the request names.
Nothing is published to the topic. A subscription is stored and reported back
and no RDS event reaches SNS through it. The docs say so.
* fix(rds): synchronize the event subscription methods and cite the SourceIds constraint
createEventSubscription checked for a duplicate name and then stored, so two
concurrent creates of the same name both passed the check and the second
overwrote the first with neither caller seeing SubscriptionAlreadyExist. The
four methods are synchronized now, matching the 48 other public synchronized
methods in this file and the find-then-throw-then-store shape of
createDbSnapshot.
The comment on the SourceIds coupling said only that the model states it,
which sent a reviewer to the operation documentation where it is absent. It
now quotes the constraint and says it lives on
CreateEventSubscriptionMessage.SourceIds rather than on the operation.
* fix(rds): keep a rejected modify inert, carry subscription tags, and page the describe
Four findings from the automated review, all confirmed against the model.
ModifyEventSubscription wrote SnsTopicArn before validating SourceType, so a
request carrying a new topic and an unmodelled source type answered 400 with
the topic already changed. The store returns the live instance, so a later
describe reported it. This is the same shape as the Lambda code signing bug in
#4286 and I did not carry the lesson across.
CreateEventSubscriptionMessage has a Tags member that was dropped on the
floor, and resolveTagHandle had no arm for an es: ARN, so a subscription could
neither be created with tags nor tagged afterwards.
DescribeEventSubscriptionsMessage has MaxRecords and Marker, and its output
shape has Marker. None were read or emitted, so a bounded page returned
everything with no way to continue.
The new test used var, which AGENTS.md prohibits, the same thing flagged on
#4286.
* fix(rds): bound MaxRecords and resume paging past a deleted marker
Two defects I introduced in the pagination added last round.
MaxRecords was unbounded. Zero built an empty page and then read its last
element, throwing IndexOutOfBoundsException, and a negative value produced
invalid bounds. The model documents minimum 20, maximum 100, default 100, and
handleDescribeEvents a few hundred lines up already enforces that range. An
omitted value now defaults to 100 rather than returning everything.
The marker resumed by looking for its own name, so a subscription deleted
between calls left the offset at zero and handed back the first page again.
Resuming at the first name strictly greater than the marker is stable under
deletion.
The test used MaxRecords 1, a value the model rejects, so it exercised a page
size real RDS never serves. It now creates 21 subscriptions and pages with 20.
* fix(rds): validate MaxRecords before the named-subscription shortcut
The range check sat after the early return for a named subscription, so a
request naming one alongside an out-of-range MaxRecords succeeded. Request
validation should not depend on which branch serves the read.
An Aurora cluster whose ServerlessV2ScalingConfiguration has MinCapacity 0
now freezes its database container with docker pause once nothing has used
it for SecondsUntilAutoPause, and resumes it for the next client, as Aurora
Serverless v2 does.
Every client of a backend container holds a lease while it uses it: each
connection through the auth proxy (cluster, reader, instance and RDS Proxy
endpoints), each RDS Data API call and open transaction, and each command
Floci runs inside the container. A client that reaches a paused cluster is
held, not refused, until the container runs again, after
FLOCI_SERVICES_RDS_AURORA_RESUME_DELAY_MILLIS (default 0; Aurora takes
about 15000). A connection that arrives while the pause is under way
cancels it.
While paused, the cluster and its instances stay available,
DescribeEvents reports RDS-EVENT-0370 to 0374 for each instance, and
ServerlessDatabaseCapacity, ACUUtilization and CPUUtilization report 0
once a minute. A cluster with a provisioned instance, in a global database
or behind an RDS Proxy never pauses. A ModifyDBCluster that changes
MinCapacity or SecondsUntilAutoPause resumes a paused cluster. Stopping,
deleting or rebooting a cluster, shutting Floci down and resetting its
state thaw a paused container first.
FLOCI_SERVICES_RDS_AURORA_AUTO_PAUSE_ENABLED=false keeps every cluster
running.
Closes#4219
* fix(rds): apply DBInstanceClass, AllocatedStorage and EngineVersion on ModifyDBInstance
ModifyDBInstance parsed the password, IAM auth, subnet group, option group,
security groups and the backup and monitoring settings, but never read
DBInstanceClass, AllocatedStorage or EngineVersion. A resize or an engine
upgrade returned 200 while DescribeDBInstances kept reporting the values the
instance was created with, so a caller that diffs its configuration against a
read-back saw the same pending change on every run.
The three members move into a DbInstanceScalingChanges record that the handler
fills from the request and the service applies, with the rules the AWS API
reference states for them:
- AllocatedStorage below the current size fails with InvalidParameterCombination
- an increase under 10% is rounded up to 10% greater on PostgreSQL, MySQL and
MariaDB, and taken as given on SQL Server
- the same size is not a change and is left alone
- a different major EngineVersion needs AllowMajorVersionUpgrade
Floci applies the change immediately rather than deferring it to the preferred
maintenance window: it runs no maintenance window and models no
PendingModifiedValues, so a deferred change would never be applied at all.
* fix(rds): reject a ModifyDBInstance scaling change before applying any member
The scaling members were validated as they were assigned: the class was set,
then the storage was resolved, which can refuse a shrink, then the engine
version was checked, which can refuse a major upgrade. The instance a modify
works on is the stored object rather than a copy, so a request refused at the
second or third step had already written the earlier ones, and a read-back
reported a class the 400 said it never got.
The checks now run in resolveFor, ahead of every setter in modifyDbInstance,
including the password rotation that reaches the running container. applyTo is
left as pure assignment of an already-resolved record.
* fix(rds): bind PostgreSQL IAM tokens to the published endpoint
The PostgreSQL proxy validated IAM auth tokens with the two-argument
validator, so a token generated for any host, port or region was
accepted as long as the signature and DBUser matched. The MySQL proxy
already checked the token against the endpoint it publishes. Thread the
same binding into the PostgreSQL handler and validate against it.
* fix(rds): carry account and resource ids in the proxy binding
RdsService now builds the proxy binding itself at every relay start
(instances, clusters, RDS Proxy relays and restart restores) from the
published endpoint, port, region, account and DbiResourceId or
DbClusterResourceId, so the auth proxy has everything rds-db:connect
is scoped to. The convenience startProxy overload that re-derived the
region from the relay key is gone along with it.
* feat(rds): authorize rds-db:connect when IAM enforcement is on
After the token signature checks out, the auth proxy now asks IAM whether
the token's principal may perform rds-db:connect on
arn:aws:rds-db:<region>:<account>:dbuser:<resource-id>/<db-user>, the
same check AWS runs. It only applies when services.iam.enforcement-enabled
is on; a caller IAM does not know keeps the filter's bypass. The client
still sees the engine's generic authentication failure, and the denial is
logged in AWS's wording so the cause is visible server-side.
* refactor(rds): rename RdsMysqlBinding to RdsProxyBinding
Both engines, Aurora clusters and RDS Proxy relays now validate IAM
tokens against it, so the MySQL-specific name was misleading.
* docs(rds): describe IAM token endpoint binding and rds-db:connect
* test(rds): cover a replayed IAM token in the JDBC compat suite
* fix(rds): accept IAM tokens generated for the loopback name of the endpoint
Floci advertises the name containers reach it by (host.docker.internal
natively, its own address in Docker), while a client on the host connects
to the same proxy over the loopback interface and generates its token for
localhost or 127.0.0.1. Binding tokens strictly to the advertised host
therefore refused every native client; the published port still has to
match, so a token for another instance on the same host is still refused.
The compatibility workflow sets FLOCI_SERVICES_RDS_ENDPOINT_HOST=floci as
it already does for Redshift, so the tests' tokens name what the
containerised Floci publishes.
* feat(rds): make the PostgreSQL IAM token endpoint binding opt-in
Refusing a PostgreSQL token generated for another hostname, port or
region matches RDS but breaks clients whose tokens name a different
host than the endpoint publishes, so the check now sits behind
services.rds.iam-token-endpoint-binding
(FLOCI_SERVICES_RDS_IAM_TOKEN_ENDPOINT_BINDING), off by default.
MySQL and MariaDB keep requiring the endpoint as before, and the
rds-db:connect check still runs whenever IAM enforcement is on.
The compatibility workflow turns the flag on so the replayed-token
case stays covered.
* fix(rds): refuse an IAM token that reaches the validator without a binding
Every proxy publishes a binding, so a token without one has nothing to
be checked against; validating its signature alone was a fail-open
path. The signature-only validate(token, user) overload and the MySQL
handleAuth overloads that passed no binding are removed; production
only ever used the ones that pass it.
* fix(rds): sanitize the rds-db resource named in the refused connection warning
The database user is part of that resource and comes straight from the
client's startup message, so it is stripped of control characters like
the other client-controlled values in the warning.
* docs(rds): call a refused IAM token the engine's ordinary authentication failure
The exact message differs per engine, and RDS PostgreSQL words it
differently from Floci's handler today, so the docs no longer promise
one wording.
* docs(rds): move the IAM token binding row into the RDS variables table
The row had landed above the page heading, where it rendered as a
stray one-row table; it now follows FLOCI_SERVICES_RDS_ENDPOINT_HOST
as it does on the RDS page.
* fix(rds): bind PostgreSQL IAM tokens to the endpoint by default
A stock Floci still accepted a PostgreSQL token generated for another
endpoint, the replay this change set out to close, and PostgreSQL and
MySQL disagreed about it in a way RDS never has. The endpoint check is
now on for every engine. services.rds.iam-token-endpoint-binding
(FLOCI_SERVICES_RDS_IAM_TOKEN_ENDPOINT_BINDING=false) stays as the
escape hatch for clients that generate tokens for a container name or
DNS alias the endpoint does not publish. The compatibility workflow no
longer needs to turn the check on.
* chore(ci): rerun after a Docker Hub rate limit failed shard 1