CLOUD CONCEPT

Trunk-Based Development

Trunk-Based Development is a version-control strategy in which developers integrate small changes frequently into a single shared main branch, using direct commits or short-lived branches.

Cloud Concepts Hub →

What is Trunk-Based Development

The shared trunk remains the authoritative integration point and is kept releasable through automated testing, rapid feedback, and prompt repair of failures. This reduces divergence and large merge conflicts while enabling CI/CD pipelines to promote validated changes consistently across application environments.

Trunk-Based Development organizes development around one shared integration branch, commonly named main. Developers integrate small changes frequently, usually at least daily, rather than maintaining isolated feature branches for weeks. Teams may commit directly to the trunk or use short-lived branches with lightweight pull requests. The defining characteristic is frequent integration into the shared codebase, not the absence of branches or code review.

Every integration should trigger continuous integration checks. These commonly include compilation, unit tests, static analysis, dependency checks, and selected integration tests. Branch protection can require successful checks and review before merging. Because concurrent changes can interact, the pipeline should also validate the resulting trunk revision after merge. When the trunk fails, restoring it becomes a priority: revert the offending change or deliver a small corrective commit rather than allowing failures to accumulate.

In a cloud delivery workflow, connect the repository to a pipeline and configure its source events to recognize changes to the trunk. Pull-request validation can run separately without deploying unmerged code into shared production environments. A successful trunk build produces a versioned artifact associated with the exact source commit. Promote that same artifact through development, testing, staging, and production instead of rebuilding it separately for each environment. For container workloads, an immutable image digest provides a precise artifact identity.

Application environments do not require corresponding long-lived Git branches. A staging branch and a production branch that continually diverge create additional integration work and can obscure which code was actually tested. Prefer environment-specific deployment configuration, infrastructure parameters, and separately managed secrets. Use pipeline approvals and automated quality gates to control promotion. Trunk-Based Development does not require every merged commit to reach production immediately; continuous delivery can retain an explicit production approval.

For example, a team introducing a new checkout flow can merge its implementation incrementally behind a feature flag. The pipeline tests the code and deploys the artifact to a test account, then promotes it to production after validation. The feature remains disabled until it is ready for users. Flags separate code deployment from feature release, but disabled code still requires testing, and obsolete flags should be removed. Database changes should preserve compatibility during rollout, often by adding a new schema element before migrating consumers and later removing the old element.

The trade-off is a stronger dependency on fast, trustworthy tests, small change sizes, and disciplined collaboration. Slow approvals or unreliable checks encourage branches to live longer and undermine the model. Short-lived release branches can support exceptional maintenance needs, but fixes should also reach the trunk to prevent divergence. For certification scenarios, distinguish this strategy from workflows centered on long-lived development, release, or environment branches: the key signals are frequent integration, a healthy shared mainline, and traceable artifact promotion across environments.

Key aspects of Trunk-Based Development

Trunk-Based Development combines frequent integration, fast validation, and traceable artifact promotion while keeping release controls separate from branching strategy.

One shared integration branch

The trunk is the authoritative integration point for ongoing development. Developers merge small changes frequently instead of accumulating work on long-lived feature branches.

Short feedback and review cycles

Direct commits or short-lived pull requests keep integration delays low. Required reviews and automated checks remain compatible with the approach when they complete promptly.

Continuously validated trunk

Automated checks validate proposed changes and the integrated trunk revision. A failed trunk build requires prompt repair or reversion so other developers can continue integrating safely.

Artifact promotion rather than environment branches

Build a versioned artifact from a known commit and promote it across environments. Keep environment differences in deployment configuration and secret management rather than divergent application branches.

Deployment separated from feature release

Feature flags and compatible incremental changes allow incomplete capabilities to integrate without exposing them to users. Flags need testing, ownership, and eventual removal.

Controlled production delivery

Approvals, deployment gates, and rollback procedures control production risk without delaying source integration. Frequent merges do not imply that every commit must be deployed immediately.

Cloud services for Trunk-Based Development

AWS CodeConnections links a supported external repository to CodePipeline, which starts delivery from the configured trunk branch. CodeBuild compiles the selected revision, runs checks, and produces an artifact tied to that commit. CodePipeline carries the validated artifact through environment-specific stages and any required approvals, while CodeDeploy handles deployments to supported targets. AWS AppConfig can control feature exposure independently of those deployments. Together, these services support frequent source integration and controlled release, but the team must still define branch policies, tests, permissions, and artifact traceability.

AWS CodePipeline image AWS CodePipeline

Orchestrates source, build, test, approval, and deployment stages for changes integrated into the trunk. Configure source triggers and artifact flow so validated output is promoted across environments rather than rebuilt independently.

Open AWS CodePipeline →
AWS CodeBuild image AWS CodeBuild

Runs automated builds and tests for proposed changes and merged trunk revisions. It can produce versioned deployment artifacts and report build results that help teams keep the shared branch healthy.

Open AWS CodeBuild →
AWS CodeConnections

Provides connections between supported external source repositories and AWS developer tools. Used with CodePipeline, it enables a repository hosted outside AWS to supply the trunk revision that starts the delivery workflow.

Open AWS CodeConnections →
AWS CodeDeploy image AWS CodeDeploy

Automates deployment of validated revisions to supported compute targets. Deployment strategies and configured rollback behavior help control rollout risk after changes have already been integrated into the trunk.

Open AWS CodeDeploy →
AWS AppConfig image AWS AppConfig

Manages feature flags and application configuration independently of application code deployment. It supports gradually enabling integrated features, with configuration validation and monitoring-based rollback when configured.

Open AWS AppConfig →