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:
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!
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 deployBranches
property. Check out the
environment docs for more details.
Trigger deployment manually
You can also trigger a deployment manually using AWS Console!
Navigate to
CodeBuild
service.Find the entrypoint project named
<PROJECT_NAME>-<ENV_STAGE_NAME>
(e.g.mypro-qa
) and navigate to it by pressing its name.Press the "Start build with overrides" button.
Select the source branch and optionally a commit ID.
Submit by pressing "Start build" button.
The Pipeline should start in a few seconds.
You can also build and deploy apps from your local device. Read more