Category: AWS CodeCommit


New – Notifications for AWS CodeCommit

by Jeff Barr | on | in Amazon SNS, AWS CodeCommit, AWS Lambda | | Comments

AWS CodeCommit is a fully-managed source control service that makes it easy for you to host a secure and highly scalable private Git repository.Today we are making CodeCommit even more useful by adding support for repository triggers. You can use these triggers to integrate your existing unit tests and deployment tools into your source code management workflow. Because triggers are efficient and scalable, they are more broadly applicable than a model that is built around polling for changes. I believe that you will find these triggers to be helpful as you move toward a development methodology based on  Continuous Integration and Continuous Delivery.

All About Notifications
You can create up to 10 triggers for each of your CodeCommit repositories. The triggers are activated in response to actions on the repository including code pushes, branch/tag creation, and branch/tag deletion. Triggers can be set to run for a specific branch of a repository or for all branches.

Triggers can send a notification to an Amazon Simple Notification Service (SNS) topic or can invoke a AWS Lambda function. Each trigger can also be augmented with custom data (an uninterpreted string) that you can use to distinguish the trigger from others that run for the same event. You can use triggers to subscribe to repository events through email or SMS. You can wire up SNS to SQS and queue up jobs for your CI/CD tools, or you can use SNS to activate webhooks provided by your tools. In any case, the actions you designate will be triggered by the changes in your CodeCommit repository. You can also use Lambda functions to trigger builds, check syntax, capture code complexity metrics, measure developer producitivity (less is more, of course), and so forth. My colleagues have also come up with some off-unusual ideas that you can find at the end of this post!

You can create, view, and manage your triggers from the AWS Management Console, AWS Command Line Interface (CLI), or via the CodeCommit API.  I used the Console. The navigation column on the left now includes an entry for Triggers:

I simply click on Create Trigger to get started. Then I select the event (or events), pick the branch (or all branches), and fill in the details that are needed to publish a notification or invoke a Lambda function:

Here’s how I choose the events and branches of interest:

 

Then I point to my SNS topic or Lambda function (after ensuring that the proper permissions are in place), use Test Trigger to make sure that it all works as expected, and click on Create.

You can use Test Trigger to verify that your IAM permissions are working as expected. For example, here’s an error that I triggered on purpose:

I fixed this by reading How to Allow AWS CodeCommit to run the Function in the documentation!

Available Now
This new functionality is available now and you can start using it today.To learn more, read about Managing Triggers for an AWS CodeCommit Repository.

My colleague Clare Liguori suggested some creative uses for CodeCommit triggers, above and beyond the usual integration with your CI/CD process:

  • Video Deployment – Have your Lambda function check to see if a new video or a new version of an existing video has been committed, and deploy the video to YouTube.
  • Party Time – Automatically throw and cater a party (using APIs for sandwiches, pizza, and beer) when you deploy a new release.
  • Advertise Releases – When a new release is ready, automatically generate and run a Facebook ad and publicize the release on social media.

I am looking forward to hearing about the creative ways that you make use of these triggers within your development process. Leave me a comment and let me know!

Jeff;

 

Now Available – AWS CodeCommit

by Jeff Barr | on | in AWS CodeCommit | | Comments

We announced AWS CodeCommit last November (see New AWS Tools for Code Management and Deployment) at AWS re:Invent. I am happy to announce that it is now generally available and that you can start using it today.

Let’s do a quick refresh on the CodeCommit feature set before taking the service for a spin.

CodeCommit Overview
CodeCommit is a managed revision control service that hosts Git repositories and works with existing Git-based tools. Files are organized in to repositories, with no limits on repository size or file count. As you’ll soon see, your existing Git skills, tools, and practices remain applicable.

Behind the scenes, CodeCommit implements Git in a scalable, redundant, and durable fashion so that your code and other assets will be safe and accessible. CodeCommit stores your files in encrypted repositories and uses IAM roles to control developer and administrative access. All data that moves to and from your development environment goes across HTTPS or SSH connections.

CodeCommit runs in the AWS Cloud and is a great fit for situations where your development team works from multiple locations or when you need to collaborate with vendors or other partners.

Here’s what some of our early users had to say about CodeCommit:

“We have hundreds of thousands of video players and were looking for a source control system that would allow us to store each video player code and related web assets in a separate repository. With AWS CodeCommit, we can scale to any number of repositories and don’t have to worry about the repository size. Our developers use the Git interface and tools that they are already familiar with, and we use the same user identities to manage both our AWS infrastructure and AWS CodeCommit.”

