AWS CodeCommit Integration
Note: AWS CodeCommit is deemphasized for new customers after July 25, 2024. Consider using S3-based or GitHub repositories instead for new projects.
Configuration
Configure your pipeline to use CodeCommit in cicd.config.ts:
import { defineCICD, Repository } from '@cdklabs/cdk-cicd-wrapper';
export default defineCICD({
application: 'my-app',
repository: Repository.codecommit('my-repo'), // defaults to the 'main' branch
stages: ['dev', 'prod'],
});
Pass a second argument to track a different branch:
repository: Repository.codecommit('my-repo', 'trunk'),
Repository creation
By default, Repository.codecommit('my-repo') creates the CodeCommit repository as part of the pipeline stack — so a single cdk-cicd deploy-ci gives you both the pipeline and an empty repository to push to. This matches the Blueprint (0.x) behaviour, where naming a CodeCommit source provisioned the repository for you.
If the repository already exists (for example, it is managed elsewhere, or shared across pipelines), pass { existing: true } to import it by name instead of creating it:
repository: Repository.codecommit('my-repo', 'main', { existing: true }),
An imported repository must already exist at deploy time; a created one is provisioned with the CDK default removal policy (retained on stack deletion, so your source history is not lost).
Repository.codecommit(...) names the CodeCommit repository the pipeline reads from. Unlike Blueprint (0.x)'s RepositorySource.codecommit(...), there is no enableCodeGuruReviewer/enablePullRequestChecks option: Amazon CodeGuru Reviewer pull-request automation is not part of Autopilot. If you relied on that, cdk-cicd security-scan/cdk-cicd check (Bandit, Semgrep, ShellCheck, dependency audit — see the Security guide) run in the pipeline's CI build instead, but they are not PR-time checks against a CodeCommit pull request specifically.
Pushing to the repository
Once the pipeline is deployed (cdk-cicd deploy-ci), install git-remote-codecommit locally and push your branch:
sudo pip3 install git-remote-codecommit
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git remote add origin "codecommit::${AWS_REGION}://${GIT_REPOSITORY}"
git push -u origin "${CURRENT_BRANCH}:main"
The branch pushed to must match the branch Repository.codecommit(...) names (main unless you passed a second argument).