I have some ready-made pipelines built using CodePipeline. Let’s say I wish to link them to a testing environment (whether on EC2 or ECS). How can I achieve that?
I appreciate someone mentioning the steps/procedure from a high-level perspective.
So far I have tried the below:
1. Rerun the current pipelines on different branches prior to merging them to the main/working branch.
2. Create an EC2 instance to temporarily test the backend API
2
Answers
One can leverage Amazon ECS via creating a staging environment and link it to a testing domain hosted inside a zone on Route 53. Additionally, this staging environment can be linked to Amazon CodeSuite (CodeBuild and CodeDeploy w/ Code Pipeline).
The same applies for EC2.
From a high-level view, you typically have separate steps in CodePipeline for test and deployment on each environment. A common flow would look like this:
Ideally stages are also separated through different AWS accounts, like one account for dev (potentially including the Pipeline itself), one for testing, and one for prod. See the image below and related blog post for illustration and more information.
While that works well for the common trunk-based development model, it sounds as if you may want to run the Pipeline on separate branches instead.
For that, you can implement a mechanism that will create a new Pipeline using a CloudFormation template, whenever a new branch is created. The high-level idea is shown in the diagram below. This blog post provides the full details on how to implement the approach.