Ace Cloud Interviews
Home/AWS Tutorial/CodeCommit
🛠️

AWS Developer Tools & CI/CD

CodeCommit

Managed private Git repositories with full integration with AWS services

AWS CodeCommit is a fully managed, private Git repository service that eliminates the need to run your own source control infrastructure. It integrates natively with IAM for fine-grained access control and with other AWS developer tools, making it a natural fit for teams already invested in the AWS ecosystem.

How CodeCommit Works

CodeCommit stores your Git repositories in AWS-managed infrastructure with high availability across multiple Availability Zones. You interact with it using standard Git commands - the only difference from GitHub or Bitbucket is authentication.

Two authentication methods are supported:

MethodHow It WorksBest For
HTTPS + Git credentialsIAM user generates static username/password for GitCI/CD pipelines, individual developers
SSHUpload public key to IAM user profileDeveloper workstations
HTTPS (GRC)git-remote-codecommit helper uses temporary credentialsFederated users, assumed roles, SSO
IAM rolesEC2/Lambda instance profiles or assumed roles via GRCAutomated pipelines, cross-account access
💡

Federated users (SSO, SAML) cannot generate static Git credentials. They must use git-remote-codecommit (GRC) which wraps temporary STS credentials. Install with: pip install git-remote-codecommit

bash
# Clone using GRC (works with assumed roles and SSO)
git clone codecommit::ap-south-1://my-repo

# Clone using HTTPS credentials
git clone https://git-codecommit.ap-south-1.amazonaws.com/v1/repos/my-repo

# Clone using SSH
git clone ssh://git-codecommit.ap-south-1.amazonaws.com/v1/repos/my-repo

IAM Access Control for Repositories

CodeCommit has no concept of repository-level users or teams - all access is controlled through IAM. This is a fundamental difference from GitHub and requires understanding IAM policy conditions.

IAM ActionWhat It Allows
codecommit:GitPullClone and fetch from a repository
codecommit:GitPushPush commits and branches
codecommit:CreateBranchCreate new branches
codecommit:DeleteBranchDelete branches (restrict this!)
codecommit:PutFileUpload files via console
codecommit:GetBranchDescribe branch metadata
codecommit:CreatePullRequestOpen pull requests
codecommit:MergeBranchesByFastForwardMerge via fast-forward

To restrict push to a specific branch (e.g., protect main), use a Deny policy with a condition:

bash
{
  "Effect": "Deny",
  "Action": [
    "codecommit:GitPush",
    "codecommit:DeleteBranch",
    "codecommit:PutFile",
    "codecommit:MergeBranchesByFastForward"
  ],
  "Resource": "arn:aws:codecommit:us-east-1:123456789:my-repo",
  "Condition": {
    "StringEqualsIfExists": {
      "codecommit:References": ["refs/heads/main"]
    },
    "Null": {
      "codecommit:References": "false"
    }
  }
}
⚠️

CodeCommit does not support required reviewers or mandatory CI checks at the repository level. Branch protection policies are implemented entirely through IAM Deny statements, which can be confusing to manage at scale.

Notifications, Triggers, and Approval Rules

CodeCommit supports three event-driven mechanisms that are often confused in interviews:

MechanismTrigger SourceTargetsUse Case
NotificationsRepository events via EventBridgeSNS onlyEmail/Slack alerts on PR activity
TriggersRepository events (direct)SNS or LambdaCustom automation on push/branch creation
EventBridge rulesCodeCommit events via EventBridgeLambda, SQS, CodePipeline, etc.Complex automation, cross-account

Approval rule templates let you enforce pull request review requirements across multiple repositories. You can require N approvals and restrict who counts as an approver using IAM ARN patterns.

💡

Approval rule templates are applied at the repository level and evaluated per pull request. They do not retroactively apply to open PRs when modified. Always test rule changes on a new PR.

CodeCommit vs GitHub vs GitLab in AWS Pipelines

CodeCommit is often compared to GitHub and GitLab. For pure AWS workloads, the key consideration is how well each integrates with CodePipeline, CodeBuild, and IAM.

FactorCodeCommitGitHubGitLab
Auth with IAMNative - no token managementOAuth app or PAT requiredPAT or OAuth required
CodePipeline sourceNative, no webhook setupRequires CodeStar ConnectionRequires CodeStar Connection
Cross-account accessIAM role assumption via GRCPAT or GitHub AppPAT or GitLab App
PR featuresBasic - no code owners fileRich - CODEOWNERS, ActionsRich - pipelines, MR features
CostFree up to 5 users, $1/user/mo afterFree tier available, paid plansFree tier available, paid plans
Compliance/data residencyData stays in your AWS account/regionGitHub.com cloudGitLab.com or self-hosted
💡

AWS has announced that CodeCommit is no longer accepting new customers as of July 2024. Existing customers can continue using it, but new projects should evaluate GitHub, GitLab, or Bitbucket with CodeStar Connections.

Pricing Model

TierActive UsersStorageGit Requests
Free TierUp to 5 active users/month50 GB total10,000 Git requests/month
Paid$1.00 per additional active user/month$0.06/GB/month over 10 GB/user$0.001 per additional Git request

An "active user" is any unique AWS identity that makes at least one Git request or API call in a calendar month. Service roles used by CodePipeline or CodeBuild count as active users.

⚠️

CI/CD pipelines running on every commit can quickly accumulate Git request charges because the CodePipeline source action counts as a Git request. Monitor usage in Cost Explorer under the CodeCommit service.

🎯

Interview Focus Points

  • 1How does CodeCommit authentication work for federated users who cannot get IAM credentials?
  • 2How do you protect the main branch in CodeCommit from direct pushes?
  • 3What is the difference between CodeCommit triggers, notifications, and EventBridge rules?
  • 4How does CodeCommit pricing work - what counts as an active user?
  • 5How would you set up cross-account access to a CodeCommit repository?
  • 6Why might a team choose GitHub over CodeCommit even when running entirely on AWS?
  • 7What are CodeCommit approval rule templates and what are their limitations?
  • 8How does git-remote-codecommit differ from standard HTTPS credentials?