# Serverless deploy works in local, but not within GitLab CICD. The erorr message seems empty

**URL:** <https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235>\
**Category:** Serverless Framework\
**Created:** [March 3, 2021, 3:15am UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235 "2021-03-03T03:15:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![koshyviv](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@koshyviv](https://forum.serverless.com/u/koshyviv)\
**Post date:** [March 3, 2021, 3:15am UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235/1 "2021-03-03T03:15:52Z")

</div>

I’m getting this output while deploying the serverless stack through GitLab CICD

> `ServerlessError: Invalid variable reference syntax for variable . You can only reference env vars, options, & files. You can check our docs for more info.` ` at Variables.getValueFromSource (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:589:30)` ` at Variables.splitAndGet (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:448:17)` ` at /usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:40` ` at Array.map (<anonymous>)` ` at Variables.populateMatches (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:387:20)` ` at Variables.populateValue (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:418:30)` ` at /usr/local/lib/node_modules/serverless/lib/classes/Variables.js:300:38` ` at Array.map (<anonymous>)` ` at Variables.populateVariables (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:299:8)` ` at Variables.populateObjectImpl (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:333:30)` ` at /usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:40` ` at Variables.initialCall (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:112:20)` ` at Variables.populateObject (/usr/local/lib/node_modules/serverless/lib/classes/Variables.js:329:17)` ` at /builds/koshyviv/coda-learn/node_modules/serverless-step-functions/lib/yamlParser.js:26:62`

It works completely fine in my local, and the error seems to be incomplete - thus, I’m not able to figure which variable is exactly at fault.

My serverless.yml is present here - [serverless.yml · dev · Vivek George Koshy / coda-learn · GitLab](https://gitlab.com/koshyviv/coda-learn/-/blob/dev/serverless.yml)

> service: coda-learn-vivek  
> frameworkVersion: ‘2’
> 
> provider:  
> name: aws  
> runtime: nodejs12.x  
> lambdaHashingVersion: 20201221  
> region: ap-south-1  
> stage: ${opt:stage, ‘dev’}  
> bucketname: codalearn-vivek-rawfile-${self:provider.stage}
> 
> functions:  
> LoginUser:  
> handler: backend/userAuth.login  
> role: CodaLearnCognitoLambdaRole  
> environment:  
> USERPOOLID: !Ref CodaLearnCognitoUserPool  
> CLIENTID: !Ref CodaLearnCognitoUserPoolClient  
> REGION: ${self:provider.region}  
> events:  
> - http:  
> path: user  
> method: post  
> cors: true  
> UploadFile:  
> handler: backend/uploadFile.handler  
> role: CodaLearnCognitoLambdaRole  
> environment:  
> BUCKET: ${self:provider.bucketname}  
> TABLE\_NAME: users-${self:provider.stage}  
> statemachine\_arn: ${self:resources.Outputs.SFParseDataDB.Value}  
> events:  
> - http:  
> path: file  
> method: post  
> cors: true  
> authorizer:  
> type: COGNITO\_USER\_POOLS  
> authorizerId:  
> Ref: CodaLearnApiGatewayAuthorizer  
> GetUserFile:  
> handler: backend/readFile.handler  
> role: CodaLearnCognitoLambdaRole  
> environment:  
> BUCKET: ${self:provider.bucketname}  
> TABLE\_NAME: users-${self:provider.stage}  
> DATA\_TABLE\_NAME: users-data-${self:provider.stage}  
> events:  
> - http:  
> path: file  
> method: get  
> cors: true  
> authorizer:  
> type: COGNITO\_USER\_POOLS  
> authorizerId:  
> Ref: CodaLearnApiGatewayAuthorizer  
> ParseDataDB:  
> handler: backend/parseDataDb.handler  
> role: CodaLearnCognitoLambdaRole  
> environment:  
> TABLE\_NAME: users-data-${self:provider.stage}
> 
> stepFunctions:  
> stateMachines:  
> SFParseDataDBSomething:  
> name: SFParseDataDB  
> definition:  
> Comment: “Func to asynchronously upload data to DB”  
> StartAt: SaveDatatoDB  
> States:  
> SaveDatatoDB:  
> Type: Task  
> Resource:  
> Fn::GetAtt: [ParseDataDB, Arn]  
> End: true
> 
> resources:  
> Resources:
> 
> ```
> #S3
> CodaLearnBucket:
> Type: AWS::S3::Bucket
> Properties:
> BucketName: ${self:provider.bucketname}
> WebsiteConfiguration:
> IndexDocument: index.html
> CodaLearnBucketPolicy:
> Type: AWS::S3::BucketPolicy
> Properties:
> Bucket:
> Ref: 'CodaLearnBucket'
> PolicyDocument:
> Statement:
> - Effect: 'Allow'
> Principal: '*'
> Action:
> - 's3:GetObject'
> Resource:
> Fn::Join:
> - ''
> - - 'arn:aws:s3:::'
> - Ref: 'CodaLearnBucket'
> - '/*'
> 
> # Dynamo
> CodaLearnDynamoDBTable:
> Type: AWS::DynamoDB::Table
> Properties:
> TableName: users-${self:provider.stage}
> AttributeDefinitions:
> - AttributeName: id
> AttributeType: S
> - AttributeName: username
> AttributeType: S
> KeySchema:
> - AttributeName: id
> KeyType: HASH
> - AttributeName: username
> KeyType: RANGE
> ProvisionedThroughput:
> ReadCapacityUnits: 5
> WriteCapacityUnits: 5
> CodaLearnDataDynamoDBTable:
> Type: AWS::DynamoDB::Table
> Properties:
> TableName: users-data-${self:provider.stage}
> AttributeDefinitions:
> - AttributeName: id
> AttributeType: S
> KeySchema:
> - AttributeName: id
> KeyType: HASH
> ProvisionedThroughput:
> ReadCapacityUnits: 5
> WriteCapacityUnits: 5
> 
> # Cognito
> CodaLearnCognitoUserPool:
> Type: AWS::Cognito::UserPool
> Properties:
> UserPoolName: CodaLearn-${self:provider.stage}
> CodaLearnCognitoUserPoolClient:
> Type: AWS::Cognito::UserPoolClient
> Properties:
> ClientName: CodaLearnWebApp-${self:provider.stage}
> GenerateSecret: false
> UserPoolId:
> Ref: 'CodaLearnCognitoUserPool'
> 
> # Roles
> CodaLearnCognitoLambdaRole:
> Type: AWS::IAM::Role
> Properties:
> RoleName: CodaLearnCognitoLambda-${self:provider.stage}
> AssumeRolePolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Principal:
> Service:
> - lambda.amazonaws.com
> Action: sts:AssumeRole
> Policies:
> - PolicyName: CogntioFullAccess
> PolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Action:
> - cognito-identity:*
> Resource:
> - "*"
> - PolicyName: LogWriteAccess
> PolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Action:
> - logs:CreateLogGroup
> - logs:CreateLogStream
> - logs:PutLogEvents
> Resource:
> - 'Fn::Join':
> - ':'
> - - 'arn:aws:logs'
> - Ref: 'AWS::Region'
> - Ref: 'AWS::AccountId'
> - 'log-group:/aws/lambda/*:*:*'
> - PolicyName: S3BucketFullAccess
> PolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Action:
> - s3:*
> Resource: '*'
> - PolicyName: DynamoDBFullAccess
> PolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Action:
> - dynamodb:*
> Resource: 
> - 'Fn::GetAtt': [CodaLearnDynamoDBTable, Arn]
> - 'Fn::GetAtt': [CodaLearnDataDynamoDBTable, Arn]
> - PolicyName: StepFnFullAccess
> PolicyDocument:
> Version: '2012-10-17'
> Statement:
> - Effect: Allow
> Action:
> - states:*
> Resource: '*'
> 
> # API Gateway
> CodaLearnApiGatewayAuthorizer:
> Type: AWS::ApiGateway::Authorizer
> Properties:
> Name: CodaLearn-${self:provider.stage}
> RestApiId:
> Ref: ApiGatewayRestApi
> Type: COGNITO_USER_POOLS
> ProviderARNs:
> - Fn::GetAtt: [CodaLearnCognitoUserPool, Arn]
> IdentitySource: method.request.header.Authorization
> 
> ```
> 
> Outputs:  
> CodaLearnCognitoUserPoolId:  
> Description: ‘Wild Rydes Cognito User Pool ID’  
> Value:  
> Ref: ‘CodaLearnCognitoUserPool’  
> CodaLearnCognitoUserPoolClientId:  
> Description: ‘Wild Rydes Cognito User Pool Client ID’  
> Value:  
> Ref: ‘CodaLearnCognitoUserPoolClient’  
> CodaLearnDynamoDbARN:  
> Description: ‘Wild Rydes DynamoDB ARN’  
> Value:  
> ‘Fn::GetAtt’: [CodaLearnDynamoDBTable, Arn]  
> SFParseDataDB:  
> Description: The ARN of the example state machine  
> Value:  
> Ref: SFParseDataDB
> 
> plugins:
> 
> - serverless-step-functions

The complete error logs can be found in the pipeline logs here - [deploy-backend-dev (#1068555958) · Jobs · Vivek George Koshy / coda-learn · GitLab](https://gitlab.com/koshyviv/coda-learn/-/jobs/1068555958)

My gitlab-ci.yml is as follows:

> ```
> default:
> image: node:latest
> stages:
> - deploy
> deploy-backend-dev:
> stage: deploy
> rules:
> - if: $CI_MERGE_REQUEST_ID
> when: never
> - if: $CI_COMMIT_REF_NAME =~ /dev/
> changes:
> - backend/**/*
> - if: $CI_COMMIT_REF_NAME =~ /dev/
> changes:
> - .gitlab-ci.yml
> before_script:
> - npm config set prefix /usr/local
> - npm install -g serverless
> script:
> - export AWS_ACCESS_KEY_ID=$DEV_AWS_ACCESS_KEY_ID
> - export AWS_SECRET_ACCESS_KEY=$DEV_AWS_SECRET_ACCESS_KEY
> - export AWS_REGION=$DEV_AWS_REGION
> - npm i
> - export SLS_DEBUG=*
> - sls deploy --verbose
> - sls info --verbose
> 
> ```

I’m a little new to serverless, hope these help. Thanks in advance. 🙂

---

<div class="post-metadata">

**Author:** ![garethmcc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/garethmcc/32/2276_2.png) [@garethmcc](https://forum.serverless.com/u/garethmcc)\
**Post date:** [March 3, 2021, 6:39am UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235/2 "2021-03-03T06:39:31Z")

</div>

Would you be able to paste your serverless.yml as the issue is likely there.

---

<div class="post-metadata">

**Author:** ![koshyviv](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@koshyviv](https://forum.serverless.com/u/koshyviv)\
**Post date:** [March 3, 2021, 8:15am UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235/3 "2021-03-03T08:15:40Z")

</div>

Sure, i had included the link. I have copied the contents too now.

---

<div class="post-metadata">

**Author:** ![atakansavas](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/atakansavas/32/5322_2.png) [@atakansavas](https://forum.serverless.com/u/atakansavas)\
**Post date:** [March 3, 2021, 10:50am UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235/4 "2021-03-03T10:50:16Z")

</div>

Hi. I have similar problem. But just similar. Not same. Exceptions are different. Could it be a general CI/CD problem?  
[My question link](http://forum.serverless.com/t/emfile-too-many-open-files-error-while-ci-cd-deploy/14245)

---

<div class="post-metadata">

**Author:** ![koshyviv](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@koshyviv](https://forum.serverless.com/u/koshyviv)\
**Post date:** [March 7, 2021, 5:03pm UTC](https://forum.serverless.com/t/serverless-deploy-works-in-local-but-not-within-gitlab-cicd-the-erorr-message-seems-empty/14235/5 "2021-03-07T17:03:15Z")

</div>

I’m really not sure whats going wrong/right - but it started working for me again on its own.  
Now im stuck with a different issue already listed in `GitHub` [Unsettled promises :( · Issue #5972 · serverless/serverless · GitHub](https://github.com/serverless/serverless/issues/5972)

Again, this is only happening in my GitLab pipelines
