Add sls config commands
See original GitHub issueThis is a Feature Proposal
Description
PR #3558 recently added support for a .serverlessrc
file. This file will now hold the configured serverless platform credentials and other config info. We should add generic config commands for managing these files in a programmatic way.
- Take care of file permission handling (e.g. check when file is read)
.serverlessrc file format
The .serverlessrc
format is JSON.
Commands to support
sls config set -k <key> -v <value> [-g|--global]
- Sets a config value in
.serverlessrc
. - Defaults to setting values at the project level (cwd).
- To set a value at the global level (
~/.serverless/.serverlessrc
) use the-g
option. - Creates a
.serverlessrc
file if one does not exist. - Since the config file is json, key depth can be specified using
.
- Example: running
sls config set -k foo.bar -v hello
results in…
- Example: running
{
"foo": {
"bar": "hello
}
}
- Command should return success message
Successfully configured ~/path/to/.serverlessrc
<key>: <value>
sls config get -k <key>
- Gets a config value
- Key depth can be specified using
.
- Command outputs value found at
key
sls config delete -k <key> [-g|--global]
- Deletes a config value
- Executes at the project level by default
- Key depth can be specified using
.
- Command outputs value deleted at
key
- To delete a value at the global level (
~/.serverless/.serverlessrc
) use the-g
option.
sls config list
- Lists all config from both the project and global levels
- Command outputs…
Global config `~/.serverless/.serverlessrc`
{
"foo": "bar"
}
Project config
Global config `~/path/to/project/.serverlessrc`
{
"bar": "baz"
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Config Credentials - AWS Lambda - Serverless Framework
Configure the default profile · Configure a custom profile · Update an existing profile.
Read more >Summary of SLS configuration commands
First Level Context Commands Second Level Context Commands Description
set name Identify the user name fo...
show List all BRI SLS paramet...
clear fac Delete an...
Read more >First Serverless project | Reason SLS
Step 1 - Serverless installation. Install the Serverless framework on your machine via npm by running this command: npm install serverless -g.
Read more >Configure Multiple AWS Profiles - SST.Dev
By adding AWS_PROFILE=newAccount at the beginning of our serverless invoke local command we are setting the variable that the AWS SDK will use...
Read more >Setting up the Serverless CLI and Credentials - YouTube
In this tutorial Serverless Framework lead front-end engineer Nik Graf shows you how to setup Serverless so you can deploy your first Lambda ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could we support YAML and JSON for the rc file? With the parser that is used in SLS this should work easily. (see my PR to add something similar for the serverless.yml/yaml/json here https://github.com/serverless/serverless/pull/3647). There is even no need to support file endings in this case - the .serverlessrc’s name is fix - but if the yaml parser is used it will support both right away.
@pmuens no skeleton or default config at the moment. Simply create an empty json file and add the config being set by the command.