Brief Description
Will be sharing how I was able to deploy same codebase to different AWS account on Vapor using multiple vapor.yml
config file with the help of bash scripts.
At the time of writing this, Laravel Vapor did not support deploy command to receive a filepath to deploy against. Hopefully one day that feature can be added by the team.
These approach allows you to use separate AWS account for your staging and production environments if needed as well better than that deploy to multiple aws account or multiple aws region.
How it works
Assuming you already have your laravel project setup and working with Laravel Vapor.
- Rename
vapor.yml
tovapor.{account}.yml
, project should be a unique name different to the other file you need to create. eg.vapor.dev.yml
2.Create another vapor config file to deploy to the different account or region. eg.vapor.devcon.yml
and make sure config are correct. - Make sure
vapor.yml
file doesn't exist on your root directory of project anymore. - Copy the following scripts to the root directory of project and make sure to make them executable.
Interact with scripts
At this stage you should have 2 vapor config file on your root directory. From our example you would have:
vapor.dev.yml
vapor.devcon.yml
Vapor CLI:
./vapor-cli.sh dev env:pull staging
./vapor-cli.sh dev env:push staging
Deploy:
./vapor-deploy.sh dev staging
./vapor-deploy.sh devcon production
Take Away
This approach can be used to deploy Staging and Production to different AWS account or Region as well.
All that will be
To have correct file naming and config to have only correct environment setting on the related file.
To make changes to both script by to only allow 1 argument and use 1st argument as filename and environment to run against.
Eg.
vapor.staging.yml
vapor.production.yml
./vapor-deploy.sh staging
./vapor-deploy.sh production
Top comments (0)