CodeCommit is a git service in AWS, you can own the private repository just a small fee, if you are personal or small group will be not charged any fee in some way.
Well, I will deploy my application from CodeCommit to EC2, below is my way. First I created a repository in CodeCommit.
Before create a new EC2 instance, add a new IAM role.
Now you will see this screen, click select button in Amazon EC2.
Input CodeCommit in filter and click AWSCodeCommitReadOnly.
Now review the IAM role, if no any problem then click Create Role.
OK, let’s check the role, you will see something like below.
Now I can create a new EC2 instance and assign a role, this step is important, do not forgot!
Well done, I can start setting my EC2 instance, first thing is check AWS CLI version, CodeCommit only working with AWS CLI 1.7.38 and later, type aws –version in terminal and check the version. For Debian will needs upgrade AWS CLI version, just follow steps.
When done, setting git config, just two commands.
Now clone git repository from CodeCommit.
For now, my EC2 can direct clone repository from CodeCommit and do not need setting AWS CLI credential, let me know if you have any question, thanks!