Table of contents
- What is CodeCommit?
- Why do we use CodeCommit?
- Features of AWS CodeCommit:
- Task-01 :
- <mark>Let's Setup an IAM User for AWS CodeCommit.</mark>
- <mark>How to add HTTP GitCredentials in your AWS IAM.</mark>
- <mark>Set up a code repository on CodeCommit and clone it on your local.</mark>
- <mark>Before Moving to TASK-02, Let's create a New EC2 Instance and Install Git in it so that we can clone the repository in our local machine.</mark>
- Task-02 :
In the Upcoming next 4 days, I will be making a CI/CD pipeline
on AWS with these tools.
CodeCommit
CodeBuild
CodeDeploy
CodePipeline
S3 Bucket
What is CodeCommit?
- AWS CodeCommit is a fully-managed source control service that hosts secure Git-based repositories. It makes it easy for teams to collaborate on code in a
secure
andhighly scalable
ecosystem.CodeCommit
eliminates the need to operate yourown source control system
or worry aboutscaling its infrastructure
. We can use CodeCommit tosecurely store
anything fromsource code
tobinaries
, and it works seamlessly with your existingGit tools
.
Why do we use CodeCommit?
- CodeCommit is a
managed source control service
by AWS allows users tostore
,manage
, andversion
theirsource code
andartifacts
securely and at scale. It supportsGit
, integrates with other AWS services, and enables collaboration throughbranch
andmerge
workflows, and providesaudit logs
andcompliance reports
to meet regulatory requirements and track changes. Overall, CodeCommit provides developers with a reliable and efficient way to manage their codebase and set up aCI/CD pipeline
for theirsoftware development projects
.
Features of AWS CodeCommit:
Collaborative Software Development:
AWS CodeCommit
facilitatescollaboration
among software development teams by providing version control capabilities such ascode commit
,branching
, andmerging
,ensuring smooth teamwork
andproject management
.Secure Data Transfer and Storage:
CodeCommit allows users totransfer code
to and fromrepositories
securely using HTTPS or SSH. Additionally, repositories areautomatically encrypted
at rest throughAWS Key Management Service
(KMS) using customer-specific keys, ensuring data security.Access Control and Monitoring:
AWS Identity
andAccess Management (IAM)
is used tocontrol
andmonitor
access toCodeCommit repositories
, allowing administrators toset permissions
forindividuals
orgroups
andtrack repository access
through AWS CloudTrail and AWS CloudWatch.High Availability and Durability:
CodeCommit stores repositories
in Amazon S3 and Amazon DynamoDB,leveraging the redundancy
of these services to providehigh availability
anddurability
for your codebase across multiple facilities.Easy Integration and Notifications:
CodeCommit supports all Git commands
, enablingseamless integration
with existingGit tools and workflows
. Users can receive notifications forrepository events
throughAmazon SNS
, andcustom scripts
orAWS Lambda functions
can be triggered in response to these events foradditional automation and notifications
.
Task-01 :
Let's Setup an IAM User for AWS CodeCommit.
Step-01:
Go to the IAM service inAWS Console
.
Step-02:
Click onUsers
and then click onAdd User
.
Step-03:
Enter theUser name
and then provide console access to person"IAM USER"
and create acustom password
for the user so that whenever login to the console, the user will be asked to change the password forsecutiry reasons
.
Step-04:
Click onNext:Permissions
and then click onAttach existing policies directly
and then selectAWSCodeCommitFullAccess
then click onNext:Tags
.
Step-05:
Click onNext:Review
and then click onCreate User
.
Step-06:
Now, click onDownload .csv
it and save it on your local machine for future use.
- Thus we have Successfully created an IAM User with
AWSCodeCommitFullAccess
a policy.
How to add HTTP GitCredentials in your AWS IAM.
Step-01:
Go to IAM > Users > Security Credentials.
Step-02:
Scroll down toHTTPS Git credentials for AWS CodeCommit
and then click onGenerate credentials
HTTPS Git credentials for AWS CodeCommit > Generate > Download Credentials.
- Thus we have
Generated Credentials
for ourIAM User
.
Set up a code repository on CodeCommit and clone it on your local.
Step-01:
Go to the CodeCommit service inAWS Console
.
Step-02:
Click onCreate repository
.
Step-03:
Enter theRepository name
and then click onCreate repository
.
Step-04:
Now, click onClone URL
and then copy theHTTPS URL
.
Before Moving to TASK-02, Let's create a New EC2 Instance and Install Git in it so that we can clone the repository in our local machine.
Step-01:
Go to the EC2 service inAWS Console
.
Step-02:
Click onLaunch Instance
.
Step-03:
SelectUbuntu, SSD Volume Type
and then click onSelect
.
Step-04:
Selectt2.micro
and then selectkeypair
.
Step-05:
Click onNetwork Settings
.
- Thus we have created EC2 instance on which we can use our
CodeCommit
HTTPS URL to clone the repository.
- Now log in the EC2 instance via SSH and open Terminal.
Task-02 :
Before Doing anything check if Git is installed in the EC2 instance for use
sudo apt update
sudo apt install git
Clone the repository in your local machine.
git clone <HTTPS URL>
# The URL which is copied from CodeCommit
# Enter the UserName and Password which we downloaded for HTTP and git credentials.
- After this, we can see that the
repository
iscloned
in ourlocal machine
.
ls
cd <repository which we have cloned>
Add a new file from local and commit to your local branch.
Step-01:
Create annew file
in therepository
which we havecloned
.
touch file{01..05}.txt
- From now here we will use
Git Commands
.
# For Example
git add
git status
git commit -m
git push
Step-02:
We will use git status to check the status of the repositoryunstaged
orstaged
.
git status
Step-03:
We will usegit add to add
the files to the staging area.
# git add . will add all the files to staging area.
git add .
Step-04:
Now we will usegit commit -m
to commit the files to the local branch.
# git commit -m <Your Message>
git commit -m "Added 5 files"
Step-05:
Now we will usegit push
to push the files to the remote repository.
git push origin master
So we can check Pushed the local changes to the CodeCommit repository.
Step-01:
Go toCodeCommit
service inAWS Console
.
Step-02:
Click onRepositories
and then click onRepository Name
.
Thus we have pushed the local changes to
CodeCommit
repository.