Skip to main content

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:

saas aws est-env qa
saas ci create-credentials | pbcopy

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!

  1. Open IAM service in web console.

  2. Find the external-ci user.

  3. Navigate to Security Credentials tab.

  4. Press Create access key.

  5. Copy the key id and secret.

Configure Github

  1. Open Settings page of your repository.

  2. Go to Secrets subpage.

  3. Create following secrets:

  4. Test by pushing some code to your Github repository. After couple of seconds the code should be synchronized in CodeCommit.

Configure Bitbucket

  1. Open Repository Settings page of your repository.

  2. Go to Pipeline / Settings sub-page.

  3. Enable Bitbucket Pipelines.

  4. Go to Pipeline / Repository variables sub-page.

  5. Create following variables:

    • CODE_COMMIT_REPO – set value to authenticated repository URL

    • AWS_ACCESS_KEY_IDexternal-ci user access key id

    • AWS_SECRET_ACCESS_KEYexternal-ci user access key secret

    • AWS_DEFAULT_REGION – set to a region to which your system is deployed

  6. 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.