Commit Graph
77 Commits
Author SHA1 Message Date
Vũ Thế Huy d08c241d98 feat(redshift): scheduled actions that pause and resume provisioned clusters (#8260) 2026-11-14 13:28:06 -04:00
Priamo Germosen f09468fb19 feat(redshift): require kms:Decrypt on an encrypted snapshot's key to restore it (#8309)
AWS requires the customer managed key of an encrypted snapshot to be shared
with the account restoring it (Redshift Management Guide, "Sharing a
snapshot"). Neither botocore nor the Service Reference says so, so the
request-resources generator states it in FORWARDED, an evidence entry under
MEASURED's rules: the action and the snapshot type, with the rest read from
the metadata (the key type and format kms:Decrypt acts on, the snapshot
record's KmsKeyId member, the endpoint prefix, kms:ViaService).

Under IAM enforcement a Redshift or Redshift Serverless restore is then also
checked as kms:Decrypt on the key the snapshot records, found in the
snapshot's account, against the key policy and the caller's own policies,
with aws:ViaAWSService and kms:ViaService naming the service's endpoint. KMS
key policies are now evaluated as resource policies.

A key KMS would not use, disabled, pending deletion or not held, refuses the
restore, as KMS refuses the request the service makes with it. A snapshot
under AWS's own key records none, and one under an AWS managed key (a copy
grant made without a key) needs nothing, as AWS writes that key's policy to
let the account use it through the service.
2026-11-14 11:04:31 -04:00
Vũ Thế Huy b658720afe feat: map Redshift IAM credentials to PostgreSQL roles (#8211)
* feat(redshift): map Redshift IAM credentials to PostgreSQL roles
* docs(redshift): document IAM database identity for Redshift services
* fix(redshift): harden Redshift IAM role handover and DbGroups lifecycle
* fix(redshift): grant public schema usage on auto-create and resolve latest credential
* fix(redshift): log in as the IAM-derived role so PostgreSQL blocks the switch back
* fix(redshift): restore the role's own password once the backend login completes
* chore(redshift): write the password tracker lock comment in English
2026-11-14 01:06:59 -04:00
Vũ Thế Huy eea61cd42a feat(redshift): project DynamoDB zero-ETL changes into a current-state table (#8180) 2026-11-13 16:18:31 -04:00
Vũ Thế Huy 315367f21f feat(redshift): share a cluster snapshot with another account (#8077)
AuthorizeSnapshotAccess and RevokeSnapshotAccess record the accounts that may restore a
manual, available snapshot. The snapshot reports OwnerAccount and AccountsWithRestoreAccess,
DescribeClusterSnapshots takes an OwnerAccount filter that lists only what the owner shared
with the caller, and RestoreFromClusterSnapshot takes an OwnerAccount (or a SnapshotArn of
another account) and restores a shared snapshot from the owner's dump. A snapshot that is not
shared is refused with AccessToSnapshotDenied, and the grant does not outlive the snapshot.

IAM takes generated data only, so the RestoreFromClusterSnapshot correction is replaced by two
rules in regen_iam_request_resources.py. A top-level request member whose name ends in Account
gives the account of each type whose botocore structure has that same member: Snapshot has
OwnerAccount and Cluster does not, so the snapshot moves to the owner's account and the restored
cluster stays the caller's. Of several members that could fill a variable, one naming the type
before the variable wins over a bare one, so the snapshot's ClusterName comes from
SnapshotClusterIdentifier rather than ClusterIdentifier.

Across every operation the rules change only that entry, which also gains DefaultIamRoleArn and
RedshiftIdcApplicationArn as ARN rows that never match a cluster or snapshot, and CloudFront's
GetInvalidationForDistributionTenant, whose tenant is now filled from DistributionTenantId rather
than the invalidation's Id.

The handler's SnapshotArn check now resolves the partition through RegionResolver, as the
service's Region check does, so a Region outside the known partitions cannot make the two
disagree.
2026-11-12 23:34:54 -04:00
Vũ Thế Huy 59c2b46e1c feat(redshift): implement remaining COPY options and load diagnostics (#8075)
Stream records through CopyBulkLoader.Cursor in loadRecords and reuse writeRecord, eliminating duplicate decompression, line skipping, record reading, heap tracking and blank line filtering.

Verify Cursor record iteration, line tracking and raw byte capture, along with writeRecord chunking across PostgreSQL CopyData wire frames.
2026-11-12 09:10:43 -04:00
Vũ Thế Huy 9f8593a062 fix(redshift): prune Spectrum partitions for binary integer binds (#7912) 2026-11-11 13:06:00 -04:00
Vũ Thế Huy 4d4f20b812 feat(redshift): execute S3 auto-copy and COPY JOB RUN (#7898)
A job failure (SQLState 42xx or 0A000) cannot clear on its own, so re-marking the bucket made every sweep reconnect and log a WARN. The job now waits for the next upload. The predicate is shared with CopyJobRunner via S3TransferException.isJobFailure.
2026-11-11 12:49:20 -04:00
Vũ Thế Huy 2964140717 feat(redshift): prune Spectrum partitions for bind parameters (#7758) (#7863)
A prepared statement with a predicate on a bound value (WHERE day = $1) loaded every Glue partition, because the pruner read only literals. The Bind message now carries its text-format values, and the pruner reads each $n as the value bound to it.

A statement that is only being parsed has no values yet, so it loads no partition, enough for PostgreSQL to plan it; each Bind loads the partitions its values select. A NULL, binary-format or unreadable value leaves its predicate out and the query loads every partition. A malformed Bind parameter section leaves the values unknown instead of failing the connection.

Parse of a parameterized Spectrum statement no longer deletes partitions by cast key,
which could remove rows of overlapping partitions that stay recorded as loaded; the
Bind reconciles the table. Bind parameters are decoded only when a Spectrum statement
needs them, and binary values are skipped instead of copied.
2026-11-10 10:57:23 -04:00
Vũ Thế Huy d1205c34a2 feat(redshift): prune Spectrum partitions in Extended Query and transaction blocks (#7758) (#7778)
Stage partitions loaded by a load that may roll back per client connection and publish them when the transaction commits, guarded by a per-table generation, instead of loading every partition.

ensurePartitions waited on the per-table Java lock without a timeout even when the session held PostgreSQL locks. A transaction holding a table lock while another connection held the Java lock to load that table formed a cycle PostgreSQL cannot detect. It now uses the same transaction-aware acquisition as the full-load path.

Pruning also applies to the Data API outside a transaction block, a predicate on a bind parameter is left out while literal predicates in the same statement still prune, and a session in a transaction block now waits at most 30 seconds for another load of the same table.
2026-11-09 22:00:56 -04:00
Vũ Thế Huy 92eff0aca5 feat(redshift): support ModifyClusterSnapshot API action (#7755) (#7756)
* feat(redshift): support ModifyClusterSnapshot API action (#7755)

* docs(redshift): update operation count after merging CopyClusterSnapshot

* fix(redshift): enforce ModifyClusterSnapshot retention, Force, and expiry of manual snapshots (#7755)

* fix(redshift): address snapshot retention review feedback
2026-11-09 13:18:19 -04:00
Vũ Thế Huy 6ca2b03d21 feat(redshift): support COMPUPDATE, STATUPDATE, and TRIMBLANKS in COPY (#7751) (#7754)
* feat(redshift): support COMPUPDATE, STATUPDATE, and TRIMBLANKS in COPY (#7751)

* fix(redshift): keep NULL markers and empty strings correct under COPY TRIMBLANKS (#7751)

Skip trimming for a field that is the NULL marker, and quote a CSV field that trims to an empty string so it is not read as NULL.

* fix(redshift): accept COMPUPDATE PRESET and trim trailing tabs under TRIMBLANKS (#7751)
2026-11-09 10:08:01 -04:00
Vũ Thế Huy e0692092b5 feat(redshift): support CopyClusterSnapshot API action (#7748) (#7750)
* feat(redshift): support CopyClusterSnapshot API action (#7748)

* fix(redshift): address review findings and sync docs for CopyClusterSnapshot (#7748)

* refactor(redshift): simplify CopyClusterSnapshot using existing helpers (#7748)

Drop Tags, KmsKeyId and the ARN branch, which CopyClusterSnapshotMessage does not carry.
Reuse validateManualRetention (InvalidRetentionPeriodFault), takenFrom and SnapshotDumpCopier.copy,
and share the automated-snapshot setup across the new tests.
2026-11-08 17:56:25 -04:00
Vũ Thế Huy 08be536e15 feat(redshift): support audit logging to S3 (RS-14 / INT-08) (#7699) 2026-11-07 09:14:49 -04:00
Vũ Thế Huy 8cff513c8d feat(redshift): take an S3 bucket as the source of an integration (#7466)
CreateIntegration accepts arn:aws:s3:::bucket with a Serverless namespace or cluster target. The bucket must exist in the integration's Region and have no period in its name, a bucket joins a target once, and a target takes at most 50. The integration reports SourceType s3-event-notifications, starts no poller and publishes no zero-ETL events.

fix(redshift): validate S3 integration source and target identities

fix(redshift): resolve unstored S3 bucket Region in default Region

Fall back to the deployment default Region when an S3 bucket has no stored Region, match bucket partition using RegionResolver.partitionForRegion, and remove the unused two-argument RedshiftZeroEtlEndpoints constructor.
2026-11-06 19:20:05 -04:00
Vũ Thế Huy 576646aae7 fix(redshift): run COPY ETL options on PostgreSQL 15 across protocols (#7514) 2026-11-06 08:50:21 -04:00
Vũ Thế Huy de71d91d8c feat(redshift): add COPY JOB create, list, show, alter and drop (#7465)
A job stores the parameters of a COPY from S3 in the cluster database, and sys_copy_job lists it with AWS's columns. The checks AWS documents are made when the job is created: an S3 source, an explicit IAM_ROLE, no manifest, access keys, MAXERROR or IGNOREALLERRORS, no hyphen in the name, no transaction block, at most 200 jobs. COPY JOB RUN is refused until files can be loaded automatically.
2026-11-05 15:11:51 -04:00
Maxence Frenette f7cf6fef6e feat(redshift): support Redshift UNLOAD to Parquet (#7548)
* feat(redshift): support UNLOAD to Parquet

* refactor(redshift): share internal S3 scratch plumbing

* fix(redshift): warn when UNLOAD staging cleanup fails
2026-11-04 22:53:38 -04:00
Vũ Thế Huy a42779bb2a feat(redshift): prune external table partitions from query WHERE predicates (#7413)
* feat(redshift): prune external table partitions from query WHERE predicates

Load only the partitions selected by top-level AND predicates of the query WHERE clause for external tables, accumulating partitions across queries and avoiding full scans when specific partitions are requested.

* fix(redshift): handle CASE in partition pruner, overlapping refreshes, and isolate spectrum test schema

* fix(redshift): identify materialized rows by partition and share SQL lexer

Tell materialized external table rows apart by an internal partition identifier column so that refreshing or deleting a partition only deletes its exact rows and never removes rows belonging to partitions whose keys overlap when converted. Dropping a partition no longer reads or authorizes retained overlapping partitions, preventing unauthorized S3 access errors on unselected partitions.

Share tokenization rules between ExternalReferenceScanner and PartitionPruner in SpectrumSqlLexer.

* fix(redshift): hide the partition column behind a view and read strings as strings in the scanner

A partitioned external table kept the partition each row came from in a column of the public table,
so SELECT * returned an extra column and INSERT ... SELECT * could fail on the column count. The rows
now live in a backing table, _floci_spectrum_<table>, and the name the user queries is a view of the
declared columns only. DROP TABLE drops the view and the backing table, and the Data API ListTables
does not list the backing table.

ExternalReferenceScanner took a one-character string such as ';' for a statement separator, which
cleared the table context and let the query skip preparation and its S3 checks. It now reads the
structural characters by token kind.

The pruning integration test used the legacy catalog, whose parser does not read PARTITIONED BY, so
it now creates a Glue database.

* fix(redshift): keep the partition backing table in a schema of its own and send plain batches

The batches that drop and replace the relation of a partitioned external table started with a DO
block. PostgresExtendedBackendSession wraps only batches that start with CREATE or DROP, so an
extended query sent them unchanged and PostgreSQL refused several commands in one prepared
statement. A DO block nested in the wrapper is not valid either, and a schema or table name that
held the dollar-quote tag would have closed the body early. The relation is now dropped with
DROP VIEW or DROP TABLE as the last load made it, so every batch is plain statements.

The backing table was named after the table it backs in the user's schema, so a Glue table of the
same name could drop or reuse it, and the Data API ListTables hid every table with that prefix. It
now lives in the schema floci_spectrum under a name made from the external schema and table, and
ListSchemas and ListTables hide only that schema.

* fix(redshift): load the whole external table when partition keys overlap instead of keeping a backing table

Delete by key value is only safe when no two partitions cast to the same value. When they do (integer 1 and 01, decimal 1.0 and 1.00, boolean true and t), the query reads every partition and a change replaces the whole table. This drops the backing table, view and floci_spectrum schema, which broke dropping a table whose Glue definition gained partition keys, other users' loads, and DROP SCHEMA CASCADE.

* fix(redshift): expect 22P02 SQLSTATE on invalid partition data
2026-11-03 21:39:17 -04:00
Vũ Thế Huy 814232c43f feat(firehose): load Redshift COPY with temporary credentials of the stream role (#7337) 2026-11-03 13:49:06 -04:00
Vũ Thế Huy e82fa60617 feat(redshift): read a Parquet column missing from a partition's files as NULL (#7406) 2026-11-03 10:29:39 -04:00
Ovidiu (Ovi) d7797bf56d feat(redshift): add PutResourcePolicy, GetResourcePolicy and DeleteResourcePolicy (#7361)
* feat(redshift): add PutResourcePolicy, GetResourcePolicy and DeleteResourcePolicy

aws_redshift_resource_policy could not be created: the provisioned Redshift API had none of the three operations. They now take the ARN of a Redshift Serverless namespace or a provisioned cluster, the targets of a zero-ETL integration, matched exactly in the caller's account and Region. The policy is kept on its namespace or cluster, so it goes with the resource, and is stored and echoed, not evaluated.

* feat(redshift): return resource policies and their errors as AWS does

Checked against AWS with read-only GetResourcePolicy calls: a stored policy comes back with Version and
Statement first and each statement's Effect, Principal, Action, Resource and Condition first,
pretty-printed, so it is now stored in that form. A namespace that does not exist answers "The requested
namespace doesn't exist."; an ARN in another Region, a namespace id that is not a UUID and an ARN of any
other resource type are InvalidParameterValue with AWS's messages, not UnsupportedOperation.

Adds an SDK compatibility test for the three operations.

* fix(redshift): keep a namespace's resource policy across updates

The Namespace copy constructor, used by tagging, untagging and UpdateNamespace, did not copy the
resource policy, so any of them dropped it. findClusterByArn now reads the ARN through AwsArnUtils.

Without a Version, GetResourcePolicy reached Elastic Load Balancing, which defines the name but does
not serve it; it now goes to Redshift.

* fix(redshift): refuse an empty resource policy before looking the resource up
2026-11-03 08:27:03 -04:00
Vũ Thế Huy a93de121ae feat(redshift): read S3 as the access keys a COPY names (#7334) 2026-11-02 21:37:08 -04:00
Ovidiu (Ovi) 6abdb4cc44 feat(redshift): take a DynamoDB table and a Serverless namespace in zero-ETL integrations (#7332)
* feat(redshift): take a DynamoDB table and a Serverless namespace in zero-ETL integrations

CreateIntegration took only a DynamoDB stream ARN as SourceArn and a provisioned cluster ARN as
TargetArn. AWS takes the table ARN and a Redshift Serverless namespace ARN (its model allows no
cluster: ARN), so a Terraform aws_redshift_integration written for AWS failed to create.

Both AWS forms are now accepted and the original ones are kept. A missing table is
IntegrationSourceNotFoundFault and a missing namespace IntegrationTargetNotFoundFault, as the API
reference lists. A namespace is written through its workgroup into the namespace's database. A
table source reads changes from the table's latest stream, following one turned on after the
integration was created.

Stream records never landed: the writer bound ApproximateCreationDateTime as an Instant, which the
PostgreSQL driver refuses, so only backfilled items reached the landing table. It now binds an
OffsetDateTime as TIMESTAMPTZ.

* fix(redshift): drain a table's replaced stream and match the source table ARN

A table source moved to the table's latest stream as soon as it changed, dropping records the old
stream still held, and moved to no stream when DynamoDB Local reported none for a table whose streams
were turned off. It now reads the followed stream until a read comes back empty, or until the stream
has expired, before moving, keeps it while the table reports no stream, and persists the move.

A source table ARN was resolved by its table name alone, so a table of another account, or an ARN
with more after the name, was taken for the caller's table of that name. The resolved table must now
have the supplied ARN. The docs no longer promise IntegrationSourceNotFoundFault for a missing stream.

* test(redshift): use the shared Docker probe and Query request helpers in the zero-ETL test
2026-11-02 21:13:21 -04:00
Vũ Thế Huy 432fa4177e feat(redshift): load empty fields of non-character columns as NULL in COPY (#7324) 2026-11-02 13:40:17 -04:00
Vũ Thế Huy d4eeada135 feat(redshift): support MAXERROR in COPY (#7291)
* feat(redshift): support MAXERROR in COPY

MAXERROR n of 2 or more now asks the backend to skip records it cannot convert
(ON_ERROR ignore) and to fail the COPY at the n-th one (REJECT_LIMIT n - 1),
which needs a PostgreSQL 18 backend. A MAXERROR of 0 or 1 fails at the first
error, as without the option.

* test(redshift): add PostgreSQL 18 MAXERROR integration test

* test(redshift): use shared DockerAvailability and RedshiftConnections in PostgreSQL 18 IT

Address review feedback on PR #7291:
- Call testing.DockerAvailability.isAvailable() instead of carrying a private copy of the probe.
- Use RedshiftConnections.waitForConnection(cluster) instead of duplicating the JDBC connection wait helper.
2026-11-02 11:58:15 -04:00
Allen Sanborn 4438e3df49 fix(redshift): keep tags, VPC and subnet detail on cluster subnet groups (#7211)
* fix(redshift): keep tags, VPC and subnet detail on cluster subnet groups

CreateClusterSubnetGroup dropped Tags and passed a null VPC, so
DescribeClusterSubnetGroups returned no Tags, VpcId, SubnetGroupStatus or
SubnetAvailabilityZone and the Terraform provider saw drift on every plan.

Tags are now parsed (Tags.member.N and Tags.Tag.N) and stored on the group,
where DescribeTags/CreateTags already find them under the subnetgroup ARN.
The VPC and each subnet's zone are resolved from EC2 on create and modify;
subnets EC2 does not know are kept unresolved, as before. Groups persisted
earlier load unchanged (the new zone map is nullable).

* fix(redshift): inject Ec2Service through the constructor

Replace the Ec2Service field injection with a constructor parameter held
in a final field. The previous @Inject signature stays as a package-private
delegating constructor passing null, so hand-built test services still
skip subnet resolution.

* test(redshift): build the EC2 setup requests with Ec2Requests

ec2Id now only extracts the id from the response; the auth header and
Action come from the shared Ec2Requests.ec2 helper.

* test(redshift): make ec2Id a plain path extraction

Call sites build the EC2 request with Ec2Requests.ec2 and pass it in;
the account and region are named constants.
2026-11-02 10:09:50 -04:00
Vũ Thế Huy cd6e516929 feat(redshift): support FILLRECORD in COPY (#7269)
* feat(redshift): support FILLRECORD in COPY

A text or CSV record that stops short of the last columns is loaded with the
rest of them filled: a character column gets a zero-length string and any other
column NULL, as in Redshift. EMPTYASNULL and NULL AS '' make the character
columns NULL too. Without FILLRECORD nothing changes.

* fix(redshift): bound memory growth for FILLRECORD output

Count transformed output against COPY_TRANSFORM_MAX_OBJECT_BYTES and the shared COPY_TRANSFORM_HEAP_MIB budget as records are written, so short records expanded by FILLRECORD fail with the statement limit or memory budget error rather than exhausting the emulator heap.

* fix(redshift): load missing CHAR columns as NULL on FILLRECORD
2026-11-02 09:33:31 -04:00
Vũ Thế Huy b92340b243 fix(redshift): skip the header of every object in a COPY (#7266) 2026-11-02 08:30:02 -04:00
Vũ Thế Huy 105d6732f3 feat(redshift): support DATEFORMAT, TIMEFORMAT and ACCEPTANYDATE in COPY (#7263) 2026-11-01 21:55:35 -04:00
Vũ Thế Huy cedc1073ec feat(redshift): sign the Spectrum floci-duck transfer with the role session when S3 auth is enforced (#7162) 2026-11-01 09:26:32 -04:00
Vũ Thế Huy dd423ee161 feat(redshift): copy cluster snapshots into the configured destination region (#7058)
* feat(redshift): copy cluster snapshots into the configured destination region

EnableSnapshotCopy used to only record the destination on the cluster. A background sweep now copies each available snapshot taken after copy was enabled into a per-Region copy store, with its own dump file, retention and KMS key from the copy grant. Describe, delete, restore and tagging use the copy when the request's Region has one.

* fix(redshift): harden snapshot copy expiry, rollback and same-region enable

Expiry re-reads the copy under the lock so a replaced copy is not deleted. A failed flush undoes the copy record and the source mark before the dump is removed. A sweep re-checks that copy is still enabled to the destination. EnableSnapshotCopy refuses the cluster's own Region, and CreateClusterSnapshot refuses an identifier a copy already holds in that Region.

* fix(redshift): harden snapshot copy and share the sweep scheduler base and dump copier

Snapshot copy: keep a retained copy when a source snapshot is recreated under the same name, flush the copy before marking the source, only apply the cluster's copy retention to copies of the same cluster generation, recheck the copy settings under the snapshot lock before each copy, and leave shadowed sources out of DescribeTags.

Refactor: the five SweepWorker scheduler wrappers now extend SweepScheduler, and both services copy dumps through SnapshotDumpCopier.

* docs(redshift): note the hybrid storage limit of snapshot copy

Hybrid storage does not report a failed flush, so a crash can leave a source snapshot marked as copied without its copy. Persistent and WAL storage report the failure before the source is marked.
2026-10-31 11:34:57 -04:00
Vũ Thế Huy 1a871392b7 feat(redshift): support pausing and resuming provisioned clusters (#6911)
* feat(redshift): support pausing and resuming provisioned clusters

* docs(redshift): sync supported operation count

* fix(redshift): harden pause and resume failure recovery

* fix(redshift): skip unchanged idle integration writes

* fix: consolidate Redshift pause and resume state persistence
2026-10-29 12:55:50 -04:00
Vũ Thế Huy c0d1767ec0 feat(redshift): send zero-ETL integration events to EventBridge (#6822) 2026-10-28 22:41:04 -04:00
Vũ Thế Huy d3c4732b31 feat(cloudformation): provision Redshift event subscriptions (#6664)
* feat(redshift): support event history and SNS notifications

* fix(redshift): guard stale delivery failures and prune all event scopes

* feat(cloudformation): provision Redshift event subscriptions

* fix(redshift): scope snapshot events and serialize subscription tag mutations

* feat(cloudformation): provision Redshift event subscriptions

* fix(cloudformation): resolve Redshift subscription list parameters

Use the shared list reader for SourceIds and EventCategories. Cover CommaDelimitedList and List<String> parameters through the AWS SDK and verify concurrent tag requests preserve CloudFormation tag updates.

* fix(redshift): honor event disablement and restore rollback attributes

Check the EventBridge external service key before publishing API events. Snapshot and restore CloudFormation resource attributes alongside subscription state during in-place rollback.

* fix(redshift): drop API event publisher and share subscription setup

Remove RedshiftApiEventPublisher, its handler hook, tests and docs, which are not part of the CloudFormation resource and emit CloudTrail-style events without a trail. Route createSubscription and replaceSubscription through one helper that normalizes the subscription fields.
2026-10-27 23:28:52 -04:00
Vũ Thế Huy 5bd4bd481a feat(redshift): publish CloudWatch cluster metrics (#6740)
* feat(redshift): publish CloudWatch cluster metrics

* fix(redshift): skip duplicate CloudWatch publication minutes

* test(redshift): isolate metrics publisher between integration tests

* fix(test): use Java 17 list access in Redshift metrics compatibility test

* fix(metrics): share minute publishing and prevent duplicate SQS samples

Centralize daemon scheduling, minute claims, per-target failures, retention and shutdown for SQS and Redshift. Carry the Redshift proxy key in metric targets and use the shared compatibility await fixture.

* docs(metrics): restore publisher class docs after the shared publisher move

Keep the SQS sample shape on SqsMetricsPublisher and document minute stamping, 15-day retention and the nothing-may-escape rule on MinuteMetricsPublisher.
2026-10-27 22:03:23 -04:00
Vũ Thế Huy 3d30bbcf7a feat(redshift): add event subscriptions with SNS delivery (#6705)
* feat(redshift): add event subscriptions with SNS delivery

Add Create, Modify, Delete and DescribeEventSubscriptions, subscription tagging, and publication of matching events to the subscription's SNS topic, honouring the topic policy.

* fix(redshift): deliver events from a consistent subscription snapshot and reject nameless subscription ARNs

Delivery copied no state under the lock modifySubscription holds, so a concurrent
update could change the topic between matching and publishing. Match and publish
from a snapshot taken under that lock.

A tag ARN ending in eventsubscription: passed an empty name to
describeSubscriptions, which lists all subscriptions. Reject it up front.
2026-10-27 11:34:38 -04:00
Vũ Thế Huy e9e2b38da6 feat(redshift): add event history and DescribeEvents (#6663) 2026-10-26 21:25:14 -04:00
Vũ Thế Huy f184cce726 feat(redshift): execute automated snapshot schedules (#6536)
* feat(redshift): execute automated snapshot schedules

* fix(redshift): address automated snapshot review findings

Flush snapshot metadata before deleting an expired dump, pause the
snapshot scheduler across emulator reset, run retention even when the
next dump fails, and remove checkpoints of deleted clusters.

* fix(redshift): retake an automated snapshot whose metadata was lost

The checkpoint is a separate store, so it can persist while the snapshot
metadata never reached disk. Skip a completed occurrence only when its
snapshot still exists.

* test(redshift): restore the automated snapshot on the shared interceptor cluster

Run the Docker restore scenario in RedshiftInterceptorIntegrationTest
against the cluster it already starts, so only the restore pays for a
container, and drop the hand-rolled Docker probe.
2026-10-26 11:42:07 -04:00
Vũ Thế Huy ce0933be9b feat(redshift): rotate managed master passwords (#6505)
* feat(redshift): rotate managed master passwords

* fix(redshift): serialize managed secret rotation

* fix(redshift): address managed secret rotation review

* fix(redshift): keep concurrent rotation retries idempotent

* fix: defer managed secret guard until rotation reservation succeeds

* fix: preserve secret versions saved during rotation reservation

* fix: guarantee required character types in serverless passwords

* revert: defer serverless password character types fix to dedicated PR

* test(secretsmanager): extract blocking reserve helper across rotators
2026-10-26 09:30:08 -04:00
Vũ Thế Huy b15bc708fa feat: deliver Redshift audit logs to CloudWatch Logs (#6432)
* feat: deliver Redshift audit logs to CloudWatch Logs

* fix: correct Redshift audit logging and account isolation

* docs: remove Redshift audit logging design document

* fix: reject transaction control in Redshift Data API batches

* fix: track Redshift batch audit changes through savepoints

* fix(redshift-data): guard explicit batch commits against cancellation

* fix(redshift): preserve audit regions and redact ambiguous passwords
2026-10-25 07:42:48 -04:00
Vũ Thế Huy fac6378abd fix(redshift): raise postgres max_connections to 500 (#6421)
* fix(redshift): raise postgres max_connections to 500

The Postgres container behind a Redshift cluster runs with the default max_connections of 100, and each retained session keeps a connection open. Near 100 sessions, Data API calls and JDBC clients on that cluster encounter 'sorry, too many clients already', well before reaching the 500-session limit. Raising max_connections to 500 in RedshiftContainerManager lets the documented 500-session limit apply.

* fix(redshift): raise default proxy max connections to 500

The PostgreSQL backend limit was raised to 500, but the Redshift auth proxy connection semaphore defaulted to 100 via proxy-max-connections. As a result, client connections above 100 were refused by the proxy before reaching PostgreSQL. Raise the default proxy-max-connections to 500 across config, application YAML, and documentation.

* fix(redshift): follow node type for max_connections and raise proxy default to 2000

* fix(redshift): support rg node types, pass serverless from runtime, and update test stubs

- Include rg.* node types for 2,000 max_connections
- Pass 'serverless' node type from RedshiftServerlessRuntime and drop prefix check
- Update start(...) stubs across integration tests with the six-argument signature
2026-10-24 21:09:27 -04:00
Vũ Thế Huy 4c70d6b1a2 feat(cloudformation): support Redshift snapshot restores (#6395)
* feat(cloudformation): support Redshift snapshot restores

* fix(cloudformation): address Redshift snapshot restore review findings

- Reconcile ManageMasterPassword and KMS key on in-place cluster update
- Avoid overriding inherited snapshot passwords on unrelated template changes
- Reconcile tags by deleting removed tags on update
- Mint ARN for parameter group tags to prevent invalid parameter errors
- Scope mutate locking during snapshot restore to prevent stalling writes

* fix(cloudformation): narrow Redshift snapshot restore scope

* fix(cloudformation): use shared rollback for Redshift state
2026-10-24 08:01:26 -04:00
Andre Kurait a96921afad fix(redshift): reclaim anonymous container volumes (#6382)
Reclaim disposable anonymous volumes while preserving adopted containers during failed recovery. Retain pre-reboot dumps and failed cleanup ownership across partial teardown. Preserve the original database when only proxy shutdown fails. Share startup orchestration while retaining the opt-in cleanup policy.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
2026-10-23 20:46:24 -04:00
Vũ Thế Huy 1b8548a0af feat(redshift): create final snapshots before deleting clusters (#6346)
* feat(redshift): create final snapshots before deleting clusters

* fix(redshift): clean failed dumps and scope snapshot locking

* fix(redshift): default manual snapshot retention and fix Spectrum cleanup
2026-10-23 14:06:47 -04:00
Vũ Thế Huy 7e51e69c44 feat(redshift): support default IAM roles for COPY and UNLOAD (#6304)
* feat(redshift): support default IAM roles for COPY and UNLOAD

* fix(redshift): distinguish default role keyword from literals

* fix(redshift): accept blank default IAM roles
2026-10-23 08:33:20 -04:00
Priamo Germosen 812c95499d fix(iam): check iam:PassRole for Redshift, Redshift Serverless and AddRoleToInstanceProfile (#6250)
Under IAM enforcement a request that passes a role to a service needs iam:PassRole on that role,
but no Redshift or Redshift Serverless operation was checked for it. A caller allowed to create a
cluster or change its roles could attach any role to it, and Floci's COPY, UNLOAD and Spectrum
statements then run as that role; statements run through the Data API on a Redshift Serverless
workgroup can use its namespace's roles the same way.

Now checked, with iam:PassedToService as the Service Authorization Reference gives it:
- Redshift CreateCluster and RestoreFromClusterSnapshot pass the roles in IamRoles, and
  ModifyClusterIamRoles those in AddIamRoles, to redshift.amazonaws.com. The lists are read through
  the Redshift handler's own member pattern, so IamRoles.IamRoleArn.N, as the SDK sends it,
  IamRoles.member.N and IamRoles.N all count. RestoreFromClusterSnapshot is checked although
  Floci's restore attaches no role yet, as AWS checks it.
- Redshift Serverless CreateNamespace and UpdateNamespace pass the roles in iamRoles and the one
  in defaultIamRoleArn, and CreateScheduledAction and UpdateScheduledAction pass roleArn, to
  redshift-serverless.amazonaws.com.

The Redshift management guide: "To associate an IAM role with a cluster, a user must have
iam:PassRole permission for that IAM role." A role named only as a cluster's default,
DefaultIamRoleArn, is not checked on its own: the default is one of the roles the cluster holds, and
Floci does not act on it. A namespace's defaultIamRoleArn is checked, since Floci keeps it whether
or not iamRoles holds it.

COPY, UNLOAD and Spectrum now take a role only under the ARN IAM holds it under, path included, as
STS AssumeRole does. They looked the role up by its name alone, so a cluster given
role/sandbox/AdminRole, which a PassRole grant on role/sandbox/* allows, ran its statements as the
AdminRole IAM holds under another path.

IAM's AddRoleToInstanceProfile now passes the role it adds to ec2.amazonaws.com. Every instance
running with the profile gets that role's credentials from the instance metadata service, so adding
a role to a profile already attached to a running instance handed it any role. The IAM API
reference: "The caller of this operation must be granted the PassRole permission on the IAM role by
a permissions policy." RoleName names the role without its path, so the check uses the ARN IAM holds
the role under, or, for a role IAM does not hold, the ARN the name gives.

docs/services/iam.md lists the new operations, and docs/services/redshift.md the path rule.
2026-10-22 17:06:02 -05:00
Vũ Thế Huy d2f2625005 feat(redshift): add ResetClusterParameterGroup (#6230)
* feat(redshift): add ResetClusterParameterGroup

* docs(redshift): update supported operation count

* fix(redshift): validate resets and preserve legacy parameter groups

* fix(redshift): accept empty Query parameter lists
2026-10-22 15:59:54 -04:00
Vũ Thế Huy fd37e109f8 feat(firehose): deliver staged Redshift batches with single-attempt COPY (#6006)
* feat(firehose): deliver staged Redshift batches with single-attempt COPY

A flush stages the batch in the intermediate S3 location, then runs COPY against the cluster proxy over JDBC simple-query mode without an IAM role. The load runs on its own thread so that slow COPY queries do not hold the shared flush executor or PutRecord callers, and failures are logged with the staged batch kept in S3.

* fix(firehose): address review comments on Redshift single-attempt COPY delivery

- Drain buffers before shutting down the Redshift delivery executor on Firehose shutdown and log dropped queued tasks.

- Catch RejectedExecutionException in deliverRedshiftBatch to prevent staged records from returning to the buffer.

- Extract DatabaseSecretCredentials helper in core.common to deduplicate Secrets Manager credentials parsing across RDS Data, Redshift Data, and Firehose.

- Extract RedshiftConnections test helper for waitForConnection and use DockerAvailability.isAvailable() in FirehoseRedshiftDeliveryIntegrationTest.

- Update docs and Javadocs to remove outdated references to retries and shared flush threads.

* fix(firehose): wait for queued Redshift COPY delivery before shutdown and log secret parse errors

* refactor(firehose): deduplicate dropAndLogQueuedTasks helper on shutdown
2026-10-21 13:40:53 -04:00
Aniket Shukla 35ddd5c59d fix(redshift): retry snapshot and catalog uploads (#6065)
Rebuild host-resource uploads and catalog tar streams for transient Docker I/O retries. Keep SQL outside the retry boundary and preserve snapshot failure and optional bootstrap behavior.

Refs #5096.
2026-10-20 07:14:28 -04:00