AWS CodeCommit
AWS CodeCommit is a version control service that enables you to privately store and manage Git repositories in the AWS cloud.
For further information on CodeCommit,
see the AWS CodeCommit documentation.
To add a CodeCommit Repository to your stack:
import codecommit = require('@aws-cdk/aws-codecommit');
const repo = new codecommit.Repository(this, 'Repository' ,{
repositoryName: 'MyRepositoryName',
description: 'Some description.',
});
To add an Amazon SNS trigger to your repository:
repo.notify('arn:aws:sns:*:123456789012:my_topic');
AWS CodePipeline
To use a CodeCommit Repository in a CodePipeline:
import codepipeline = require('@aws-cdk/aws-codepipeline');
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', {
pipelineName: 'MyPipeline',
});
const sourceAction = new codecommit.PipelineSourceAction({
actionName: 'CodeCommit',
repository: repo,
});
pipeline.addStage({
name: 'Source',
actions: [sourceAction],
});
You can also create the action from the Repository directly:
const sourceAction = repo.toCodePipelineSourceAction({ actionName: 'CodeCommit' });
Events
CodeCommit repositories emit Amazon CloudWatch events for certain activities.
Use the repo.onXxx
methods to define rules that trigger on these events
and invoke targets as a result:
repo.onCommit('CommitToMaster', project, 'master');
const rule = repo.onCommentOnPullRequest('CommentOnPullRequest');
rule.addTarget(myTopic);