Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless: deploy particular profile

In the serverless.yml, the deployment profiles are set like this

custom:
defaultStage: dev
profiles:
  dev: b***2_dev
  prod: b***2_prod
  suku: b***2_suku

While the default deploy is dev, I would like to deploy the profile suku without changing the defaultStage.

What is the command for this? sls deploy --profile suku didn't work

like image 400
suku Avatar asked Apr 15 '17 10:04

suku


People also ask

How do I deploy a specific function in serverless?

Deploying function from an existing project yml file in the folder, and define your function within serverless. yml. Then open the command prompt, navigate to the folder, and hit sls deploy -v. That way, your existing function can also be deployed to AWS Lambda.

How do I create a serverless profile?

Login to your AWS account and go to the Identity & Access Management (IAM) page. Click on Users and then Add user. Enter a name in the first field to remind you this user is related to the Serverless Framework, like serverless-admin . Enable Programmatic access by clicking the checkbox.

How do I deploy serverless locally?

Once the package is installed, add the following in the plugin section of your serverless. yml file. Add the plugin section if you don't already have it. This will start a local server that emulates AWS Lambda and API gateways on your local machine.


1 Answers

On newest versions of serverless (currently 1.26.1), you can provide the argument --aws-profile

ex: sls --aws-profile suku deploy https://serverless.com/framework/docs/providers/aws/guide/credentials#using-the-aws-profile-option

However, in your case, another option could be to use "per stage" profile:

service: new-service
provider:
  name: aws
  runtime: nodejs6.10
  stage: ${opt:stage, self:custom.defaultStage}
  profile: ${self:custom.profiles.${self:provider.stage}}
custom:
  defaultStage: dev
  profiles:
    dev: devProfile
    prod: prodProfile

https://serverless.com/framework/docs/providers/aws/guide/credentials#per-stage-profiles

like image 196
Michael Avatar answered Jan 03 '23 17:01

Michael