serverless / github-action

:zap::octocat: A Github Action for deploying with the Serverless Framework
Apache License 2.0
662 stars 173 forks source link

Question: How to set lambda environment variable? #74

Closed maour closed 1 year ago

maour commented 1 year ago

Hello,

Is it possible to set environment variables for lambda from this action?

I can see such thing seems to be here using aws-lambda-deploy .

  - name: AWS Lambda Deploy
      if: github.ref == 'refs/heads/master'
      uses: appleboy/lambda-action@master
      with:
        aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws_region: ${{ secrets.AWS_REGION }}
        function_name: gorush
        zip_file: output.zip
        dry_run: true
+       environment: foo=bar,author=appleboy
maour commented 1 year ago

I tried this and it's fine, so in case there isn't a better way, this solution works fine for me,


- uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: eu-central-1
- run: |
          aws lambda update-function-configuration --function-name existingFunc --environment "Variables={ MYENV=SAMPLE }"