Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variables #79

Closed
xavicolomer opened this issue Aug 1, 2017 · 3 comments
Closed

Environment Variables #79

xavicolomer opened this issue Aug 1, 2017 · 3 comments

Comments

@xavicolomer
Copy link

xavicolomer commented Aug 1, 2017

Hi there,

I'm thinking on developing a plugin which allows me to switch environments easily

The challenges:

  1. I am developing multiple APIs which have different stages (dev, staging / testing, and production)

  2. This stages might be deployed in different accounts, dev is for example my own Amazon account, but testing and production might rely on the client.

  3. Serverless / AWS Cli stores the configuration on the ~/.aws/credentials and as far as I know it must be changed manually everytime you target a different account

  4. Finally those environments might also need other custom parameters such as Database configurations

The possible solution:

Note: I already created a little NodeJS script which allows me to switch AWS config based on parameter.

a. Develop a plugin wich allows me to switch accounts based on configuration files.

b. Files would allow to give those configurations to certain users, for example a junior developer would only have dev and testing and only senior developers would have the prod environment files

c. All environments files would be placed on a specific folder, for example .slsenv

.slsenv/
    dev.yml
    staging.yml
    prod.yml

d. The command could be:
sls deploy --environment dev --alias aliasName

e. Environment file could also store DB variables

environment:
    awsAPIKey: 123456789
    awsAPISecret: ABCDEF
    mySQLEndpoint: mysql.endpoint.eu-west-1.rds.amazonaws.com
    mySQLUser: user
    mySQLAdmin: admin

f. Finally some environments could require some extra confirmation
Are you sure you want to deploy on prod?

What do you think people?

Am I reinventing the wheel? Is this something I could already do in the main yml?

Thanks!

@dougmoscrop
Copy link
Contributor

What we do more or less is:

custom:
  stage: ${opt.stage, self:provider.stage}
  config: ${file(./env/${opt:config, self:custom.stage}.yml)}

This mens that you can sls deploy --stage=x and you get ./env/x.yml, but you can sls deploy --config=x --stage=y (use the same config on a different stage)

We use profiles to manage account access, and the profile is done via some interpolation/lookup in the config.

@xavicolomer
Copy link
Author

@dougmoscrop by account access do you mean AWS Key and Secret?

Otherwise how do you change that?

@medikoo
Copy link
Contributor

medikoo commented Nov 30, 2021

This is a plugin registry repository, where exchange should rather be limited to the state of this registry, and not to discuss ideas for plugins.

I propose to discuss plugin ideas at https://github.com/serverless/serverless/discussions

@medikoo medikoo closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants