feat(rds): support PostgreSQL aws_lambda extension (#800)#802
Merged
vieiralucas merged 6 commits intomainfrom Apr 27, 2026
Merged
feat(rds): support PostgreSQL aws_lambda extension (#800)#802vieiralucas merged 6 commits intomainfrom
vieiralucas merged 6 commits intomainfrom
Conversation
Lets SQL running inside fakecloud-managed RDS PostgreSQL instances
invoke fakecloud Lambda functions via the AWS RDS extension API:
CREATE EXTENSION IF NOT EXISTS aws_lambda CASCADE;
SELECT aws_commons.create_lambda_function_arn('my_function');
SELECT * FROM aws_lambda.invoke('my_function', '{"body":"Hello!"}'::json);
- Bake plpython3u + aws_lambda + aws_commons into a fakecloud-postgres
image (built lazily off postgres:<major> on first use, hashed tag
caches per-asset content)
- aws_lambda.invoke (text + composite-typed overloads) calls back to
fakecloud over host.docker.internal via the new
POST /_fakecloud/rds/lambda-invoke bridge endpoint
- Bridge resolves account-scoped function ARNs and routes through the
existing LambdaDelivery trait; Event invocation returns 202 immediately
- E2E test exercises the full path: Lambda + RDS + SQL extension
There was a problem hiding this comment.
3 issues found across 15 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/fakecloud-rds/assets/postgres/aws_lambda--1.0.sql">
<violation number="1" location="crates/fakecloud-rds/assets/postgres/aws_lambda--1.0.sql:52">
P2: HTTP error responses can lose their real status code and return `0` when the error JSON omits `status_code`.</violation>
</file>
<file name="crates/fakecloud-rds/assets/postgres/aws_commons--1.0.sql">
<violation number="1" location="crates/fakecloud-rds/assets/postgres/aws_commons--1.0.sql:13">
P1: Use a `region` field here instead of `qualifier`; this helper is meant to carry the Lambda region, not a version/alias.</violation>
</file>
<file name="website/content/docs/services/rds.md">
<violation number="1" location="website/content/docs/services/rds.md:74">
P2: Don't claim AWS parity here; fakecloud only implements a subset of the RDS Lambda API and its helper signature differs from AWS.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- aws_commons.create_lambda_function_arn second arg is `region`, not `qualifier`, matching the AWS RDS helper. Composite type field renamed to match. Composite-typed `aws_lambda.invoke` overload now uses the carried region (callers can still override it). - aws_lambda.invoke plpython3u path captures the HTTP status separately so error responses without a `status_code` field surface the real code instead of falling back to 0. - Soften docs: don't claim full AWS parity, the extension is a subset.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
tokio-postgres in this workspace doesn't enable the with-serde_json-1
feature, so it can't ToSql a Rust &str into a postgres json parameter
(WrongType { postgres: Json, rust: "&str" }). Switch the e2e test to
embed payloads as SQL literals — test fixtures, no injection concern —
and parse the returned payload via ::text + serde_json::from_str.
…E SQL PL/pgSQL rejected the function with "parameter name 'payload' used more than once" because both an input arg and a RETURNS TABLE column shared the name. LANGUAGE SQL doesn't enforce that uniqueness, so we keep the AWS-compatible argument names and lose the wrapper boilerplate.
The first CreateDBInstance against postgres on a fresh runner now builds the fakecloud-postgres image (plpython3u + aws_lambda extension files) before starting the container, which can take ~30-60s. Default 30s vitest timeout was tripping. Bump to 180s; subsequent runs hit the local cache and are fast.
This was referenced Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #800.
Summary
aws_lambdaextension shape — same surface LocalStack documents, same return tuple(status_code, payload, executed_version, log_result).fakecloud-postgres:<major>-<hash>image is built lazily offpostgres:<major>the first time a Postgres DB instance is created. The image bakes inplpython3u,aws_commons, andaws_lambda. Hashed tag invalidates cached images when fakecloud changes the embedded extension files.POST /_fakecloud/rds/lambda-invokeis whatplpython3ucalls. It builds an account-scoped ARN and dispatches through the existingLambdaDeliverytrait.invocation_type=Eventreturns 202 immediately and runs the Lambda async.--add-host host.docker.internal:<bridge>plusFAKECLOUD_ENDPOINT/FAKECLOUD_ACCOUNT_ID/FAKECLOUD_REGIONenv vars so the python UDF can find fakecloud across macOS, Linux, and Windows hosts.User-visible:
Test plan
cargo build -p fakecloudcleancargo clippy --workspace --all-targets -- -D warningscleancargo fmt --allcargo test -p fakecloud-rdspasses (119 tests)cargo test -p fakecloud-e2e --test rds_aws_lambda -- --nocapture(CI — needs Docker; first run builds the postgres image which takes ~60s)Summary by cubic
Adds PostgreSQL
aws_lambdaextension support in fakecloud RDS so SQL can invoke fakecloud Lambda functions. Ships a lazy-builtfakecloud-postgres:<major>-<hash>image withplpython3u,aws_commons, andaws_lambda, plus a bridge endpoint to route calls.New Features
aws_lambda.invoke(...)andaws_commons.create_lambda_function_arn(function_name, region), returning(status_code, payload, executed_version, log_result).fakecloud-postgresimage per major version; content-hashed tag auto-invalidates the cache.POST /_fakecloud/rds/lambda-invokeresolves account-scoped ARNs and routes through existing Lambda delivery;invocation_type=Eventreturns 202 and runs async.host.docker.internaland setFAKECLOUD_ENDPOINT/FAKECLOUD_ACCOUNT_ID/FAKECLOUD_REGIONfor cross-OS connectivity.Bug Fixes
aws_commons.create_lambda_function_arnsecond parameter isregion; composite field names aligned. Compositeaws_lambda.invokewrapper switched to LANGUAGE SQL and now honors the ARN’s region.aws_lambda.invoke(plpython3u) preserves HTTP status codes when the bridge response lacksstatus_code.jsonpayloads as SQL literals due totokio-postgreslacking theserde_jsonfeature.Written for commit 447b5de. Summary will update on new commits. Review in cubic