Brian Deitte, Architect

Brightcove

“Previously, we were using a centralized version control system that was hosted on-premises. AWS CodeCommit gives us a scalable distributed source control system that is fully managed. We no longer worry about hardware scaling costs and the pay-as-you-go pricing model gives us the flexibility to add or remove users without procuring licenses ahead of time. We can now focus on developing great applications for our consumers and instead let AWS CodeCommit tackle the challenges of managing a highly available source control system.”

Ajit Zadgaonkar, Executive Director, Software Engineering Operations

Edmunds

CodeCommit in Action
In order to gain some real-world experience with CodeCommit, I decided to create a mirror of the AWS SDK for PHP repository. I started out with a fresh EC2 instance running the Amazon Linux AMI. I installed the newest version of the AWS Command Line Interface (CLI), set up my credentials, and installed Git in the usual way:

$ sudo yum install git

I also configured my Git identity:

$ git config --global user.name "Jeff Barr"
$ git config --global user.email jbarr@amazon.com

I configured my AWS CLI to reference IAM user awscli by default. I gave this user permission to perform administrative actions on my CodeCommit repositories by attaching the AWSCodeCommitFullAccess policy:

This policy, as the name implies, allows me to perform all of the CodeCommit operations on all of my repositories. In a real-world environment, a more restrictive set of permissions would be more appropriate. For example, you might want to allow only certain senior developers to create and delete repositories.

Then I configured Git so that it could authenticate itself to CodeCommit. I instructed it to use a credential helper as follows:

$ git config --global credential.helper '!aws codecommit credential-helper $@'
$ git config --global credential.UseHttpPath true

Because the credential helper is supplied as part of the aws command, the Git configuration setting can include a reference to any of the profiles that I have configured for use with the CLI. This option would be helpful if I was working on several projects in distinct repositories, each with individual credentials. In that case I would set the credential.helper on a per-repo basis like this:

$ cd repo1
$ git config --local credential.helper '!aws codecommit --profile jb_repo1 credential-helper $@' 
$ cd ../repo2
$ git config --local credential.helper '!aws codecommit --profile jb_repo2 credential-helper $@' 

With Git configured, I created my repository using the Console (I could have used the CLI’s create-repository command as well):

My repository was available for use right away! My CodeCommit Dashboard allowed me to see all of my repositories at a glance:

I was ready to add some content to the AWS_PHP_SDK repo, so I clicked on the URL icon and captured the HTTPS URL (the SSL URL is also available via the icon):

Then I cloned a copy of the SDK and pushed it to my repo:

$ git push https://git-codecommit.us-east-1.amazonaws.com/v1/repos/AWS_PHP_SDK --all
Counting objects: 28690, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9608/9608), done.
Writing objects: 100% (28690/28690), 12.91 MiB | 625.00 KiB/s, done.544.00 KiB/s
Total 28690 (delta 16604), reused 28686 (delta 16603)

To https://git-codecommit.us-east-1.amazonaws.com/v1/repos/AWS_PHP_SDK
* [new branch] 2.8 -> 2.8
* [new branch] master -> master

I was about to learn more about my repo via the Console:

I also had the option to rename the repo and to adjust other settings:

Available Now
CodeCommit is available now and you can start using it today!

You will be charged $1 per active user (defined as a unique IAM user or role, a federated user, or the root account) per month. You can store as many Git repositories as you’d like.

Each user comes with an allowance of 10 GB of storage and 2,000 Git requests (a push or pull that transmits repository objects) per month, all pooled across the users with each AWS account. Additional storage costs $0.06 per GB per month; additional requests are $0.001 each.

As part of the AWS Free Tier, new and existing customers can benefit from 5 active users, 50 GB of storage, and 10,000 Git requests per month at no charge.

In the Works
We have big plans for CodeCommit! Here are some of the things that we are working on next:

  • Post-Receive Hooks – You will be able to have CodeCommit call external systems after each push to a repository. This will allow you to do things like notify a Continuous Integration (CI) server that new code is ready to be built and tested.
  • CloudTrail Support – Your calls to the CodeCommit API will be recorded and available for auditing.
  • More Regions – We are launching in the US East (Northern Virginia) region today. We plan to expand to additional regions over time.
  • Additional UI Features – We are working to build out a complete web-based UI for your source code repositories.

Jeff;