How to deploy multiple serverless.yml files one after another

I have created multiple Serverless.yml(stacks) files, I am able to deploy one by one using cd with going to each folder, but how to deploy the stacks one after another using a single sevrerless.yml or shell script file?

I think you will have to rely on bash.
If the stacks are independent, you could execute on parallel doing something like:

sls deploy -c /path/to/serverless1.yml & sls deploy -c /path/to/serverless2.yml

If you want instead to execute sequentially (if one fails, the following won’t be executed):

sls deploy -c /path/to/serverless1.yml && sls deploy -c /path/to/serverless2.yml

If you have parameters, you could manage them from bash also.

1 Like

bash example… i think i got this from this forum a while back.
for dir in _projectfolder/folder-with-all-the-sub-folders/*; do (cd "$dir" && npx serverless deploy); done

2 Likes