Lesson 4 of 5 AWS CI/CD Services

Managing Releases with Branches, Tags and Promoted Artifacts

This lesson explains how deployments start from source control, and how branches and tags decide what is released to each environment.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish trunk-based development from feature branching.
  • Explain how trigger filters on branches, paths and tags map changes to environments.
  • Explain why an artifact should be built once and promoted through every environment.

Branching strategies

A branching strategy defines how changes move from a developer's machine into a release, and it shapes how the CI/CD pipeline is triggered.

In trunk-based development, developers work on short-lived branches that are merged into the main branch, the trunk, at least daily after a pull request and automated tests. The trunk is always releasable, and every merge can flow through the pipeline to production. Unfinished features are merged but hidden behind feature flags, for example in AppConfig, rather than kept on long-running branches. This strategy suits continuous delivery and keeps merge conflicts small.

GitFlow uses long-lived branches: features are merged into a develop branch, a release branch is cut and stabilised before each release, and hotfix branches patch production. It suits products with scheduled, versioned releases, but the long-lived branches drift apart and make merges harder. The following table summarises the two strategies.

StrategyHow it worksSuits
Trunk-based developmentShort-lived branches merged often; feature flags hide unfinished workContinuous delivery
GitFlowLong-lived develop and release branchesScheduled releases

In either case, pull requests can trigger CodeBuild to run tests before code is merged.

Mapping branches and tags to environments

Once a branching strategy is chosen, the CI/CD pipeline must decide which changes go to which environment. V2 pipelines do this with trigger filters on branch names, file paths and Git tags. A common arrangement deploys every merge to the develop branch to a test environment and every merge to main to production. Another releases to production only when a version tag such as v1.2.0 is pushed, which makes each release a deliberate act that can be traced to a tag.

File path filters let one repository that contains several services, often called a monorepo, start only the pipeline for the service that changed. Without them, every commit would rebuild and redeploy every service.

Build once, promote everywhere

A deployable artifact, such as a ZIP file, a container image or a packaged template, should be built once and the same artifact promoted through development, test and production. If each environment rebuilt the code, dependency versions or build tools could differ between builds, and the version released to production would not be the one that was tested. Differences between environments, such as database endpoints or feature flags, belong in configuration held outside the artifact, for example in Parameter Store or AWS AppConfig.

Each artifact should also carry a version label through every stage: a Git tag or commit ID, an immutable container image tag in Amazon ECR, a Lambda version and alias, and resource tags. With this traceability, a team can find the exact commit behind what is running in production, and rolling back means redeploying a known earlier version rather than rebuilding old code.

Worked example

Mapping branches to environments

Each Git event triggers different pipeline behaviour and deploys to a different environment. The following table maps common Git events to their pipeline behaviour and target environment.

Git eventPipeline behaviourEnvironment
Push to a feature branchBuild and unit test onlyNone (or a temporary stack)
Pull request into mainBuild, test, report status to the pull requestNone
Merge to mainBuild once, deploy to test, run integration testsTest
Tag v1.4.0Promote the same artifact after approvalProduction

This trunk-based model keeps branches short-lived and production releases traceable to a tag. Rebuilding the artifact separately for production would risk shipping something other than what passed testing.

Check yourself

Why build an artifact once and promote it through the environments instead of rebuilding it for each one?

Show answer

The artifact deployed to production is exactly the one that was tested, so changes in dependencies or build tools cannot slip in. Environment differences come from configuration, not from separate builds.

Exam Tips

Remember for the exam

  • To release when a version tag is pushed, trigger the pipeline on Git tags.
  • To deploy different branches to different environments, use branch-filtered triggers or separate pipelines.
  • To hide unfinished features while merging often, use feature flags, for example with AppConfig.
  • Build an artifact once and promote that same artifact through every environment.