Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/plugins/aws/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,17 @@ class AwsProvider {
],
},
versionFunction: { $ref: '#/definitions/awsLambdaVersioning' },
vpc: { $ref: '#/definitions/awsLambdaVpcConfig' },
vpc: {
// Function-level opt-out: `false`/`null` exclude this function from
// the provider VPC. The compile step (package/compile/functions.js)
// already handles both, so this function-level schema must accept
// them too, otherwise strict validation rejects a valid opt-out.
anyOf: [
{ $ref: '#/definitions/awsLambdaVpcConfig' },
{ const: false },
{ type: 'null' },
],
},
httpApi: {
type: 'object',
properties: {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/lib/plugins/aws/package/compile/functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,10 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => {
vpc: null,
handler: 'index.handler',
},
vpcDisabled: {
vpc: false,
handler: 'index.handler',
},
},
},
});
Expand Down Expand Up @@ -2639,6 +2643,12 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => {
expect(Properties.VpcConfig).to.be.undefined;
});

it('should allow `functions[].vpc` set to `false` to opt out of `provider.vpc`', () => {
const Properties = cfResources[naming.getLambdaLogicalId('vpcDisabled')].Properties;

expect(Properties.VpcConfig).to.be.undefined;
});

it('should support `provider.tags`', () => {
const providerConfig = serviceConfig.provider;

Expand Down