* feat(redshiftserverless): add snapshot and restore operations Adds CreateSnapshot, GetSnapshot (by name or ARN), ListSnapshots (filterable by namespace), DeleteSnapshot and RestoreFromSnapshot on top of the existing workgroup support. A snapshot is AVAILABLE as soon as it is created, so a snapshot created in a standby region stands in for a cross-region copy. RestoreFromSnapshot restores into an existing namespace and workgroup and never creates either. * docs(redshiftserverless): document snapshot and restore actions * docs(redshiftserverless): update service matrix operation count * fix(redshiftserverless): validate snapshot restore and ARN lookup Reject a RestoreFromSnapshot workgroup that belongs to another namespace, resolve snapshotArn only for this account and Region, and register the snapshot model for reflection so persisted snapshots survive a native restart. * fix(redshiftserverless): harden snapshot restore and add lifecycle tests Validate namespaceName and snapshot names, accept snapshotArn on RestoreFromSnapshot, read the snapshot once during restore, and cover the handler with an integration lifecycle test and a Java SDK compatibility test. * feat(redshiftserverless): dump and restore snapshot data and model retention, tags and filters CreateSnapshot dumps a running workgroup with pg_dump and RestoreFromSnapshot empties the public schema and replays the dump, reusing the provisioned Redshift container manager. Snapshots now report adminUsername, kmsKeyId and retention, accept tags (taggable by ARN), ListSnapshots filters by namespaceArn, ownerAccount and a time window, and RestoreFromSnapshot rejects snapshotName and snapshotArn together. * fix(redshiftserverless): make snapshot restore atomic and strict Dump the current contents before a restore and put them back when the replay fails, drop every user schema rather than only public, run psql with ON_ERROR_STOP so a failing statement fails the restore, and fail a restore whose recorded dump file is missing. * fix(redshiftserverless): keep the catalog bootstrap schema out of snapshot restore The reset dropped floci_internal and with it the pg_catalog svv_external_* views, so the strict replay failed. Leave that schema out of the reset and out of the dump. * fix(redshiftserverless): drop large objects when resetting before a restore * refactor(redshift): share container lookup and defaults in the container manager * docs(redshiftserverless): document the bootstrap schema left out of snapshots * style(redshiftserverless): order imports in the runtime test --------- Co-authored-by: yarammanasa2001-max <271440416+yarammanasa2001-max@users.noreply.github.com>
13 KiB
Redshift Serverless
Protocol: JSON 1.1
Endpoint: POST http://localhost:4566/ with X-Amz-Target: RedshiftServerless.<Operation> and Content-Type: application/x-amz-json-1.1
Floci emulates the namespace and workgroup lifecycle of Amazon Redshift Serverless: the account and Region scoped namespace that holds a serverless database, its admin credentials, and its IAM roles, and the workgroup that carries its compute settings and endpoint. This is the surface Terraform's aws_redshiftserverless_namespace and aws_redshiftserverless_workgroup drive, and the surface the AWS::RedshiftServerless::Namespace and AWS::RedshiftServerless::Workgroup CloudFormation types provision.
For the upstream API shape, see the Amazon Redshift Serverless API Reference.
Supported Actions
| Action | Description |
|---|---|
CreateNamespace |
Create a namespace, applying AWS defaults for dbName, kmsKeyId, and logExports |
GetNamespace |
Return a namespace by name |
ListNamespaces |
Page through the namespaces in the account and Region |
UpdateNamespace |
Apply the supplied fields to an existing namespace and return it |
DeleteNamespace |
Remove a namespace and return it with status DELETING |
CreateWorkgroup |
Create a workgroup in a namespace that has none, applying AWS defaults, starting its container and proxy, and returning its endpoint |
GetWorkgroup |
Return a workgroup by name |
ListWorkgroups |
Page through the workgroups in the account and Region |
UpdateWorkgroup |
Apply the supplied fields to an existing workgroup and return it |
DeleteWorkgroup |
Stop a workgroup's container and proxy, release its endpoint, and return it with status DELETING |
CreateSnapshot |
Create an AVAILABLE snapshot of a namespace, dumping the workgroup's database when it is running; a snapshot created in a standby Region stands in for a cross-Region copy |
GetSnapshot |
Return a snapshot by snapshotName or snapshotArn |
ListSnapshots |
Page through the snapshots in the Region, filtered by namespaceName, namespaceArn, ownerAccount and a startTime/endTime window |
DeleteSnapshot |
Remove a snapshot and return it |
RestoreFromSnapshot |
Restore into an existing namespace and workgroup, replaying the snapshot's dump into the workgroup's database; neither is created |
GetCredentials |
Mint a temporary database user and password for a workgroup, valid on its endpoint until expiration |
ListTagsForResource |
Return the tags on the namespace or workgroup named by resourceArn |
TagResource |
Merge tags into the namespace or workgroup named by resourceArn |
UntagResource |
Remove tags by key from the namespace or workgroup named by resourceArn |
Namespace and workgroup state is account and Region scoped and persisted through StorageFactory.
Compatibility Notes
- A workgroup runs a real PostgreSQL container.
CreateWorkgroupstarts the container (this needs Docker and usesfloci.services.redshift.image-version) and an authenticating proxy on theendpoint, whose port comes from the same pool as provisioned Redshift clusters (floci.services.redshift.proxy-base-porttoproxy-max-port). Connect with any PostgreSQL client or JDBC driver using the namespace admin user and password, to the namespacedbName. The Redshift Data API acceptsWorkgroupName(details). Only the operations in the Supported Actions table are served. The rest of the Redshift Serverless API is not emulated and answersUnknownOperationException: snapshot copy configurations, snapshot restore access policies, recovery points, table restore and restore status, usage limits, endpoint access, resource policies, custom domain associations, scheduled actions, reservations and reservation offerings, tracks, managed workgroups, the Identity Center token, and lakehouse configuration. - Admin credentials come from the namespace. The backend role is the namespace
adminUsername(defaultadmin) and the password is theadminUserPasswordthe namespace was created with. A namespace created without a password gets a generated one that is kept internally and never returned, so such a workgroup is reachable throughGetCredentialsand the Data API only.manageAdminPasswordstill creates no secret. ChangingadminUserPasswordwithUpdateNamespacetakes effect for new connections and is refused withValidationExceptionif the backend rejects it (AWS password rules: 8 to 64 characters with upper case, lower case and a digit, and none of' " / @). ChangingadminUsernameon a running workgroup does not rename the backend role; the new name is accepted at the proxy, which opens the backend as the original role. GetCredentialsreturns a master-equivalent password.dbUseris derived from the signing identity (IAM:<user>orIAMR:<role>, falling back toIAMR:flociwhen the caller cannot be resolved),dbPasswordis random, andexpirationandnextRefreshTimeare epoch seconds (the same instant).durationSecondsdefaults to 900 and must be 900 to 3600.dbName, when given, must be the namespacedbName.customDomainNameis not supported. A returned credential stays valid until it expires or the workgroup is deleted.- The runtime survives a restart when its container does. On startup Floci re-attaches to the container and restarts the proxy on the same port, so the endpoint is stable. If the container is gone the workgroup comes back with an empty database; if neither can be started, the workgroup stays
AVAILABLE, the Data API reports that its runtime is not available, and the failure is logged. Containers have no Docker volume, as for provisioned clusters. adminUserPasswordis accepted and never returned, matching AWS. No secret is created formanageAdminPassword.- Defaults follow AWS.
dbNamedefaults todev,kmsKeyIdtoAWS_OWNED_KMS_KEY,logExportsto an empty list, andstatustoAVAILABLEimmediately: there is noMODIFYINGorCREATINGphase to poll through. creationDateis an ISO-8601 string, for example2026-09-11T18:12:55.433Z, not the epoch-seconds number that awsJson1.1 uses by default.Namespace.creationDatecarriesTimestampFormatTrait(ISO_8601)in the API model, and strict SDKs reject a number here even though the AWS CLI accepts one. (Not a model-wide rule: roughly half the model's timestamp members carry no format trait and use the epoch default, so check each member when extending this service.)namespaceIdis a generated UUID andnamespaceArnisarn:aws:redshift-serverless:<region>:<account>:namespace/<namespaceId>.DeleteNamespacereturns the deleted namespace withstatusDELETINGand removes it in the same call, so the nextGetNamespacereturnsResourceNotFoundException.UpdateNamespaceapplies only the fields present in the request. An omitted field keeps its stored value; an explicitly emptyiamRolesorlogExportsarray clears it.- A namespace has at most one workgroup, and a workgroup belongs to exactly one namespace. A second
CreateWorkgroupfor a namespace returnsConflictException, and so doesDeleteNamespacewhile the namespace still has a workgroup. AWS documents the one-to-one relationship; theDeleteNamespacerefusal is the one rule here that is inferred rather than documented, because the API reference listsConflictExceptionfor that call without naming its trigger. - Workgroup defaults follow AWS.
baseCapacitydefaults to 128 RPUs,portto 5439,ipAddressTypetoipv4,trackNametocurrent,pricePerformanceTargetto{"status":"DISABLED"}, andenhancedVpcRouting,publiclyAccessibleandextraComputeForAutomaticOptimizationtofalse.statusisAVAILABLEas soon as the call returns;DeleteWorkgroupreturns the workgroup withDELETINGand removes it in the same call. - Capacity, network and security settings are stored and echoed, not enforced.
baseCapacity,maxCapacity,subnetIds,securityGroupIds,enhancedVpcRouting,publiclyAccessibleandconfigParametershave no effect on the emulator.configParametersreturns only what the caller supplied: AWS also adds a set of default parameters that the API reference does not enumerate, and Terraform treats the attribute as computed, so the difference does not produce a plan diff. portis validated and echoed. It must be in 5431-5455 or 8191-8215. Theendpoint.portis the port Floci allocated, which is what a client connects to.UpdateWorkgroupapplies only the fields present. AWS documents that several parameters cannot be changed in one request; Floci accepts any combination. AtrackNamedifferent from the current one is recorded aspendingTrackNameandtrackNameis unchanged, as AWS switches tracks on the next release.workgroupNameandnamespaceNamecannot be changed.workgroupArnisarn:aws:redshift-serverless:<region>:<account>:workgroup/<workgroupId>, andcreationDateis an ISO-8601 string like the namespace one.workgroupVersion,patchVersion,crossAccountVpcs, the custom domain members andendpoint.vpcEndpointsare omitted.- Tagging is keyed by
resourceArn, not by name, and namespaces and workgroups are the taggable Redshift Serverless resources in Floci.TagResourcemerges into the existing tags rather than replacing them,UntagResourceremoves by key, and any ARN that does not name a known namespace or workgroup in the caller's Region returnsResourceNotFoundException. Tags supplied at create are readable throughListTagsForResourceand survive an update.
AWS-compatible failures
Namespace and workgroup names, database names, log export values, ports and workgroup enum members are validated. Floci returns ValidationException for a malformed request, ConflictException when a namespace or workgroup name is already taken, when a namespace already has a workgroup, or when a namespace being deleted still has one, and ResourceNotFoundException for an unknown namespace or workgroup.
AWS also models AccessDeniedException, InternalServerException, and ThrottlingException. Floci does not inject provider-side failures that cannot be derived from the request or emulator state.
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_REDSHIFT_SERVERLESS_ENABLED |
true |
Enable or disable Redshift Serverless |
Workgroup containers and proxies use the floci.services.redshift.* settings: image-version, proxy-base-port and proxy-max-port, endpoint-host, docker-network and the proxy connection limits.
Example
export AWS_ENDPOINT_URL=http://localhost:4566
aws redshift-serverless create-namespace \
--namespace-name analytics \
--admin-username admin \
--admin-user-password Secret123! \
--db-name dev
aws redshift-serverless get-namespace --namespace-name analytics
aws redshift-serverless list-namespaces
aws redshift-serverless update-namespace --namespace-name analytics --log-exports userlog
aws redshift-serverless create-workgroup \
--workgroup-name analytics-wg \
--namespace-name analytics \
--base-capacity 32
aws redshift-serverless get-workgroup --workgroup-name analytics-wg
aws redshift-serverless get-credentials --workgroup-name analytics-wg --db-name dev
aws redshift-data execute-statement --workgroup-name analytics-wg --database dev --sql "select 1"
aws redshift-serverless list-workgroups
aws redshift-serverless update-workgroup --workgroup-name analytics-wg --base-capacity 64
aws redshift-serverless delete-workgroup --workgroup-name analytics-wg
aws redshift-serverless delete-namespace --namespace-name analytics
- Snapshots dump the database. While the namespace's workgroup is running,
CreateSnapshotrunspg_dumpon its container and stores the dump under<persistent-path>/redshift-serverless-dumps/<account>/<region>/.RestoreFromSnapshotdrops every user schema (the catalog bootstrap schema excepted) and replays the dump withpsql, stopping at the first failing statement, so rows written after the snapshot are gone. The current contents are dumped first and put back if the replay fails, and a restore whose recorded dump file has gone missing fails instead of reporting success. A snapshot taken with no running workgroup is metadata only, and restoring it leaves the database untouched.DeleteSnapshotremoves the dump. Snapshot ARNs use the snapshot name as their id, snapshot names are 3-255 lowercase letters, digits and hyphens, andretentionPeriodis-1(indefinite, the default) or 1 to 3653 days. Snapshots are taggable by ARN.snapshotNameandsnapshotArncannot be sent together. Floci's ownfloci_internalbootstrap schema, which feeds thesvv_external_*views from the Glue catalog, is left out of both the dump and the reset, matching AWS where the Glue catalog is outside a namespace snapshot, so a client schema with that exact name is not captured. A real snapshot expires after its retention period; Floci reportssnapshotRemainingDaysbut does not expire snapshots.