a. Create a repo in CodeCommit

This lab requires an AWS Cloud9 IDE. If you do not have an AWS Cloud9 IDE set up, complete the Prepartion section of the workshop.

  1. In the AWS Management Console search bar, type and select Cloud9.

  2. Choose open IDE for the Cloud9 instance set up previously. It may take a few moments for the IDE to open. AWS Cloud9 stops and restarts the instance so that you do not pay compute charges when no longer using the Cloud9 IDE.

  3. Next, we’ll use the AWS Command Line Interface (CLI) to create a Git repository in AWS CodeCommit and clone the empty repo in your Cloud9 environment.

  4. Set AWS Region

AWS_REGION=$(curl --silent http://169.254.169.254/latest/meta-data/placement/region)
echo "export AWS_REGION=${AWS_REGION}"
  1. Next create your CodeCommit Repo:

AWS CodeCommit is a secure, highly scalable, managed source control service that hosts private Git repositories.

aws codecommit create-repository --repository-name MyDemoRepo --repository-description "My demonstration repository" --tags Team=SC21 --region $AWS_REGION
  1. Get repository URL to clone:
REPOURL=$(aws codecommit get-repository --repository-name MyDemoRepo --query repositoryMetadata.cloneUrlHttp --output text --region $AWS_REGION)
echo $REPOURL

Verify echo $REPOURL outputs a repo url like https://git-codecommit.<region>.amazonaws.com/v1/repos/MyDemoRepo

  1. Clone the repository in your Cloud9 terminal and cd into it:
git clone $REPOURL
cd MyDemoRepo/

You can ignore the warning shown [warning: You appear to have cloned an empty repository]

  1. Now let’s update the default branch from master to main:
git branch -m master main