Menu
AWS for DevOps
Getting Started Guide

Step 2.3: Launch an Amazon EC2 Instance to Access the AWS CodeCommit Repository

Although you could set up your local workstation to connect to the repository you created in Step 2.1: Create a Repository, in this step you will use an AWS CloudFormation template to launch an Amazon EC2 instance running Amazon Linux. (To view the contents of the AWS CloudFormation template, see CodeCommitInstance.template.)

This instance allows users to log in to it by using the SSH protocol. The instance has permission to take any AWS CodeCommit action for any AWS CodeCommit repository across the AWS account. AWS CloudFormation runs commands on the instance to set up the Git credential helper for AWS CodeCommit, clone the repository's contents onto the instance, and establish the user name and email address for all commits to the repository. (Later, in Step 2.4: Explore the Cloned Repository, you will log in to the instance and confirm that you successfully cloned the repository onto the instance.)

To learn how to set up your local workstation to connect to AWS CodeCommit, see the following topics in the AWS CodeCommit User Guide:

To launch an Amazon Linux instance set up with AWS CodeCommit

  1. Use the AWS CloudFormation console to create a stack in the US East (N. Virginia) region based on the following Amazon S3 template URL: https://s3.amazonaws.com/aws-for-devops/cfn-templates/CodeCommitInstance.template

    On the Specify Details page, for Type, type the Amazon EC2 instance type to launch (for example, t2.micro).

    For KeyPair, type the name of the key pair that you will use to log in to the instance (for example, the key pair you created in Step 2.2: Create an Amazon EC2 Key Pair).

    For Tag, type a tag for the instance to help you more easily identify it in places such as the Amazon EC2 console (for example, CodeCommitInstance).

    For CloneURL, type the HTTPS clone URL for the repository that you noted in Step 2.1: Create a Repository.

    For LocalRepo, type the name of the subdirectory to create in the /home/ec2-user directory on the instance and then clone the repository into (for example, my-demo-repo). If you choose a different name, substitute it for my-demo-repo throughout this walkthrough.

    For UserName, type the user name you want to associate with all commits to the repository.

    For UserEmail, type the email address you want to associate with all commits to the repository.

  2. When CREATE_COMPLETE is displayed for Status for the stack, you can explore the resources created by the stack. Otherwise, go to Step 2.4: Explore the Cloned Repository.

To explore the Amazon EC2 resources created by the stack

  1. In the AWS CloudFormation console, choose the Resources tab for the stack.

  2. To view details about the newly launched instance, for CodeCommitInstance, choose the Physical ID link.

  3. To view details about the newly created security group, on the Description tab in the Amazon EC2 console for the instance, choose the Security groups link.

To explore the IAM resources created by the stack

  1. In the AWS CloudFormation console, choose the Resources tab for the stack.

  2. To view the newly created IAM instance profile, for CodeCommitInstanceProfileRole, choose the Physical ID link.

  3. Go to Step 2.4: Explore the Cloned Repository.