Configure Automatic Deployments
Each deployed environment comes with a preconfigured CI/CD implemented with AWS CodeCommit, AWS CodeBuild,
and AWS CodePipeline. The general idea of the deployment is for the user to push the code to a master
branch of the
CodeCommit repository created by the Ci CDK Stack.
Automatically synchronize external repository
Get authenticated repository URL
AWS Boilerplate generates a user for you that has minimal permissions required for pushing code to the CodeCommit repository. In order to implement a synchronization logic we need to get a repository URL and credentials of the user. You can create both using a following command:
- Mac OS
- Linux
saas aws est-env qa
saas ci create-credentials | pbcopy
saas aws est-env qa
saas ci create-credentials | xclip -sel clip
The result will be copied to your clipboard. Make sure you save it in some secure place. You can only create two such
URLs so if something goes wrong just open external-ci
user's page in AWS IAM's web panel and delete appropriate key.
Get authentication credentials for ECR repository
All CI pipeline builds are running within a docker image; some services, such as web app, utilise a base image that
contain preinstalled packages to speed up the whole process. Such base images automatically update on every
push to a master
branch, so they are up to date with your code, and you don't have to really do anything besides
providing access to pull them!
Open
IAM
service in web console.Find the
external-ci
user.Navigate to
Security Credentials
tab.Press
Create access key
.Copy the key id and secret.
Configure Github
Open
Settings
page of your repository.Go to
Secrets
subpage.Create following secrets:
CODE_COMMIT_REPO
– authenticated repository URLAWS_ACCESS_KEY_ID
– external-ci user access key idAWS_SECRET_ACCESS_KEY
– external-ci user access key secretAWS_DEFAULT_REGION
– set to a region to which your system is deployed
Test by pushing some code to your Github repository. After couple of seconds the code should be synchronized in CodeCommit.
Configure Bitbucket
Open
Repository Settings
page of your repository.Go to
Pipeline / Settings
sub-page.Enable Bitbucket Pipelines.
Go to
Pipeline / Repository variables
sub-page.Create following variables:
CODE_COMMIT_REPO
– set value to authenticated repository URLAWS_ACCESS_KEY_ID
–external-ci
user access key idAWS_SECRET_ACCESS_KEY
–external-ci
user access key secretAWS_DEFAULT_REGION
– set to a region to which your system is deployed
Test by pushing some code to your BitBucket repository. After couple of seconds the code should be synchronized in CodeCommit.
Trigger deployment automatically
If you want a branch to be deployed automatically for every pushed commit the only thing you need to do is to name this branch
in your environment configuration file using SHIPFAST_DEPLOY_BRANCHES
environment variable. Check out the
environment docs for more details.