Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AWS Lambda): Allow overriding provider VPC with no VPC on function #10060

Merged
merged 2 commits into from Oct 11, 2021

Conversation

HowManyOliversAreThere
Copy link
Contributor

Allows for specification of no VPC for a function, even if the provider has a VPC specified. To specify no VPC is to be used, a null value must be passed to vpc. This can be done via ~, null, or even leaving the line blank after vpc:. false can also be used for un-setting the VPC as this was discussed as an option in the ticket, however the documentation updates all refer to using ~ as the unified way of achieving this for the sake of consistency.

Closes: #4387

…ss#4387)

Allows for specification of no VPC for a function, even if the provider
has a VPC specified.
@HowManyOliversAreThere HowManyOliversAreThere changed the title feat(AWS Lambda): Allow overriding provider VPC with no VPC (#4387) feat(AWS Lambda): Allow overriding provider VPC with no VPC Oct 7, 2021
Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @HowManyOliversAreThere 🙇 Looks good in general, I have one suggestion related on how we should handle such case on CF level. Please let me know what do you think 🙇

it('should allow `functions[].vpc` to specify no vpc', () => {
const { VpcConfig } = cfResources[naming.getLambdaLogicalId('vpcNullify')].Properties;

expect(VpcConfig.SecurityGroupIds).to.deep.equal([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should take another approach here - in such cases the VpcConfig should not be defined at all on the CF resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, much neater approach! I've implemented this in 524faab

if (!functionObject.vpc) functionObject.vpc = {};
// ensure provider VPC is not used if function VPC explicitly unset
if (functionObject.vpc === null || functionObject.vpc === false) {
functionObject.vpc = { securityGroupIds: [], subnetIds: [] };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of that, let's change the logic so in such case, the whole VpcConfig property will be removed from functionResource.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in 524faab

@codecov
Copy link

codecov bot commented Oct 11, 2021

Codecov Report

Merging #10060 (524faab) into master (7c91cde) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10060      +/-   ##
==========================================
- Coverage   85.53%   85.41%   -0.13%     
==========================================
  Files         333      333              
  Lines       13473    13538      +65     
==========================================
+ Hits        11524    11563      +39     
- Misses       1949     1975      +26     
Impacted Files Coverage Δ
lib/plugins/aws/package/compile/functions.js 94.44% <100.00%> (+0.05%) ⬆️
lib/classes/CLI.js 60.00% <0.00%> (-31.43%) ⬇️
lib/plugins/create/create.js 85.71% <0.00%> (-3.48%) ⬇️
lib/plugins/standalone.js 40.74% <0.00%> (-2.40%) ⬇️
lib/plugins/aws/rollback.js 98.18% <0.00%> (-1.82%) ⬇️
lib/plugins/aws/package/compile/layers.js 84.21% <0.00%> (-0.74%) ⬇️
commands/plugin-uninstall.js 64.17% <0.00%> (-0.44%) ⬇️
commands/plugin-install.js 62.16% <0.00%> (-0.34%) ⬇️
lib/plugins/aws/invokeLocal/index.js 68.70% <0.00%> (-0.12%) ⬇️
lib/plugins/install.js 100.00% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c91cde...524faab. Read the comment docs.

Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you @HowManyOliversAreThere 🙇

@pgrzesik pgrzesik changed the title feat(AWS Lambda): Allow overriding provider VPC with no VPC feat(AWS Lambda): Allow overriding provider VPC with no VPC on function Oct 11, 2021
@pgrzesik pgrzesik merged commit 44a81fc into serverless:master Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override Global VPC configuration in function level to no VPC
2 participants