Skip to content

Allow function-level vpc: false/null under strict config validation#422

Open
bburgalat-bcg wants to merge 2 commits into
oss-serverless:4.xfrom
bburgalat-bcg:fix-function-vpc-false-null-schema
Open

Allow function-level vpc: false/null under strict config validation#422
bburgalat-bcg wants to merge 2 commits into
oss-serverless:4.xfrom
bburgalat-bcg:fix-function-vpc-false-null-schema

Conversation

@bburgalat-bcg

@bburgalat-bcg bburgalat-bcg commented Jul 21, 2026

Copy link
Copy Markdown

Closes #421.

Problem

Under v4's default configValidationMode: error, a function-level VPC opt-out (vpc: false or vpc: null) is rejected:

Configuration error at 'functions.<fn>.vpc': must be object

The opt-out is still honored by the compile step — lib/plugins/aws/package/compile/functions.js checks functionObject.vpc !== null && functionObject.vpc !== false — but the function-level vpc schema only accepts an object, so strict validation blocks it. This removes the only way to exclude a single function from provider.vpc (false, null and {} are all rejected). It worked in v3 only because config validation defaulted to warn.

Fix

Extend the function-level vpc schema to accept false/null in addition to the config object, matching the compile logic. The provider-level vpc schema is left unchanged.

Test

Added a regression test asserting vpc: false yields no VpcConfig (mirrors the existing vpc: null case). All vpc tests in the functions compile suite pass (10/10).

Function VPC opt-out (`vpc: false` or `vpc: null`) is honored by the compile
step (lib/plugins/aws/package/compile/functions.js), but the JSON schema only
accepted an object. With v4's default `configValidationMode: error`, this was
rejected with `vpc: must be object`, making it impossible to exclude a single
function from `provider.vpc` under strict validation.

Extend the function-level `vpc` schema to accept `false`/`null` in addition to
the config object, matching the compile logic. Add a regression test asserting
`vpc: false` yields no VpcConfig.
Reword the comment on the function `vpc` schema to make clear the change is
on the function-level field (opting a function out of the provider VPC), not
on `provider.vpc` itself.
@GrahamCampbell
GrahamCampbell self-requested a review July 21, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function-level vpc: false / vpc: null opt-out rejected by config validation in v4 (schema ↔ compile mismatch)

1 participant