Push the code

Ignore the build artifacts

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. We will paste the following into a .gitgnore file.

Create the file

cd ~/environment/sam-app
touch .gitignore

In Cloud9, remember to enable hidden files:

EnableHiddenFiles

Open the .gitignore file and paste the two lines below.

.aws-sam/
packaged.yaml

Remember to save the file (File> Save or CMD +S etc)

GitIgnore

From the root directory of your sam-app project, run the following commands:

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

Example: GitCommit

Push the code

Add your CodeCommit repository URL as a remote on your local git project.

git remote add origin codecommit://sam-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

Example:

GitPush

Verify in CodeCommit

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

VerifyCodeCommit