Skip to content

Commit

Permalink
Add remaining properties
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbarthelet committed Sep 15, 2020
1 parent 3c42917 commit a2343bc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
22 changes: 5 additions & 17 deletions lib/plugins/aws/package/compile/functions/index.js
Expand Up @@ -338,10 +338,9 @@ class AwsCompileFunctions {
functionResource.Properties.FileSystemConfigs = [cfFileSystemConfig];
}

if (functionObject.reservedConcurrency || functionObject.reservedConcurrency === 0) {
// Try convert reservedConcurrency to integer
const reservedConcurrency = Number(functionObject.reservedConcurrency);
functionResource.Properties.ReservedConcurrentExecutions = reservedConcurrency;
if (functionObject.reservedConcurrency) {
functionResource.Properties.ReservedConcurrentExecutions =
functionObject.reservedConcurrency;
}

if (!functionObject.disableLogs) {
Expand All @@ -350,12 +349,9 @@ class AwsCompileFunctions {
].concat(functionResource.DependsOn || []);
}

if (functionObject.layers && Array.isArray(functionObject.layers)) {
if (functionObject.layers) {
functionResource.Properties.Layers = functionObject.layers;
} else if (
this.serverless.service.provider.layers &&
Array.isArray(this.serverless.service.provider.layers)
) {
} else if (this.serverless.service.provider.layers) {
functionResource.Properties.Layers = this.serverless.service.provider.layers;
}

Expand Down Expand Up @@ -585,14 +581,6 @@ class AwsCompileFunctions {
return BbPromise.each(allFunctions, functionName => this.compileFunction(functionName));
}

// helper functions
isArnRefGetAttOrImportValue(arn) {
return (
typeof arn === 'object' &&
Object.keys(arn).some(k => ['Ref', 'Fn::GetAtt', 'Fn::ImportValue'].includes(k))
);
}

cfLambdaFunctionTemplate() {
return {
Type: 'AWS::Lambda::Function',
Expand Down
39 changes: 33 additions & 6 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -292,6 +292,30 @@ class AwsProvider {
{ $ref: '#/definitions/awsCfGetAtt' },
],
},
awsLambdaVpcConfig: {
type: 'object',
properties: {
securityGroupIds: {
type: 'array',
items: {
type: 'string',
},
maxItems: 5,
},
subnetIds: {
type: 'array',
items: {
type: 'string',
},
maxItems: 16,
},
},
},
awsLambdaLayers: {
type: 'array',
items: { $ref: '#/definitions/awsArn' },
},
awsLambdaVersionning: { type: 'boolean' },
awsResourceTags: {
type: 'object',
patternProperties: {
Expand Down Expand Up @@ -404,6 +428,9 @@ class AwsProvider {
},
environment: { $ref: '#/definitions/awsLambdaEnvironment' },
role: { $ref: '#/definitions/awsLambdaRole' },
vpc: { $ref: '#/definitions/awsLambdaVpcConfig' },
layers: { $ref: '#/definitions/awsLambdaLayers' },
versionFunctions: { $ref: '#/definitions/awsLambdaVersionning' },
},
},
function: {
Expand Down Expand Up @@ -432,12 +459,12 @@ class AwsProvider {
tracing: { $ref: '#/definitions/awsLambdaTracing' },
environment: { $ref: '#/definitions/awsLambdaEnvironment' },
role: { $ref: '#/definitions/awsLambdaRole' },
vpc: {},
reservedConcurrency: {},
provisionedConcurrency: {},
disableLogs: {},
layers: {},
versionFunction: {},
vpc: { $ref: '#/definitions/awsLambdaVpcConfig' },
reservedConcurrency: { type: 'integer', minimum: 0 },
provisionedConcurrency: { type: 'integer', minimum: 0 },
disableLogs: { type: 'boolean' },
layers: { $ref: '#/definitions/awsLambdaLayers' },
versionFunction: { $ref: '#/definitions/awsLambdaVersionning' },
},
},
resources: {
Expand Down

0 comments on commit a2343bc

Please sign in to comment.