【发布时间】:2022-01-14 22:08:59
【问题描述】:
我有以下无服务器配置文件:
service: aws-node-scheduled-cron-project
frameworkVersion: '2 || 3'
plugins:
- serverless-plugin-typescript
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: 20201221
region: us-west-2
# Imports all the enviromental variables in `.env.yml` file
environment: ${file(./env.yml)}
functions:
...
env.yml
DATABASE_HOST: 127.0.0.1
DATABASE_USER: root
DATABASE_PASSWORD: your_mysql_root_password
DATABASE_TABLE: laravel
DATABASE_PORT: 3306
DATABASE_USE_SSL: false
NOTIFICATION_SERVICE_URL: http://localhost:4000
现在我想在本地调用函数时即时更改DATABASE_TABLE。我试过了:
export DATABASE_TABLE=1-30-task-template-schedule && npx serverless invoke local --function notifyTodoScheduleFullDay
但变量DATABASE_TABLE 被env.yml 中的变量覆盖。可以通过命令行来实现吗?
【问题讨论】:
标签: node.js amazon-web-services shell serverless-framework