question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add sls config commands

See original GitHub issue

This 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…
{
  "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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
HyperBraincommented, May 18, 2017

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.

1reaction
brianneislercommented, May 9, 2017

@pmuens no skeleton or default config at the moment. Simply create an empty json file and add the config being set by the command.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found