Push the code

Ignore the build artifacts

Add the following lines to sls-app/.gitignore file. There is no need to track the .aws-sam directory or the packaged.yaml under version control as they are re-generated on every build.

.aws-sam/
packaged.yaml

In Cloud9, remember to enable hidden files. Open the .gitignore file and paste the two lines described above.
.gitignore From the root directory of your sls-app project, run the following commands:

cd ~/environment/sls-app
git init
git add .
git commit -m "Initial commit"

Init

Push the code

Add your CodeCommit repository URL as a remote on your local git project. This is the cloneUrlHttp value that you got back after creating the repository in Step 1 of this chapter.

git remote add origin https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/sls-app

If you can’t find the CodeCommit repository URL, you can find it by running this command: aws codecommit get-repository --repository-name sls-app.
If you typed the origin url incorrectly, you can remove it by running: git remote rm origin.

Now push the code:

git push -u origin master

Push

Verify in CodeCommit

Navigate to the AWS CodeCommit console , find your sls-app repository and click on it to view its contents. Make sure your code is there. You should see a screen like the following: Verify