Can't pass env variables in gitlab environment to serverless
Describe the bug
I'm trying to wrap up serverless deployment of Next.js, however I can't get Gitlab env variables to work and get accepted by serverless. It accepts aws key and id fine, just none of the custom ones get taken into account.
Screenshots/Code/Logs
Here is my serverless.yml
myNextApplication:
component: "./node_modules/@sls-next/serverless-component"
inputs:
domain: ${env.DOMAIN}
name: ${env.APP_NAME}
bucketName: ${env.APP_NAME}
bucketRegion: ${env.AWS_BUCKET_REGION}
}
And my super simple .gitlab-ci.yml
stages:
- deploy
deploy:
stage: deploy
image: node
before_script:
- npm config set prefix /usr/local
- npm install -g serverless
- npm install
script:
- >-
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
APP_NAME=$APP_NAME
NODE_ENV=$NODE_ENV
DOMAIN=$DOMAIN
AWS_BUCKET_REGION=$AWS_BUCKET_REGION
serverless
Versions
- OS/Environment: Gitlab-CI runner
- @sls-next/serverless-component version: 1.18.0
- Next.js version: n/a
My apologies, it was issue on gitlab end.
@Reiiya Hi. Hm, How did you solve this? I tried different things and seems can only pass single variable with single line: 🤷♂️
NODE_ENV='production' serverless
Hey @maxim-c . It was a dumb error on my end.
I set environment variables via gitlab global variables but branch I tried to deploy on didn't have access to them.
I changed my .gitlab-ci.yml too. I don't pass any variables to serverless call at all, they just worked from gitlab globals in my case.