diff --git a/lib/classes/ConfigSchemaHandler/normalizeAjvErrors.js b/lib/classes/ConfigSchemaHandler/normalizeAjvErrors.js index b5ed52960..596149552 100644 --- a/lib/classes/ConfigSchemaHandler/normalizeAjvErrors.js +++ b/lib/classes/ConfigSchemaHandler/normalizeAjvErrors.js @@ -35,9 +35,9 @@ const filterIrreleventEventConfigurationErrors = (resultErrorsSet) => { delete eventEventTypeErrorsByTypeIndex.root; // 3.3 Resolve eventual type configuration errors for intended event type - const eventConfiguredEventTypeErrors = Object.entries( - eventEventTypeErrorsByTypeIndex - ).find(([, errors]) => errors.every(({ keyword }) => keyword !== 'required')); + const eventConfiguredEventTypeErrors = Object.entries(eventEventTypeErrorsByTypeIndex).find( + ([, errors]) => errors.every(({ keyword }) => keyword !== 'required') + ); if (!eventConfiguredEventTypeErrors) { // 3.4 If there are no event type configuration errors for intended event type diff --git a/lib/classes/Variables.js b/lib/classes/Variables.js index 8a5ec30c1..2431f7334 100644 --- a/lib/classes/Variables.js +++ b/lib/classes/Variables.js @@ -476,11 +476,14 @@ class Variables { match = quotedWordSyntax.exec(input); } const commaReplacements = []; - const contained = ( - commaMatch // curry the current commaMatch - ) => ( - stringMatch // check whether stringMatch containing the commaMatch - ) => stringMatch.start < commaMatch.index && this.overwriteSyntax.lastIndex < stringMatch.end; + const contained = + ( + commaMatch // curry the current commaMatch + ) => + ( + stringMatch // check whether stringMatch containing the commaMatch + ) => + stringMatch.start < commaMatch.index && this.overwriteSyntax.lastIndex < stringMatch.end; match = this.overwriteSyntax.exec(input); while (match) { const matchContained = contained(match); diff --git a/lib/cli/ensure-supported-command.js b/lib/cli/ensure-supported-command.js index 933fb921a..9ab32236a 100644 --- a/lib/cli/ensure-supported-command.js +++ b/lib/cli/ensure-supported-command.js @@ -25,14 +25,8 @@ const getCommandSuggestion = (command, commandsSchema) => { }; module.exports = (configuration = null) => { - const { - command, - options, - commandSchema, - commandsSchema, - isContainerCommand, - isHelpRequest, - } = resolveInput(); + const { command, options, commandSchema, commandsSchema, isContainerCommand, isHelpRequest } = + resolveInput(); if (!commandSchema && !isContainerCommand) { throw new ServerlessError( diff --git a/lib/cli/parse-args.js b/lib/cli/parse-args.js index 9b228f8a2..3b19fc5b3 100644 --- a/lib/cli/parse-args.js +++ b/lib/cli/parse-args.js @@ -4,7 +4,8 @@ const ServerlessError = require('../serverless-error'); -const paramRe = /^-(?:-(?[a-zA-Z][A-Za-z0-9:_-]+)|(?[a-z]+))(?:=(?.*)|$)/; +const paramRe = + /^-(?:-(?[a-zA-Z][A-Za-z0-9:_-]+)|(?[a-z]+))(?:=(?.*)|$)/; const isParamName = RegExp.prototype.test.bind(paramRe); module.exports = ( diff --git a/lib/plugins/aws/customResources/index.js b/lib/plugins/aws/customResources/index.js index ebdf1f130..fe8d78695 100644 --- a/lib/plugins/aws/customResources/index.js +++ b/lib/plugins/aws/customResources/index.js @@ -36,19 +36,24 @@ async function addCustomResourceToService(awsProvider, resourceName, iamRoleStat if (resourceName === 's3') { functionName = awsProvider.naming.getCustomResourceS3HandlerFunctionName(); Handler = 's3/handler.handler'; - customResourceFunctionLogicalId = awsProvider.naming.getCustomResourceS3HandlerFunctionLogicalId(); + customResourceFunctionLogicalId = + awsProvider.naming.getCustomResourceS3HandlerFunctionLogicalId(); } else if (resourceName === 'cognitoUserPool') { functionName = awsProvider.naming.getCustomResourceCognitoUserPoolHandlerFunctionName(); Handler = 'cognitoUserPool/handler.handler'; - customResourceFunctionLogicalId = awsProvider.naming.getCustomResourceCognitoUserPoolHandlerFunctionLogicalId(); + customResourceFunctionLogicalId = + awsProvider.naming.getCustomResourceCognitoUserPoolHandlerFunctionLogicalId(); } else if (resourceName === 'eventBridge') { functionName = awsProvider.naming.getCustomResourceEventBridgeHandlerFunctionName(); Handler = 'eventBridge/handler.handler'; - customResourceFunctionLogicalId = awsProvider.naming.getCustomResourceEventBridgeHandlerFunctionLogicalId(); + customResourceFunctionLogicalId = + awsProvider.naming.getCustomResourceEventBridgeHandlerFunctionLogicalId(); } else if (resourceName === 'apiGatewayCloudWatchRole') { - functionName = awsProvider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionName(); + functionName = + awsProvider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionName(); Handler = 'apiGatewayCloudWatchRole/handler.handler'; - customResourceFunctionLogicalId = awsProvider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionLogicalId(); + customResourceFunctionLogicalId = + awsProvider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionLogicalId(); } else { throw new ServerlessError( `No implementation found for Custom Resource "${resourceName}"`, diff --git a/lib/plugins/aws/customResources/resources/s3/lib/bucket.js b/lib/plugins/aws/customResources/resources/s3/lib/bucket.js index 8920eb186..41f84cd57 100644 --- a/lib/plugins/aws/customResources/resources/s3/lib/bucket.js +++ b/lib/plugins/aws/customResources/resources/s3/lib/bucket.js @@ -48,9 +48,10 @@ async function updateConfiguration(config) { return getConfiguration(config).then((NotificationConfiguration) => { // remove configurations for this specific function - NotificationConfiguration.LambdaFunctionConfigurations = NotificationConfiguration.LambdaFunctionConfigurations.filter( - (conf) => !conf.Id.startsWith(functionName) - ); + NotificationConfiguration.LambdaFunctionConfigurations = + NotificationConfiguration.LambdaFunctionConfigurations.filter( + (conf) => !conf.Id.startsWith(functionName) + ); // add the events to the existing NotificationConfiguration bucketConfigs.forEach((bucketConfig) => { @@ -84,9 +85,10 @@ async function removeConfiguration(config) { return getConfiguration(config).then((NotificationConfiguration) => { // remove configurations for this specific function - NotificationConfiguration.LambdaFunctionConfigurations = NotificationConfiguration.LambdaFunctionConfigurations.filter( - (conf) => !conf.Id.startsWith(functionName) - ); + NotificationConfiguration.LambdaFunctionConfigurations = + NotificationConfiguration.LambdaFunctionConfigurations.filter( + (conf) => !conf.Id.startsWith(functionName) + ); const payload = { Bucket, diff --git a/lib/plugins/aws/deployFunction.js b/lib/plugins/aws/deployFunction.js index 6e480616b..45545b9b3 100644 --- a/lib/plugins/aws/deployFunction.js +++ b/lib/plugins/aws/deployFunction.js @@ -89,8 +89,8 @@ class AwsDeployFunction { checkIfFunctionChangesBetweenImageAndHandler() { const functionObject = this.serverless.service.getFunction(this.options.function); - const remoteFunctionPackageType = this.serverless.service.provider.remoteFunctionData - .Configuration.PackageType; + const remoteFunctionPackageType = + this.serverless.service.provider.remoteFunctionData.Configuration.PackageType; if (functionObject.handler && remoteFunctionPackageType === 'Image') { throw new ServerlessError( @@ -171,8 +171,8 @@ class AwsDeployFunction { const functionObj = this.options.functionObj; const serviceObj = this.serverless.service.serviceObject; const providerObj = this.serverless.service.provider; - const remoteFunctionConfiguration = this.serverless.service.provider.remoteFunctionData - .Configuration; + const remoteFunctionConfiguration = + this.serverless.service.provider.remoteFunctionData.Configuration; const params = { FunctionName: functionObj.name, }; @@ -365,8 +365,8 @@ class AwsDeployFunction { const { functionImageUri, functionImageSha } = await this.provider.resolveImageUriAndSha( this.options.function ); - const remoteImageSha = this.serverless.service.provider.remoteFunctionData.Configuration - .CodeSha256; + const remoteImageSha = + this.serverless.service.provider.remoteFunctionData.Configuration.CodeSha256; if (remoteImageSha === functionImageSha && !this.options.force) { this.serverless.cli.log('Image did not change. Skipping function deployment.'); return; @@ -383,8 +383,8 @@ class AwsDeployFunction { const data = fs.readFileSync(artifactFilePath); - const remoteHash = this.serverless.service.provider.remoteFunctionData.Configuration - .CodeSha256; + const remoteHash = + this.serverless.service.provider.remoteFunctionData.Configuration.CodeSha256; const localHash = crypto.createHash('sha256').update(data).digest('base64'); if (remoteHash === localHash && !this.options.force) { diff --git a/lib/plugins/aws/invokeLocal/index.js b/lib/plugins/aws/invokeLocal/index.js index 11f38f1e4..43e2fb921 100644 --- a/lib/plugins/aws/invokeLocal/index.js +++ b/lib/plugins/aws/invokeLocal/index.js @@ -502,16 +502,11 @@ class AwsInvokeLocal { const envVarsDockerArgs = _.flatMap(envVars, (value, key) => ['--env', `${key}=${value}`]); const dockerArgsFromOptions = this.getDockerArgsFromOptions(); - const dockerArgs = [ - 'run', - '--rm', - '-v', - `${artifactPath}:/var/task:ro,delegated`, - ].concat(envVarsDockerArgs, dockerArgsFromOptions, [ - imageName, - handler, - JSON.stringify(this.options.data), - ]); + const dockerArgs = ['run', '--rm', '-v', `${artifactPath}:/var/task:ro,delegated`].concat( + envVarsDockerArgs, + dockerArgsFromOptions, + [imageName, handler, JSON.stringify(this.options.data)] + ); try { const { stdBuffer } = await spawnExt('docker', dockerArgs); diff --git a/lib/plugins/aws/package/compile/events/alb/lib/permissions.js b/lib/plugins/aws/package/compile/events/alb/lib/permissions.js index 3c705e7d1..c823c306c 100644 --- a/lib/plugins/aws/package/compile/events/alb/lib/permissions.js +++ b/lib/plugins/aws/package/compile/events/alb/lib/permissions.js @@ -8,12 +8,10 @@ module.exports = { this.validated.events.forEach((event) => { const { functionName, albId, multiValueHeaders } = event; - const albPermissionLogicalId = this.provider.naming.getLambdaAlbPermissionLogicalId( - functionName - ); - const registerTargetPermissionLogicalId = this.provider.naming.getLambdaRegisterTargetPermissionLogicalId( - functionName - ); + const albPermissionLogicalId = + this.provider.naming.getLambdaAlbPermissionLogicalId(functionName); + const registerTargetPermissionLogicalId = + this.provider.naming.getLambdaRegisterTargetPermissionLogicalId(functionName); const targetGroupLogicalId = this.provider.naming.getAlbTargetGroupLogicalId( functionName, albId, diff --git a/lib/plugins/aws/package/compile/events/alb/lib/targetGroups.js b/lib/plugins/aws/package/compile/events/alb/lib/targetGroups.js index 1b1e099e0..9fc9fda1a 100644 --- a/lib/plugins/aws/package/compile/events/alb/lib/targetGroups.js +++ b/lib/plugins/aws/package/compile/events/alb/lib/targetGroups.js @@ -28,9 +28,8 @@ module.exports = { albId, multiValueHeaders ); - const registerTargetPermissionLogicalId = this.provider.naming.getLambdaRegisterTargetPermissionLogicalId( - functionName - ); + const registerTargetPermissionLogicalId = + this.provider.naming.getLambdaRegisterTargetPermissionLogicalId(functionName); const healthCheckProperties = { HealthCheckEnabled: healthCheckDefaults.HealthCheckEnabled }; if (healthCheck) { diff --git a/lib/plugins/aws/package/compile/events/alexaSkill.js b/lib/plugins/aws/package/compile/events/alexaSkill.js index 49f689bfc..556ec9105 100644 --- a/lib/plugins/aws/package/compile/events/alexaSkill.js +++ b/lib/plugins/aws/package/compile/events/alexaSkill.js @@ -77,10 +77,11 @@ class AwsCompileAlexaSkillEvents { permissionTemplate.Properties.EventSourceToken = appId.replace(/\\n|\\r/g, ''); } - const lambdaPermissionLogicalId = this.provider.naming.getLambdaAlexaSkillPermissionLogicalId( - functionName, - alexaSkillNumberInFunction - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaAlexaSkillPermissionLogicalId( + functionName, + alexaSkillNumberInFunction + ); const permissionCloudForamtionResource = { [lambdaPermissionLogicalId]: permissionTemplate, diff --git a/lib/plugins/aws/package/compile/events/alexaSmartHome.js b/lib/plugins/aws/package/compile/events/alexaSmartHome.js index 910bbf4e4..c1d02993b 100644 --- a/lib/plugins/aws/package/compile/events/alexaSmartHome.js +++ b/lib/plugins/aws/package/compile/events/alexaSmartHome.js @@ -63,10 +63,11 @@ class AwsCompileAlexaSmartHomeEvents { }, }; - const lambdaPermissionLogicalId = this.provider.naming.getLambdaAlexaSmartHomePermissionLogicalId( - functionName, - alexaSmartHomeNumberInFunction - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaAlexaSmartHomePermissionLogicalId( + functionName, + alexaSmartHomeNumberInFunction + ); const permissionCloudFormationResource = { [lambdaPermissionLogicalId]: permissionTemplate, diff --git a/lib/plugins/aws/package/compile/events/apiGateway/index.js b/lib/plugins/aws/package/compile/events/apiGateway/index.js index 76606a2bf..96320d6f3 100644 --- a/lib/plugins/aws/package/compile/events/apiGateway/index.js +++ b/lib/plugins/aws/package/compile/events/apiGateway/index.js @@ -329,8 +329,8 @@ class AwsCompileApigEvents { // TODO should be removed once AWS fixes the removal via CloudFormation 'before:remove:remove': async () => { const globalValidate = require('../../../../lib/validate').validate; - const disassociateUsagePlan = require('./lib/hack/disassociateUsagePlan') - .disassociateUsagePlan; + const disassociateUsagePlan = + require('./lib/hack/disassociateUsagePlan').disassociateUsagePlan; return BbPromise.bind(this).then(globalValidate).then(disassociateUsagePlan); }, diff --git a/lib/plugins/aws/package/compile/events/apiGateway/lib/permissions.js b/lib/plugins/aws/package/compile/events/apiGateway/lib/permissions.js index 5fa0ed05c..7e62e244b 100644 --- a/lib/plugins/aws/package/compile/events/apiGateway/lib/permissions.js +++ b/lib/plugins/aws/package/compile/events/apiGateway/lib/permissions.js @@ -7,9 +7,8 @@ module.exports = { const cfResources = this.serverless.service.provider.compiledCloudFormationTemplate.Resources; this.permissionMapping.forEach( ({ lambdaLogicalId, lambdaAliasName, lambdaAliasLogicalId, event }) => { - const lambdaPermissionLogicalId = this.provider.naming.getLambdaApiGatewayPermissionLogicalId( - event.functionName - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaApiGatewayPermissionLogicalId(event.functionName); const functionArnGetter = { 'Fn::GetAtt': [lambdaLogicalId, 'Arn'] }; Object.assign(cfResources, { @@ -44,9 +43,8 @@ module.exports = { if (event.http.authorizer && event.http.authorizer.arn) { const authorizer = event.http.authorizer; - const authorizerPermissionLogicalId = this.provider.naming.getLambdaApiGatewayPermissionLogicalId( - authorizer.name - ); + const authorizerPermissionLogicalId = + this.provider.naming.getLambdaApiGatewayPermissionLogicalId(authorizer.name); if ( (authorizer.type || '').toUpperCase() === 'COGNITO_USER_POOLS' || diff --git a/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.js b/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.js index ae20a516a..0fd2b0c24 100644 --- a/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.js +++ b/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.js @@ -17,9 +17,10 @@ module.exports = { let validatorName; if (event.http.request && event.http.request.schemas) { - const template = this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ - methodLogicalId - ]; + const template = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ + methodLogicalId + ]; for (const [contentType, schemaConfig] of _.entries(event.http.request.schemas)) { let modelLogicalId; @@ -89,9 +90,10 @@ module.exports = { } } else if (event.http.request && event.http.request.schema) { // Old functionality - const template = this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ - methodLogicalId - ]; + const template = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ + methodLogicalId + ]; for (const [contentType, schema] of _.entries(event.http.request.schema)) { const modelLogicalId = this.provider.naming.getEndpointModelLogicalId( resourceName, @@ -180,17 +182,16 @@ module.exports = { const validatorName = `${ this.serverless.service.service }-${this.provider.getStage()} | Validate request body and querystring parameters`; - this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ - validatorLogicalId - ] = { - Type: 'AWS::ApiGateway::RequestValidator', - Properties: { - RestApiId: this.provider.getApiGatewayRestApiId(), - ValidateRequestBody: true, - ValidateRequestParameters: true, - Name: validatorName, - }, - }; + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[validatorLogicalId] = + { + Type: 'AWS::ApiGateway::RequestValidator', + Properties: { + RestApiId: this.provider.getApiGatewayRestApiId(), + ValidateRequestBody: true, + ValidateRequestParameters: true, + Name: validatorName, + }, + }; return { validatorLogicalId, validatorName, diff --git a/lib/plugins/aws/package/compile/events/cloudFront.js b/lib/plugins/aws/package/compile/events/cloudFront.js index bd51da252..c1bf44477 100644 --- a/lib/plugins/aws/package/compile/events/cloudFront.js +++ b/lib/plugins/aws/package/compile/events/cloudFront.js @@ -317,9 +317,11 @@ class AwsCompileCloudFrontEvents { } compileCloudFrontEvents() { - this.cloudFrontDistributionLogicalId = this.provider.naming.getCloudFrontDistributionLogicalId(); + this.cloudFrontDistributionLogicalId = + this.provider.naming.getCloudFrontDistributionLogicalId(); - this.cloudFrontDistributionDomainNameLogicalId = this.provider.naming.getCloudFrontDistributionDomainNameLogicalId(); + this.cloudFrontDistributionDomainNameLogicalId = + this.provider.naming.getCloudFrontDistributionDomainNameLogicalId(); const lambdaAtEdgeFunctions = []; @@ -582,9 +584,10 @@ class AwsCompileCloudFrontEvents { const lambdaInvokePermissions = lambdaAtEdgeFunctions.reduce( (permissions, lambdaAtEdgeFunction) => { - const invokePermissionName = this.provider.naming.getLambdaAtEdgeInvokePermissionLogicalId( - lambdaAtEdgeFunction.functionName - ); + const invokePermissionName = + this.provider.naming.getLambdaAtEdgeInvokePermissionLogicalId( + lambdaAtEdgeFunction.functionName + ); const invokePermission = { Type: 'AWS::Lambda::Permission', Properties: { @@ -628,9 +631,10 @@ class AwsCompileCloudFrontEvents { ) ); } else { - const lambdaAssumeStatement = Resources.IamRoleLambdaExecution.Properties.AssumeRolePolicyDocument.Statement.find( - (statement) => statement.Principal.Service.includes('lambda.amazonaws.com') - ); + const lambdaAssumeStatement = + Resources.IamRoleLambdaExecution.Properties.AssumeRolePolicyDocument.Statement.find( + (statement) => statement.Principal.Service.includes('lambda.amazonaws.com') + ); if (lambdaAssumeStatement) { lambdaAssumeStatement.Principal.Service.push('edgelambda.amazonaws.com'); } diff --git a/lib/plugins/aws/package/compile/events/cloudWatchEvent.js b/lib/plugins/aws/package/compile/events/cloudWatchEvent.js index 129991cbb..f55bc82e9 100644 --- a/lib/plugins/aws/package/compile/events/cloudWatchEvent.js +++ b/lib/plugins/aws/package/compile/events/cloudWatchEvent.js @@ -91,10 +91,11 @@ class AwsCompileCloudWatchEventEvents { functionName, cloudWatchEventNumberInFunction ); - const lambdaPermissionLogicalId = this.provider.naming.getLambdaCloudWatchEventPermissionLogicalId( - functionName, - cloudWatchEventNumberInFunction - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaCloudWatchEventPermissionLogicalId( + functionName, + cloudWatchEventNumberInFunction + ); const cloudWatchId = this.provider.naming.getCloudWatchEventId(functionName); const cloudWatchEventRuleTemplate = ` diff --git a/lib/plugins/aws/package/compile/events/cloudWatchLog.js b/lib/plugins/aws/package/compile/events/cloudWatchLog.js index d038f7722..f792178e9 100644 --- a/lib/plugins/aws/package/compile/events/cloudWatchLog.js +++ b/lib/plugins/aws/package/compile/events/cloudWatchLog.js @@ -69,9 +69,8 @@ class AwsCompileCloudWatchLogEvents { functionName, cloudWatchLogNumberInFunction ); - const lambdaPermissionLogicalId = this.provider.naming.getLambdaCloudWatchLogPermissionLogicalId( - functionName - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaCloudWatchLogPermissionLogicalId(functionName); // unescape quotes once when the first quote is detected escaped const idxFirstSlash = FilterPattern.indexOf('\\'); diff --git a/lib/plugins/aws/package/compile/events/cognitoUserPool.js b/lib/plugins/aws/package/compile/events/cognitoUserPool.js index a983fa5b1..34bafdace 100644 --- a/lib/plugins/aws/package/compile/events/cognitoUserPool.js +++ b/lib/plugins/aws/package/compile/events/cognitoUserPool.js @@ -97,11 +97,12 @@ class AwsCompileCognitoUserPoolEvents { }, }, }; - const lambdaPermissionLogicalId = this.provider.naming.getLambdaCognitoUserPoolPermissionLogicalId( - cognitoUserPoolTriggerFunction.functionName, - cognitoUserPoolTriggerFunction.poolName, - cognitoUserPoolTriggerFunction.triggerSource - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaCognitoUserPoolPermissionLogicalId( + cognitoUserPoolTriggerFunction.functionName, + cognitoUserPoolTriggerFunction.poolName, + cognitoUserPoolTriggerFunction.triggerSource + ); const permissionCFResource = { [lambdaPermissionLogicalId]: permissionTemplate, }; @@ -155,10 +156,10 @@ class AwsCompileCognitoUserPoolEvents { } const eventFunctionLogicalId = this.provider.naming.getLambdaLogicalId(functionName); - const customResourceFunctionLogicalId = this.provider.naming.getCustomResourceCognitoUserPoolHandlerFunctionLogicalId(); - const customPoolResourceLogicalId = this.provider.naming.getCustomResourceCognitoUserPoolResourceLogicalId( - functionName - ); + const customResourceFunctionLogicalId = + this.provider.naming.getCustomResourceCognitoUserPoolHandlerFunctionLogicalId(); + const customPoolResourceLogicalId = + this.provider.naming.getCustomResourceCognitoUserPoolResourceLogicalId(functionName); // store how often the custom Cognito User Pool resource is used if (poolResources[pool]) { diff --git a/lib/plugins/aws/package/compile/events/eventBridge/index.js b/lib/plugins/aws/package/compile/events/eventBridge/index.js index 8cc5846e9..482d74975 100644 --- a/lib/plugins/aws/package/compile/events/eventBridge/index.js +++ b/lib/plugins/aws/package/compile/events/eventBridge/index.js @@ -219,11 +219,10 @@ class AwsCompileEventBridgeEvents { } const eventFunctionLogicalId = this.provider.naming.getLambdaLogicalId(functionName); - const customResourceFunctionLogicalId = this.provider.naming.getCustomResourceEventBridgeHandlerFunctionLogicalId(); - const customEventBridgeResourceLogicalId = this.provider.naming.getCustomResourceEventBridgeResourceLogicalId( - functionName, - idx - ); + const customResourceFunctionLogicalId = + this.provider.naming.getCustomResourceEventBridgeHandlerFunctionLogicalId(); + const customEventBridgeResourceLogicalId = + this.provider.naming.getCustomResourceEventBridgeResourceLogicalId(functionName, idx); const customEventBridge = { Type: 'Custom::EventBridge', @@ -246,9 +245,8 @@ class AwsCompileEventBridgeEvents { }, }; - compiledCloudFormationTemplate.Resources[ - customEventBridgeResourceLogicalId - ] = customEventBridge; + compiledCloudFormationTemplate.Resources[customEventBridgeResourceLogicalId] = + customEventBridge; if (!hasEventBusesIamRoleStatement && eventBusName && eventBusName !== 'default') { iamRoleStatements.push({ @@ -349,9 +347,8 @@ class AwsCompileEventBridgeEvents { }; // If this stack is creating the event bus the rule must depend on it to ensure stack can be removed if (shouldCreateEventBus) { - eventRuleResource.DependsOn = this.provider.naming.getEventBridgeEventBusLogicalId( - eventBusName - ); + eventRuleResource.DependsOn = + this.provider.naming.getEventBridgeEventBusLogicalId(eventBusName); } const ruleNameLogicalIdStub = makeRuleName({ diff --git a/lib/plugins/aws/package/compile/events/httpApi.js b/lib/plugins/aws/package/compile/events/httpApi.js index 3abb18354..dc0fccaa1 100644 --- a/lib/plugins/aws/package/compile/events/httpApi.js +++ b/lib/plugins/aws/package/compile/events/httpApi.js @@ -266,9 +266,8 @@ class HttpApiEvents { } compileAuthorizerLambdaPermission({ functionName, functionArn, name, functionObject }) { - const authorizerPermissionLogicalId = this.provider.naming.getLambdaAuthorizerHttpApiPermissionLogicalId( - name - ); + const authorizerPermissionLogicalId = + this.provider.naming.getLambdaAuthorizerHttpApiPermissionLogicalId(name); const permissionResource = { Type: 'AWS::Lambda::Permission', Properties: { @@ -295,9 +294,8 @@ class HttpApiEvents { }; if (functionObject && functionObject.targetAlias) { - permissionResource.Properties.DependsOn = this.provider.naming.getLambdaLogicalId( - functionName - ); + permissionResource.Properties.DependsOn = + this.provider.naming.getLambdaLogicalId(functionName); } this.cfTemplate.Resources[authorizerPermissionLogicalId] = permissionResource; } @@ -536,10 +534,9 @@ Object.defineProperties( if (method === '*') { method = 'ANY'; if ( - Array.from( - allowedMethods, - (allowedMethod) => `${allowedMethod} ${path}` - ).some((duplicateRouteKey) => routes.has(duplicateRouteKey)) + Array.from(allowedMethods, (allowedMethod) => `${allowedMethod} ${path}`).some( + (duplicateRouteKey) => routes.has(duplicateRouteKey) + ) ) { throw new ServerlessError( `Duplicate method for "${path}" path in function ${functionName} for httpApi event in serverless.yml`, diff --git a/lib/plugins/aws/package/compile/events/iotFleetProvisioning.js b/lib/plugins/aws/package/compile/events/iotFleetProvisioning.js index 9e2cd30e4..b7e374076 100644 --- a/lib/plugins/aws/package/compile/events/iotFleetProvisioning.js +++ b/lib/plugins/aws/package/compile/events/iotFleetProvisioning.js @@ -42,12 +42,10 @@ class AwsCompileIotFleetProvisioningEvents { const templateBody = event.iotFleetProvisioning.templateBody; const lambdaLogicalId = this.provider.naming.getLambdaLogicalId(functionName); - const iotFleetProvisioningLogicalId = this.provider.naming.getIotFleetProvisioningLogicalId( - functionName - ); - const lambdaPermissionLogicalId = this.provider.naming.getLambdaIotFleetProvisioningPermissionLogicalId( - functionName - ); + const iotFleetProvisioningLogicalId = + this.provider.naming.getIotFleetProvisioningLogicalId(functionName); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaIotFleetProvisioningPermissionLogicalId(functionName); const provisioningTemplateResource = { Type: 'AWS::IoT::ProvisioningTemplate', diff --git a/lib/plugins/aws/package/compile/events/lib/ensureApiGatewayCloudWatchRole.js b/lib/plugins/aws/package/compile/events/lib/ensureApiGatewayCloudWatchRole.js index d0eef6b47..f1f166414 100644 --- a/lib/plugins/aws/package/compile/events/lib/ensureApiGatewayCloudWatchRole.js +++ b/lib/plugins/aws/package/compile/events/lib/ensureApiGatewayCloudWatchRole.js @@ -18,8 +18,10 @@ module.exports = memoize(async (provider) => } const cfTemplate = provider.serverless.service.provider.compiledCloudFormationTemplate; - const customResourceLogicalId = provider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleResourceLogicalId(); - const customResourceFunctionLogicalId = provider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionLogicalId(); + const customResourceLogicalId = + provider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleResourceLogicalId(); + const customResourceFunctionLogicalId = + provider.naming.getCustomResourceApiGatewayAccountCloudWatchRoleHandlerFunctionLogicalId(); cfTemplate.Resources[customResourceLogicalId] = { Type: 'Custom::ApiGatewayAccountRole', diff --git a/lib/plugins/aws/package/compile/events/s3/index.js b/lib/plugins/aws/package/compile/events/s3/index.js index b153f32a6..39f4b88ed 100644 --- a/lib/plugins/aws/package/compile/events/s3/index.js +++ b/lib/plugins/aws/package/compile/events/s3/index.js @@ -294,10 +294,10 @@ class AwsCompileS3Events { }); const eventFunctionLogicalId = this.provider.naming.getLambdaLogicalId(functionName); - const customResourceFunctionLogicalId = this.provider.naming.getCustomResourceS3HandlerFunctionLogicalId(); - const customS3ResourceLogicalId = this.provider.naming.getCustomResourceS3ResourceLogicalId( - functionName - ); + const customResourceFunctionLogicalId = + this.provider.naming.getCustomResourceS3HandlerFunctionLogicalId(); + const customS3ResourceLogicalId = + this.provider.naming.getCustomResourceS3ResourceLogicalId(functionName); // store how often the custom S3 resource is used if (bucketResources[bucket]) { diff --git a/lib/plugins/aws/package/compile/events/schedule.js b/lib/plugins/aws/package/compile/events/schedule.js index d7eacf02a..8d28861bd 100644 --- a/lib/plugins/aws/package/compile/events/schedule.js +++ b/lib/plugins/aws/package/compile/events/schedule.js @@ -121,10 +121,11 @@ class AwsCompileScheduledEvents { functionName, scheduleNumberInFunction ); - const lambdaPermissionLogicalId = this.provider.naming.getLambdaSchedulePermissionLogicalId( - functionName, - scheduleNumberInFunction - ); + const lambdaPermissionLogicalId = + this.provider.naming.getLambdaSchedulePermissionLogicalId( + functionName, + scheduleNumberInFunction + ); const scheduleId = this.provider.naming.getScheduleId(functionName); const scheduleTemplate = ` diff --git a/lib/plugins/aws/package/compile/events/sns.js b/lib/plugins/aws/package/compile/events/sns.js index 6e38c9a32..fec3d8477 100644 --- a/lib/plugins/aws/package/compile/events/sns.js +++ b/lib/plugins/aws/package/compile/events/sns.js @@ -103,11 +103,8 @@ class AwsCompileSNSEvents { } if (event.sns.redrivePolicy) { - const { - deadLetterTargetArn, - deadLetterTargetRef, - deadLetterTargetImport, - } = event.sns.redrivePolicy; + const { deadLetterTargetArn, deadLetterTargetRef, deadLetterTargetImport } = + event.sns.redrivePolicy; let targetArn; let targetUrl; diff --git a/lib/plugins/aws/package/compile/events/sqs.js b/lib/plugins/aws/package/compile/events/sqs.js index 0c3cdcdc9..5389ad2bb 100644 --- a/lib/plugins/aws/package/compile/events/sqs.js +++ b/lib/plugins/aws/package/compile/events/sqs.js @@ -72,9 +72,8 @@ class AwsCompileSQSEvents { const queueLogicalId = this.provider.naming.getQueueLogicalId(functionName, queueName); const dependsOn = []; - const functionIamRoleResourceName = this.provider.resolveFunctionIamRoleResourceName( - functionObj - ); + const functionIamRoleResourceName = + this.provider.resolveFunctionIamRoleResourceName(functionObj); if (functionIamRoleResourceName) { dependsOn.push(functionIamRoleResourceName); } @@ -117,8 +116,9 @@ class AwsCompileSQSEvents { this.serverless.service.provider.compiledCloudFormationTemplate.Resources .IamRoleLambdaExecution ) { - const statement = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources.IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; + const statement = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources + .IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; if (sqsStatement.Resource.length) { statement.push(sqsStatement); } diff --git a/lib/plugins/aws/package/compile/events/stream.js b/lib/plugins/aws/package/compile/events/stream.js index 34d18fff8..622206a59 100644 --- a/lib/plugins/aws/package/compile/events/stream.js +++ b/lib/plugins/aws/package/compile/events/stream.js @@ -188,9 +188,8 @@ class AwsCompileStreamEvents { ); const dependsOn = []; - const functionIamRoleResourceName = this.provider.resolveFunctionIamRoleResourceName( - functionObj - ); + const functionIamRoleResourceName = + this.provider.resolveFunctionIamRoleResourceName(functionObj); if (functionIamRoleResourceName) { dependsOn.push(functionIamRoleResourceName); } @@ -285,9 +284,8 @@ class AwsCompileStreamEvents { ConsumerName: consumerName, }, }; - const consumerLogicalId = this.provider.naming.getStreamConsumerLogicalId( - consumerName - ); + const consumerLogicalId = + this.provider.naming.getStreamConsumerLogicalId(consumerName); newStreamObject[consumerLogicalId] = consumerResource; if (Array.isArray(streamResource.DependsOn)) { streamResource.DependsOn.push(consumerLogicalId); @@ -318,8 +316,9 @@ class AwsCompileStreamEvents { this.serverless.service.provider.compiledCloudFormationTemplate.Resources .IamRoleLambdaExecution ) { - const statement = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources.IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; + const statement = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources + .IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; if (dynamodbStreamStatement.Resource.length) { statement.push(dynamodbStreamStatement); } diff --git a/lib/plugins/aws/package/compile/events/websockets/lib/api.js b/lib/plugins/aws/package/compile/events/websockets/lib/api.js index 6660e043e..b4c396383 100644 --- a/lib/plugins/aws/package/compile/events/websockets/lib/api.js +++ b/lib/plugins/aws/package/compile/events/websockets/lib/api.js @@ -30,8 +30,10 @@ module.exports = { }, }); - const defaultRoleResource = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources[this.provider.naming.getRoleLogicalId()]; + const defaultRoleResource = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ + this.provider.naming.getRoleLogicalId() + ]; if (defaultRoleResource) { // insert policy that allows functions to postToConnection diff --git a/lib/plugins/aws/package/compile/events/websockets/lib/deployment.js b/lib/plugins/aws/package/compile/events/websockets/lib/deployment.js index 2f0c17242..4b700fb7e 100644 --- a/lib/plugins/aws/package/compile/events/websockets/lib/deployment.js +++ b/lib/plugins/aws/package/compile/events/websockets/lib/deployment.js @@ -24,9 +24,8 @@ module.exports = { .createHash('sha256') .update(JSON.stringify(websocketsTemplatePart)) .digest('base64'); - this.websocketsDeploymentLogicalId = this.provider.naming.getWebsocketsDeploymentLogicalId( - cfTemplateHash - ); + this.websocketsDeploymentLogicalId = + this.provider.naming.getWebsocketsDeploymentLogicalId(cfTemplateHash); const resources = this.serverless.service.provider.compiledCloudFormationTemplate.Resources; _.merge(resources, { diff --git a/lib/plugins/aws/package/compile/events/websockets/lib/permissions.js b/lib/plugins/aws/package/compile/events/websockets/lib/permissions.js index c0cdfb859..69aca9a70 100644 --- a/lib/plugins/aws/package/compile/events/websockets/lib/permissions.js +++ b/lib/plugins/aws/package/compile/events/websockets/lib/permissions.js @@ -8,9 +8,8 @@ module.exports = { const websocketApiId = this.provider.getApiGatewayWebsocketApiId(); const lambdaLogicalId = this.provider.naming.getLambdaLogicalId(event.functionName); - const websocketsPermissionLogicalId = this.provider.naming.getLambdaWebsocketsPermissionLogicalId( - event.functionName - ); + const websocketsPermissionLogicalId = + this.provider.naming.getLambdaWebsocketsPermissionLogicalId(event.functionName); _.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources, { [websocketsPermissionLogicalId]: { @@ -27,9 +26,8 @@ module.exports = { }); if (event.authorizer) { - const websocketsAuthorizerPermissionLogicalId = this.provider.naming.getLambdaWebsocketsPermissionLogicalId( - event.authorizer.name - ); + const websocketsAuthorizerPermissionLogicalId = + this.provider.naming.getLambdaWebsocketsPermissionLogicalId(event.authorizer.name); const authorizerPermissionTemplate = { [websocketsAuthorizerPermissionLogicalId]: { diff --git a/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.js b/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.js index 2af12cb39..d7fbfc612 100644 --- a/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.js +++ b/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.js @@ -7,9 +7,8 @@ module.exports = { return; } - const websocketsRouteResponseLogicalId = this.provider.naming.getWebsocketsRouteResponseLogicalId( - event.route - ); + const websocketsRouteResponseLogicalId = + this.provider.naming.getWebsocketsRouteResponseLogicalId(event.route); const websocketsRouteLogicalId = this.provider.naming.getWebsocketsRouteLogicalId( event.route diff --git a/lib/plugins/aws/package/compile/functions.js b/lib/plugins/aws/package/compile/functions.js index f0af59a88..c4973abf1 100644 --- a/lib/plugins/aws/package/compile/functions.js +++ b/lib/plugins/aws/package/compile/functions.js @@ -533,9 +533,8 @@ class AwsCompileFunctions { Object.assign(cfTemplate.Resources, newVersionObject); // Add function versions to Outputs section - const functionVersionOutputLogicalId = this.provider.naming.getLambdaVersionOutputLogicalId( - functionName - ); + const functionVersionOutputLogicalId = + this.provider.naming.getLambdaVersionOutputLogicalId(functionName); const newVersionOutput = this.cfOutputLatestVersionTemplate(); newVersionOutput.Value = { Ref: versionLogicalId }; @@ -548,9 +547,8 @@ class AwsCompileFunctions { if (!shouldVersionFunction) delete versionResource.DeletionPolicy; const provisionedConcurrency = Number(functionObject.provisionedConcurrency); - const aliasLogicalId = this.provider.naming.getLambdaProvisionedConcurrencyAliasLogicalId( - functionName - ); + const aliasLogicalId = + this.provider.naming.getLambdaProvisionedConcurrencyAliasLogicalId(functionName); const aliasName = this.provider.naming.getLambdaProvisionedConcurrencyAliasName(); functionObject.targetAlias = { name: aliasName, logicalId: aliasLogicalId }; @@ -637,8 +635,9 @@ class AwsCompileFunctions { // Memoized in a constructor ensureTargetExecutionPermission(functionAddress) { - const iamPolicyStatements = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources.IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; + const iamPolicyStatements = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources + .IamRoleLambdaExecution.Properties.Policies[0].PolicyDocument.Statement; const action = (() => { if (!functionAddress.startsWith('arn:') || functionAddress.includes(':function:')) { diff --git a/lib/plugins/aws/package/compile/layers.js b/lib/plugins/aws/package/compile/layers.js index dff0f7af0..10a3d4d04 100644 --- a/lib/plugins/aws/package/compile/layers.js +++ b/lib/plugins/aws/package/compile/layers.js @@ -99,15 +99,13 @@ class AwsCompileLayers { newLayerOutput.Value = { Ref: layerLogicalId }; - const layerHashOutputLogicalId = this.provider.naming.getLambdaLayerHashOutputLogicalId( - layerName - ); + const layerHashOutputLogicalId = + this.provider.naming.getLambdaLayerHashOutputLogicalId(layerName); const newLayerHashOutput = this.cfOutputLayerHashTemplate(); newLayerHashOutput.Value = sha; - const layerS3KeyOutputLogicalId = this.provider.naming.getLambdaLayerS3KeyOutputLogicalId( - layerName - ); + const layerS3KeyOutputLogicalId = + this.provider.naming.getLambdaLayerS3KeyOutputLogicalId(layerName); const newLayerS3KeyOutput = this.cfOutputLayerS3KeyTemplate(); newLayerS3KeyOutput.Value = newLayer.Properties.Content.S3Key; @@ -121,25 +119,23 @@ class AwsCompileLayers { async compareWithLastLayer(layerName) { const stackName = this.provider.naming.getStackName(); - const layerHashOutputLogicalId = this.provider.naming.getLambdaLayerHashOutputLogicalId( - layerName - ); + const layerHashOutputLogicalId = + this.provider.naming.getLambdaLayerHashOutputLogicalId(layerName); return this.provider.request('CloudFormation', 'describeStacks', { StackName: stackName }).then( (data) => { const lastHash = data.Stacks[0].Outputs.find( (output) => output.OutputKey === layerHashOutputLogicalId ); - const compiledCloudFormationTemplate = this.serverless.service.provider - .compiledCloudFormationTemplate; + const compiledCloudFormationTemplate = + this.serverless.service.provider.compiledCloudFormationTemplate; const newSha = compiledCloudFormationTemplate.Outputs[layerHashOutputLogicalId].Value; if (lastHash == null || lastHash.OutputValue !== newSha) { return; } - const layerS3keyOutputLogicalId = this.provider.naming.getLambdaLayerS3KeyOutputLogicalId( - layerName - ); + const layerS3keyOutputLogicalId = + this.provider.naming.getLambdaLayerS3KeyOutputLogicalId(layerName); const lastS3Key = data.Stacks[0].Outputs.find( (output) => output.OutputKey === layerS3keyOutputLogicalId ); diff --git a/lib/plugins/aws/package/lib/generateCoreTemplate.js b/lib/plugins/aws/package/lib/generateCoreTemplate.js index 499132793..0b18c34b1 100644 --- a/lib/plugins/aws/package/lib/generateCoreTemplate.js +++ b/lib/plugins/aws/package/lib/generateCoreTemplate.js @@ -6,16 +6,17 @@ const ServerlessError = require('../../../../serverless-error'); module.exports = { generateCoreTemplate() { - this.serverless.service.provider.compiledCloudFormationTemplate = this.serverless.utils.readFileSync( - path.join( - this.serverless.config.serverlessPath, - 'plugins', - 'aws', - 'package', - 'lib', - 'core-cloudformation-template.json' - ) - ); + this.serverless.service.provider.compiledCloudFormationTemplate = + this.serverless.utils.readFileSync( + path.join( + this.serverless.config.serverlessPath, + 'plugins', + 'aws', + 'package', + 'lib', + 'core-cloudformation-template.json' + ) + ); const bucketName = this.serverless.service.provider.deploymentBucket; @@ -60,7 +61,8 @@ module.exports = { } if (deploymentBucketObject.skipPolicySetup) { - const deploymentBucketPolicyLogicalId = this.provider.naming.getDeploymentBucketPolicyLogicalId(); + const deploymentBucketPolicyLogicalId = + this.provider.naming.getDeploymentBucketPolicyLogicalId(); delete this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ deploymentBucketPolicyLogicalId ]; @@ -86,7 +88,8 @@ module.exports = { } this.bucketName = bucketName; this.serverless.service.package.deploymentBucket = bucketName; - this.serverless.service.provider.compiledCloudFormationTemplate.Outputs.ServerlessDeploymentBucketName.Value = bucketName; + this.serverless.service.provider.compiledCloudFormationTemplate.Outputs.ServerlessDeploymentBucketName.Value = + bucketName; delete this.serverless.service.provider.compiledCloudFormationTemplate.Resources .ServerlessDeploymentBucket; @@ -107,9 +110,10 @@ module.exports = { } ); // keep track of acceleration status via CloudFormation Output - this.serverless.service.provider.compiledCloudFormationTemplate.Outputs.ServerlessDeploymentBucketAccelerated = { - Value: true, - }; + this.serverless.service.provider.compiledCloudFormationTemplate.Outputs.ServerlessDeploymentBucketAccelerated = + { + Value: true, + }; } else if (isS3TransferAccelerationDisabled && isS3TransferAccelerationSupported) { // explicitly disable acceleration via CloudFormation Object.assign( diff --git a/lib/plugins/aws/package/lib/mergeIamTemplates.js b/lib/plugins/aws/package/lib/mergeIamTemplates.js index 54aaa7666..e0bf88aec 100644 --- a/lib/plugins/aws/package/lib/mergeIamTemplates.js +++ b/lib/plugins/aws/package/lib/mergeIamTemplates.js @@ -86,10 +86,12 @@ module.exports = { } else if (iamRole.permissionBoundary) { iamRoleLambdaExecutionTemplate.Properties.PermissionsBoundary = iamRole.permissionBoundary; } else if (this.serverless.service.provider.rolePermissionsBoundary) { - iamRoleLambdaExecutionTemplate.Properties.PermissionsBoundary = this.serverless.service.provider.rolePermissionsBoundary; + iamRoleLambdaExecutionTemplate.Properties.PermissionsBoundary = + this.serverless.service.provider.rolePermissionsBoundary; } - iamRoleLambdaExecutionTemplate.Properties.Policies[0].PolicyName = this.provider.naming.getPolicyName(); + iamRoleLambdaExecutionTemplate.Properties.Policies[0].PolicyName = + this.provider.naming.getPolicyName(); _.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources, { [this.provider.naming.getRoleLogicalId()]: iamRoleLambdaExecutionTemplate, @@ -100,19 +102,18 @@ module.exports = { }-${this.provider.getStage()}`; const logGroupsPrefix = this.provider.naming.getLogGroupName(canonicalFunctionNamePrefix); - const policyDocumentStatements = this.serverless.service.provider.compiledCloudFormationTemplate - .Resources[this.provider.naming.getRoleLogicalId()].Properties.Policies[0].PolicyDocument - .Statement; + const policyDocumentStatements = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ + this.provider.naming.getRoleLogicalId() + ].Properties.Policies[0].PolicyDocument.Statement; let hasOneOrMoreCanonicallyNamedFunctions = false; const disableLogsCanonicallyNamedFunctions = []; // Ensure policies for functions with custom name resolution this.serverless.service.getAllFunctions().forEach((functionName) => { - const { - name: resolvedFunctionName, - disableLogs: areLogsDisabled, - } = this.serverless.service.getFunction(functionName); + const { name: resolvedFunctionName, disableLogs: areLogsDisabled } = + this.serverless.service.getFunction(functionName); if (!resolvedFunctionName || resolvedFunctionName.startsWith(canonicalFunctionNamePrefix)) { if (areLogsDisabled) { disableLogsCanonicallyNamedFunctions.push(resolvedFunctionName); @@ -123,9 +124,8 @@ module.exports = { } if (!areLogsDisabled) { - const customFunctionNamelogGroupsPrefix = this.provider.naming.getLogGroupName( - resolvedFunctionName - ); + const customFunctionNamelogGroupsPrefix = + this.provider.naming.getLogGroupName(resolvedFunctionName); policyDocumentStatements[0].Resource.push({ 'Fn::Sub': @@ -214,9 +214,10 @@ module.exports = { mergeManagedPolicies(managedPolicies) { if (!managedPolicies.length) return; - const resource = this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ - this.provider.naming.getRoleLogicalId() - ].Properties; + const resource = + this.serverless.service.provider.compiledCloudFormationTemplate.Resources[ + this.provider.naming.getRoleLogicalId() + ].Properties; if (!Array.isArray(resource.ManagedPolicyArns)) { resource.ManagedPolicyArns = []; } diff --git a/package.json b/package.json index 5554ced07..be0b92a5b 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "mock-require": "^3.0.3", "nyc": "^15.1.0", "pkg": "^4.5.1", - "prettier": "^2.2.1", + "prettier": "^2.3.0", "process-utils": "^4.0.0", "proxyquire": "^2.1.3", "semver-regex": "^3.1.2", diff --git a/scripts/serverless.js b/scripts/serverless.js index 48e8b89f8..7ea979145 100755 --- a/scripts/serverless.js +++ b/scripts/serverless.js @@ -415,9 +415,8 @@ const processSpanPromise = (async () => { { providerName: providerName || 'aws', configuration } ); resolveInput.clear(); - ({ command, commands, options, isHelpRequest, commandSchema } = resolveInput( - commandsSchema - )); + ({ command, commands, options, isHelpRequest, commandSchema } = + resolveInput(commandsSchema)); serverless.processedInput.commands = serverless.pluginManager.cliCommands = commands; serverless.processedInput.options = serverless.pluginManager.cliOptions = options; hasFinalCommandSchema = true; @@ -479,9 +478,8 @@ const processSpanPromise = (async () => { } // Register serverless instance and AWS provider specific variable sources - resolverConfiguration.sources.sls = require('../lib/configuration/variables/sources/instance-dependent/get-sls')( - serverless - ); + resolverConfiguration.sources.sls = + require('../lib/configuration/variables/sources/instance-dependent/get-sls')(serverless); resolverConfiguration.fulfilledSources.add('sls'); if (providerName === 'aws') { @@ -580,9 +578,8 @@ const processSpanPromise = (async () => { } // Report unrecognized variable sources found in variables configured in service config - const unresolvedSources = require('../lib/configuration/variables/resolve-unresolved-source-types')( - variablesMeta - ); + const unresolvedSources = + require('../lib/configuration/variables/resolve-unresolved-source-types')(variablesMeta); if (!(configuration.variablesResolutionMode >= 20210326)) { unresolvedSources.delete('opt'); const legacyCfVarPropertyPaths = new Set(); diff --git a/test/unit/lib/classes/ConfigSchemaHandler/index.test.js b/test/unit/lib/classes/ConfigSchemaHandler/index.test.js index d1054c7bf..91cdb9ef9 100644 --- a/test/unit/lib/classes/ConfigSchemaHandler/index.test.js +++ b/test/unit/lib/classes/ConfigSchemaHandler/index.test.js @@ -131,11 +131,12 @@ describe('ConfigSchemaHandler', () => { command: 'info', }); - const existingEventDefinition = serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ - FUNCTION_NAME_PATTERN - ].properties.events.items.anyOf.find( - (definition) => definition.required[0] === 'existingEvent' - ).properties.existingEvent; + const existingEventDefinition = + serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ + FUNCTION_NAME_PATTERN + ].properties.events.items.anyOf.find( + (definition) => definition.required[0] === 'existingEvent' + ).properties.existingEvent; expect(existingEventDefinition.properties).to.have.deep.property( 'somePluginAdditionalEventProp', @@ -152,11 +153,12 @@ describe('ConfigSchemaHandler', () => { command: 'info', }); - const existingEventDefinition = serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ - FUNCTION_NAME_PATTERN - ].properties.events.items.anyOf.find( - (definition) => definition.required[0] === 'existingComplexEvent' - ).properties.existingComplexEvent; + const existingEventDefinition = + serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ + FUNCTION_NAME_PATTERN + ].properties.events.items.anyOf.find( + (definition) => definition.required[0] === 'existingComplexEvent' + ).properties.existingComplexEvent; expect(existingEventDefinition).to.deep.equal({ anyOf: [ diff --git a/test/unit/lib/plugins/aws/deploy/index.test.js b/test/unit/lib/plugins/aws/deploy/index.test.js index 301ce7ffa..023b921e8 100644 --- a/test/unit/lib/plugins/aws/deploy/index.test.js +++ b/test/unit/lib/plugins/aws/deploy/index.test.js @@ -400,16 +400,14 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { const listObjectsV2Stub = sinon.stub().resolves({ Contents: [ { - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', LastModified: new Date(), ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', Size: 356, StorageClass: 'STANDARD', }, { - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', LastModified: new Date(), ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', Size: 356, @@ -421,8 +419,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { s3HeadObjectStub .withArgs({ Bucket: 's3-bucket-resource', - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', }) .returns({ Metadata: { filesha256: 'qxp+iwSTMhcRUfHzka4AE4XAWawS8GnEyBh1WpGb7Vw=' }, @@ -430,8 +427,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { s3HeadObjectStub .withArgs({ Bucket: 's3-bucket-resource', - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', }) .returns({ Metadata: { filesha256: 'T0qEYHOE4Xv2E8Ar03xGogAlElcdf/dQh/lh9ao7Glo=' }, diff --git a/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js b/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js index 3fcd3ecf5..c4a8cc1d1 100644 --- a/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js +++ b/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js @@ -601,8 +601,7 @@ describe('checkForChanges #2', () => { listObjectsV2: { Contents: [ { - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/artifact.zip', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/artifact.zip', LastModified: new Date(), ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', Size: 356, @@ -1041,8 +1040,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { headObjectStub .withArgs({ Bucket: 'deployment-bucket', - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', }) .returns({ Metadata: { filesha256: 'pZOdrt6qijT7ITsLQjPP9QwgMAfKA2RuUUSTW+l8wWs=' }, @@ -1051,8 +1049,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { headObjectStub .withArgs({ Bucket: 'deployment-bucket', - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', }) .returns({ Metadata: { filesha256: 'T0qEYHOE4Xv2E8Ar03xGogAlElcdf/dQh/lh9ao7Glo=' }, @@ -1063,16 +1060,14 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { listObjectsV2: { Contents: [ { - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json', LastModified: new Date(), ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', Size: 356, StorageClass: 'STANDARD', }, { - Key: - 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', + Key: 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip', LastModified: new Date(), ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', Size: 356, diff --git a/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js b/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js index e0b61a30c..48d648893 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js @@ -355,62 +355,63 @@ describe('AwsCompileCloudFrontEvents', () => { ], }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', - }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, - }, - }, - IamRoleLambdaExecution: { - Type: 'AWS::IAM::Role', - Properties: { - AssumeRolePolicyDocument: { - Version: '2012-10-17', - Statement: [ - { - Effect: 'Allow', - Principal: { - Service: ['lambda.amazonaws.com'], - }, - Action: ['sts:AssumeRole'], - }, - ], + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', }, - Policies: [ - { - PolicyName: { - 'Fn::Join': ['-', ['dev', 'first', 'lambda']], - }, - PolicyDocument: { - Version: '2012-10-17', - Statement: [], - }, - }, - ], - Path: '/', - RoleName: { - 'Fn::Join': [ - '-', - [ - 'first', - 'dev', + }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, + }, + IamRoleLambdaExecution: { + Type: 'AWS::IAM::Role', + Properties: { + AssumeRolePolicyDocument: { + Version: '2012-10-17', + Statement: [ { - Ref: 'AWS::Region', + Effect: 'Allow', + Principal: { + Service: ['lambda.amazonaws.com'], + }, + Action: ['sts:AssumeRole'], }, - 'lambdaRole', ], + }, + Policies: [ + { + PolicyName: { + 'Fn::Join': ['-', ['dev', 'first', 'lambda']], + }, + PolicyDocument: { + Version: '2012-10-17', + Statement: [], + }, + }, ], + Path: '/', + RoleName: { + 'Fn::Join': [ + '-', + [ + 'first', + 'dev', + { + Ref: 'AWS::Region', + }, + 'lambdaRole', + ], + ], + }, }, }, - }, - }; + }; expect(() => awsCompileCloudFrontEvents.compileCloudFrontEvents()).to.throw( /to the us-east-1 region/ @@ -431,62 +432,63 @@ describe('AwsCompileCloudFrontEvents', () => { ], }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', - }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, - }, - }, - IamRoleLambdaExecution: { - Type: 'AWS::IAM::Role', - Properties: { - AssumeRolePolicyDocument: { - Version: '2012-10-17', - Statement: [ - { - Effect: 'Allow', - Principal: { - Service: ['lambda.amazonaws.com'], - }, - Action: ['sts:AssumeRole'], - }, - ], + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', }, - Policies: [ - { - PolicyName: { - 'Fn::Join': ['-', ['dev', 'first', 'lambda']], - }, - PolicyDocument: { - Version: '2012-10-17', - Statement: [], - }, - }, - ], - Path: '/', - RoleName: { - 'Fn::Join': [ - '-', - [ - 'first', - 'dev', + }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, + }, + IamRoleLambdaExecution: { + Type: 'AWS::IAM::Role', + Properties: { + AssumeRolePolicyDocument: { + Version: '2012-10-17', + Statement: [ { - Ref: 'AWS::Region', + Effect: 'Allow', + Principal: { + Service: ['lambda.amazonaws.com'], + }, + Action: ['sts:AssumeRole'], }, - 'lambdaRole', ], + }, + Policies: [ + { + PolicyName: { + 'Fn::Join': ['-', ['dev', 'first', 'lambda']], + }, + PolicyDocument: { + Version: '2012-10-17', + Statement: [], + }, + }, ], + Path: '/', + RoleName: { + 'Fn::Join': [ + '-', + [ + 'first', + 'dev', + { + Ref: 'AWS::Region', + }, + 'lambdaRole', + ], + ], + }, }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -607,20 +609,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -677,20 +680,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -744,14 +748,15 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -807,20 +812,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -863,14 +869,15 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -936,20 +943,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1001,20 +1009,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - }; + }; expect(() => { awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1048,32 +1057,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1134,20 +1144,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1213,32 +1224,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1321,32 +1333,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; expect(() => { awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1382,32 +1395,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1464,20 +1478,21 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - }; + }; awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1532,32 +1547,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; expect(() => { awsCompileCloudFrontEvents.compileCloudFrontEvents(); @@ -1592,32 +1608,33 @@ describe('AwsCompileCloudFrontEvents', () => { }, }; - awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - FirstLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'first', + awsCompileCloudFrontEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + FirstLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'first', + }, }, - }, - FirstLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'FirstLambdaFunction' }, + FirstLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'FirstLambdaFunction' }, + }, }, - }, - SecondLambdaFunction: { - Type: 'AWS::Lambda::Function', - Properties: { - FunctionName: 'second', + SecondLambdaFunction: { + Type: 'AWS::Lambda::Function', + Properties: { + FunctionName: 'second', + }, }, - }, - SecondLambdaVersion: { - Type: 'AWS::Lambda::Version', - Properties: { - FunctionName: { Ref: 'SecondLambdaFunction' }, + SecondLambdaVersion: { + Type: 'AWS::Lambda::Version', + Properties: { + FunctionName: { Ref: 'SecondLambdaFunction' }, + }, }, - }, - }; + }; expect(() => { awsCompileCloudFrontEvents.compileCloudFrontEvents(); diff --git a/test/unit/lib/plugins/aws/package/compile/events/cognitoUserPool.test.js b/test/unit/lib/plugins/aws/package/compile/events/cognitoUserPool.test.js index fe379bdb4..a920b1dfc 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/cognitoUserPool.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/cognitoUserPool.test.js @@ -295,9 +295,9 @@ describe('AwsCompileCognitoUserPoolEvents', () => { return expect( awsCompileCognitoUserPoolEvents.existingCognitoUserPools() ).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileCognitoUserPoolEvents.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileCognitoUserPoolEvents.serverless.service.provider + .compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('cognitoUserPool'); @@ -377,9 +377,9 @@ describe('AwsCompileCognitoUserPoolEvents', () => { return expect( awsCompileCognitoUserPoolEvents.existingCognitoUserPools() ).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileCognitoUserPoolEvents.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileCognitoUserPoolEvents.serverless.service.provider + .compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('cognitoUserPool'); @@ -491,9 +491,9 @@ describe('AwsCompileCognitoUserPoolEvents', () => { return expect( awsCompileCognitoUserPoolEvents.existingCognitoUserPools() ).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileCognitoUserPoolEvents.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileCognitoUserPoolEvents.serverless.service.provider + .compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('cognitoUserPool'); diff --git a/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js index 692e6f1e8..9a49fd8e9 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js @@ -156,9 +156,8 @@ describe('EventBridgeEvents', () => { it('should create the correct policy Statement', () => { const roleId = naming.getCustomResourcesRoleLogicalId('default', '12345'); - const [firstStatement, secondStatement, thirdStatment] = cfResources[ - roleId - ].Properties.Policies[0].PolicyDocument.Statement; + const [firstStatement, secondStatement, thirdStatment] = + cfResources[roleId].Properties.Policies[0].PolicyDocument.Statement; expect(firstStatement.Effect).to.be.eq('Allow'); expect(firstStatement.Resource['Fn::Join'][1]).to.deep.include('arn'); expect(firstStatement.Resource['Fn::Join'][1]).to.deep.include('events'); diff --git a/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js b/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js index 192f5d024..78cbd654b 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js @@ -462,9 +462,8 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }); it('should create permission resource when authorizer references function from service', () => { - const authorizerPermissionLogicalId = naming.getLambdaAuthorizerHttpApiPermissionLogicalId( - 'someAuthorizer' - ); + const authorizerPermissionLogicalId = + naming.getLambdaAuthorizerHttpApiPermissionLogicalId('someAuthorizer'); expect(cfResources[authorizerPermissionLogicalId]).to.deep.equal({ Type: 'AWS::Lambda::Permission', Properties: { diff --git a/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js index a032d8738..d1be3db41 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js @@ -373,9 +373,8 @@ describe('AwsCompileS3Events', () => { }; return expect(awsCompileS3Events.existingS3Buckets()).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('s3'); @@ -458,9 +457,8 @@ describe('AwsCompileS3Events', () => { }; return expect(awsCompileS3Events.existingS3Buckets()).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('s3'); @@ -564,9 +562,8 @@ describe('AwsCompileS3Events', () => { }; return expect(awsCompileS3Events.existingS3Buckets()).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; expect(addCustomResourceToServiceStub).to.have.been.calledOnce; expect(addCustomResourceToServiceStub.args[0][1]).to.equal('s3'); @@ -745,9 +742,8 @@ describe('AwsCompileS3Events', () => { }; return expect(awsCompileS3Events.existingS3Buckets()).to.be.fulfilled.then(() => { - const { - Resources, - } = awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; + const { Resources } = + awsCompileS3Events.serverless.service.provider.compiledCloudFormationTemplate; expect(Object.keys(Resources)).to.have.length(2); expect(Resources.FirstCustomS31).to.deep.equal({ @@ -872,9 +868,10 @@ describe('AwsCompileS3Events', () => { '*', ]; - const lambdaPermissionsPolicies = cfTemplate.Resources.IamRoleCustomResourcesLambdaExecution.Properties.Policies[ - '0' - ].PolicyDocument.Statement.filter((x) => x.Action[0].includes('AddPermission')); + const lambdaPermissionsPolicies = + cfTemplate.Resources.IamRoleCustomResourcesLambdaExecution.Properties.Policies[ + '0' + ].PolicyDocument.Statement.filter((x) => x.Action[0].includes('AddPermission')); expect(lambdaPermissionsPolicies).to.have.length(1); diff --git a/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js b/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js index 3124cc030..8f49098b3 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js @@ -50,7 +50,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileSQSEvents.compileSQSEvents(); @@ -74,7 +75,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileSQSEvents.compileSQSEvents(); @@ -107,7 +109,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileSQSEvents.compileSQSEvents(); @@ -140,7 +143,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileSQSEvents.compileSQSEvents(); @@ -171,7 +175,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileSQSEvents.serverless.service.provider.role = 'arn:aws:iam::account:role/foo'; @@ -205,7 +210,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileSQSEvents.compileSQSEvents(); @@ -233,7 +239,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileSQSEvents.serverless.service.provider.role = { 'Fn::GetAtt': [roleLogicalId, 'Arn'], @@ -269,7 +276,8 @@ describe('AwsCompileSQSEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileSQSEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileSQSEvents.serverless.service.provider.role = roleLogicalId; diff --git a/test/unit/lib/plugins/aws/package/compile/events/stream.test.js b/test/unit/lib/plugins/aws/package/compile/events/stream.test.js index af2404dd7..910e424d6 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/stream.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/stream.test.js @@ -97,7 +97,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -122,7 +123,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -156,7 +158,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -186,7 +189,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -214,7 +218,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileStreamEvents.serverless.service.provider.role = 'arn:aws:iam::account:role/foo'; @@ -249,7 +254,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -278,7 +284,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; expect(() => { awsCompileStreamEvents.compileStreamEvents(); @@ -307,7 +314,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileStreamEvents.serverless.service.provider.role = { 'Fn::GetAtt': [roleLogicalId, 'Arn'], @@ -340,7 +348,8 @@ describe('AwsCompileStreamEvents', () => { }; // pretend that the default IamRoleLambdaExecution is not in place - awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = null; + awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + null; awsCompileStreamEvents.serverless.service.provider.role = roleLogicalId; diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js index ea87b8258..c11588e8b 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js @@ -18,19 +18,20 @@ describe('#compileApi()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); roleLogicalId = awsCompileWebsocketsEvents.provider.naming.getRoleLogicalId(); - awsCompileWebsocketsEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = { - [roleLogicalId]: { - Properties: { - Policies: [ - { - PolicyDocument: { - Statement: [], + awsCompileWebsocketsEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + { + [roleLogicalId]: { + Properties: { + Policies: [ + { + PolicyDocument: { + Statement: [], + }, }, - }, - ], + ], + }, }, - }, - }; + }; }); it('should create a websocket api resource', () => { @@ -90,7 +91,8 @@ describe('#compileApi()', () => { }); it('should NOT add the websockets policy if role resource does not exist', () => { - awsCompileWebsocketsEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = {}; + awsCompileWebsocketsEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources = + {}; awsCompileWebsocketsEvents.compileApi(); const resources = diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/authorizers.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/authorizers.test.js index 9cf51b2bf..1c5da2675 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/authorizers.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/authorizers.test.js @@ -16,7 +16,8 @@ describe('#compileAuthorizers()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); awsCompileWebsocketsEvents.validated = { events: [ @@ -111,7 +112,8 @@ describe('#compileAuthorizers()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); awsCompileWebsocketsEvents.validated = { events: [ diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/deployment.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/deployment.test.js index b1cb4c040..4b1c1f4e8 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/deployment.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/deployment.test.js @@ -22,7 +22,8 @@ describe('#compileDeployment()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless, options); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create a deployment resource and output', () => { diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/integrations.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/integrations.test.js index de54f104b..e62461012 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/integrations.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/integrations.test.js @@ -15,7 +15,8 @@ describe('#compileIntegrations()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create an integration resource for every event', () => { diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/permissions.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/permissions.test.js index 93100ee59..bdda60143 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/permissions.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/permissions.test.js @@ -15,7 +15,8 @@ describe('#compilePermissions()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create a permission resource for every event', () => { diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.test.js index 1c6cf4820..535161a32 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routeResponses.test.js @@ -15,7 +15,8 @@ describe('#compileRouteResponses()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create a RouteResponse resource for events with selection expression', () => { diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routes.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routes.test.js index 23d99e820..95c64247e 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routes.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/routes.test.js @@ -15,7 +15,8 @@ describe('#compileRoutes()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create a route resource for every event', () => { diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/stage.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/stage.test.js index 2b07e6df5..89c5fd3a1 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/stage.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/stage.test.js @@ -34,7 +34,8 @@ describe('#compileStage()', () => { awsCompileWebsocketsEvents = new AwsCompileWebsocketsEvents(serverless, options); stageLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsStageLogicalId(); logGroupLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsLogGroupLogicalId(); - awsCompileWebsocketsEvents.websocketsApiLogicalId = awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); + awsCompileWebsocketsEvents.websocketsApiLogicalId = + awsCompileWebsocketsEvents.provider.naming.getWebsocketsApiLogicalId(); }); it('should create a stage resource if no websocketApiId specified', () => diff --git a/test/unit/lib/plugins/aws/package/compile/functions.test.js b/test/unit/lib/plugins/aws/package/compile/functions.test.js index b787974cb..ee9af17e9 100644 --- a/test/unit/lib/plugins/aws/package/compile/functions.test.js +++ b/test/unit/lib/plugins/aws/package/compile/functions.test.js @@ -450,17 +450,18 @@ describe('AwsCompileFunctions', () => { describe('when IamRoleLambdaExecution is used', () => { beforeEach(() => { // pretend that the IamRoleLambdaExecution is used - awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = { - Properties: { - Policies: [ - { - PolicyDocument: { - Statement: [], + awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + { + Properties: { + Policies: [ + { + PolicyDocument: { + Statement: [], + }, }, - }, - ], - }, - }; + ], + }, + }; }); it('should create necessary resources if a SNS arn is provided', () => { @@ -804,17 +805,18 @@ describe('AwsCompileFunctions', () => { describe('when IamRoleLambdaExecution is used', () => { beforeEach(() => { // pretend that the IamRoleLambdaExecution is used - awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = { - Properties: { - Policies: [ - { - PolicyDocument: { - Statement: [], + awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + { + Properties: { + Policies: [ + { + PolicyDocument: { + Statement: [], + }, }, - }, - ], - }, - }; + ], + }, + }; }); it('should create necessary resources if a KMS key arn is provided', () => { @@ -878,17 +880,18 @@ describe('AwsCompileFunctions', () => { describe('when IamRoleLambdaExecution is used', () => { beforeEach(() => { // pretend that the IamRoleLambdaExecution is used - awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = { - Properties: { - Policies: [ - { - PolicyDocument: { - Statement: [], + awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.IamRoleLambdaExecution = + { + Properties: { + Policies: [ + { + PolicyDocument: { + Statement: [], + }, }, - }, - ], - }, - }; + ], + }, + }; }); it('should create necessary resources if a tracing config is provided', () => { @@ -1520,8 +1523,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { handler: 'index.handler', fileSystemConfig: { localMountPath: '/mnt/path', - arn: - 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', + arn: 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', }, }, }, @@ -1932,8 +1934,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { }, fileSystemConfig: { localMountPath: '/mnt/path', - arn: - 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', + arn: 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', }, }, fnImage: { @@ -2309,8 +2310,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { foo: { fileSystemConfig: { localMountPath: '/mnt/path', - arn: - 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', + arn: 'arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a', }, }, }, diff --git a/test/unit/lib/plugins/aws/package/lib/mergeCustomProviderResources.test.js b/test/unit/lib/plugins/aws/package/lib/mergeCustomProviderResources.test.js index e750e820b..f117d4f7a 100644 --- a/test/unit/lib/plugins/aws/package/lib/mergeCustomProviderResources.test.js +++ b/test/unit/lib/plugins/aws/package/lib/mergeCustomProviderResources.test.js @@ -21,7 +21,8 @@ describe('mergeCustomProviderResources', () => { ) ); - awsPackage.serverless.service.provider.compiledCloudFormationTemplate = coreCloudFormationTemplate; + awsPackage.serverless.service.provider.compiledCloudFormationTemplate = + coreCloudFormationTemplate; }); describe('#mergeCustomProviderResources()', () => { diff --git a/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js b/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js index 74b5edc6a..3f1e175ec 100644 --- a/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js +++ b/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js @@ -431,7 +431,11 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { let serverless; const customFunctionName = 'foo-bar'; before(async () => { - const { awsNaming, cfTemplate, serverless: serverlessInstance } = await runServerless({ + const { + awsNaming, + cfTemplate, + serverless: serverlessInstance, + } = await runServerless({ fixture: 'function', command: 'package', configExt: { diff --git a/test/unit/lib/plugins/aws/provider.test.js b/test/unit/lib/plugins/aws/provider.test.js index 355f099f7..db0fbce1c 100644 --- a/test/unit/lib/plugins/aws/provider.test.js +++ b/test/unit/lib/plugins/aws/provider.test.js @@ -813,8 +813,7 @@ aws_secret_access_key = CUSTOMSECRET images: { invalidimage: { path: './', - uri: - '000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38', + uri: '000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38', }, }, }, @@ -909,8 +908,7 @@ aws_secret_access_key = CUSTOMSECRET foo: { image: { name: 'baseimage', - uri: - '000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38', + uri: '000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38', }, }, }, diff --git a/test/unit/lib/plugins/aws/rollback.test.js b/test/unit/lib/plugins/aws/rollback.test.js index 146d5bb72..0abdc97f6 100644 --- a/test/unit/lib/plugins/aws/rollback.test.js +++ b/test/unit/lib/plugins/aws/rollback.test.js @@ -91,8 +91,7 @@ describe('AwsRollback', () => { const s3Objects = [ { // eslint-disable-next-line max-len - Key: - 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', + Key: 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', }, { Key: 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/test.zip', @@ -141,8 +140,7 @@ describe('AwsRollback', () => { const s3Objects = [ { // eslint-disable-next-line max-len - Key: - 'serverless/rollback/dev/2000000000000-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', + Key: 'serverless/rollback/dev/2000000000000-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', }, { Key: 'serverless/rollback/dev/2000000000000-2016-10-18T08:24:56.930Z/test.zip', @@ -176,8 +174,7 @@ describe('AwsRollback', () => { const s3Objects = [ { // eslint-disable-next-line max-len - Key: - 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', + Key: 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', }, { Key: 'serverless/rollback/dev/1476779096930-2016-10-18T08:24:56.930Z/test.zip', diff --git a/test/unit/lib/plugins/aws/utils/findAndGroupDeployments.test.js b/test/unit/lib/plugins/aws/utils/findAndGroupDeployments.test.js index 4df749cc9..52e60f243 100644 --- a/test/unit/lib/plugins/aws/utils/findAndGroupDeployments.test.js +++ b/test/unit/lib/plugins/aws/utils/findAndGroupDeployments.test.js @@ -16,24 +16,21 @@ describe('#findAndGroupDeployments()', () => { const s3Objects = [ { // eslint-disable-next-line max-len - Key: - 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', + Key: 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', }, { Key: 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/test.zip', }, { // eslint-disable-next-line max-len - Key: - 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/compiled-cloudformation-template.json', + Key: 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/compiled-cloudformation-template.json', }, { Key: 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/test.zip', }, { // eslint-disable-next-line max-len - Key: - 'serverless/test/dev/1476781042481-2016-10-18T08:57:22.481Z/compiled-cloudformation-template.json', + Key: 'serverless/test/dev/1476781042481-2016-10-18T08:57:22.481Z/compiled-cloudformation-template.json', }, { Key: 'serverless/test/dev/1476781042481-2016-10-18T08:57:22.481Z/test.zip', diff --git a/test/unit/lib/plugins/aws/utils/getS3ObjectsFromStacks.test.js b/test/unit/lib/plugins/aws/utils/getS3ObjectsFromStacks.test.js index 064737bd6..6cf20f71e 100644 --- a/test/unit/lib/plugins/aws/utils/getS3ObjectsFromStacks.test.js +++ b/test/unit/lib/plugins/aws/utils/getS3ObjectsFromStacks.test.js @@ -35,14 +35,12 @@ describe('#getS3ObjectsFromStacks()', () => { const expected = [ // eslint-disable-next-line max-len { - Key: - 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', + Key: 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/compiled-cloudformation-template.json', }, { Key: 'serverless/test/dev/1476779096930-2016-10-18T08:24:56.930Z/test.zip' }, // eslint-disable-next-line max-len { - Key: - 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/compiled-cloudformation-template.json', + Key: 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/compiled-cloudformation-template.json', }, { Key: 'serverless/test/dev/1476779278222-2016-10-18T08:27:58.222Z/test.zip' }, ];