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:

caution

This command will output a value with a password in a plain text! You can pipe it to xclip in Linux or to pbcopy in Mac OS to save it directly to your clipboard.

make aws-vault
make create-repo-auth-url

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 deployBranches property. Check out the environment docs for more details.

Trigger deployment manually

You can also trigger a deployment manually using AWS Console!

  1. Navigate to CodeBuild service.

  2. Find the entrypoint project named <PROJECT_NAME>-<ENV_STAGE_NAME> (e.g. mypro-qa) and navigate to it by pressing its name.

  3. Press the "Start build with overrides" button.

  4. Select the source branch and optionally a commit ID.

  5. Submit by pressing "Start build" button.

  6. The Pipeline should start in a few seconds.

info

You can also build and deploy apps from your local device. Read more