Let’s go through the instructions to upload the code to AWS CodeCommit.
In the terminal tab, run this command to create a repository
aws codecommit create-repository --repository-name api
Copy the value of cloneUrlHttp, you will need it later.
One of the cool things about CodeCommit is the support for IAM authentication. And if you are running this workshop from a Cloud9 workspace, you can leverage the fact that your terminal is already pre-authenticated with valid AWS credentials.
Configure the git client with username and email, so your commits have an author defined.
git config --global user.name "First Last"
git config --global user.email "first.last@example.com"
Open the api/.gitgnore file from the file navigation pane. Copy and paste the following line to the end of the file. There is no need to track the .aws-sam/build directory as they are re-generated on every build.
.aws-sam/build
Go back to the Cloud9 terminal tab. Let’s initialise the local repository, add the files, and commit.
git init -b main
git add .
git commit -m "Initial commit"
Add your CodeCommit repository URL as a remote on your local git project.
git remote add origin codecommit://api
Now push the code.
git push -u origin main