mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
fix(AWS Deploy): Ensure vpc configuration on custom resources (#11985)
This commit is contained in:
parent
3afb71e39d
commit
f2d1e23f59
@ -179,6 +179,13 @@ async function addCustomResourceToService(awsProvider, resourceName, iamRoleStat
|
||||
};
|
||||
Resources[customResourceFunctionLogicalId] = customResourceFunction;
|
||||
|
||||
if (providerConfig.vpc && providerConfig.vpc.securityGroupIds && providerConfig.vpc.subnetIds) {
|
||||
customResourceFunction.Properties.VpcConfig = {
|
||||
SecurityGroupIds: providerConfig.vpc.securityGroupIds,
|
||||
SubnetIds: providerConfig.vpc.subnetIds,
|
||||
};
|
||||
}
|
||||
|
||||
if (customDeploymentRole) {
|
||||
customResourceFunction.Properties.Role = customDeploymentRole;
|
||||
} else {
|
||||
|
||||
@ -347,6 +347,33 @@ describe('#addCustomResourceToService()', () => {
|
||||
Resources.CustomDashresourceDashexistingDashs3LambdaFunction.Properties.FunctionName.length
|
||||
).to.be.below(65);
|
||||
});
|
||||
|
||||
it('should configure vpc configs for the custom resource lambda function if vpc is configured', async () => {
|
||||
const vpcConfig = {
|
||||
securityGroupIds: ['sg-0a0a0a0a'],
|
||||
subnetIds: ['subnet-01010101'],
|
||||
};
|
||||
const { cfTemplate } = await runServerless({
|
||||
fixture: 'api-gateway',
|
||||
command: 'package',
|
||||
configExt: {
|
||||
provider: {
|
||||
logs: {
|
||||
restApi: true,
|
||||
},
|
||||
vpc: vpcConfig,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const properties =
|
||||
cfTemplate.Resources.CustomDashresourceDashapigwDashcwDashroleLambdaFunction.Properties;
|
||||
|
||||
expect(properties.VpcConfig).to.deep.equal({
|
||||
SecurityGroupIds: ['sg-0a0a0a0a'],
|
||||
SubnetIds: ['subnet-01010101'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('test/unit/lib/plugins/aws/customResources/index.test.js', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user