Your CI/CD pipeline on AWS - Part-1

Your CI/CD pipeline on AWS - Part-1

#90 DaysofDevOps Challenge - Day 50

What is CodeCommit?

AWS CodeCommit is a fully managed source code repository service provided by Amazon Web Services (AWS). It offers a secure and scalable platform for storing and managing your code repositories in the cloud. In simple terms, CodeCommit is a service that allows you to securely store and version your code, making it easier to collaborate with team members and manage changes to your software projects.

With CodeCommit, you can create private Git repositories to host your code. It provides a reliable and highly available infrastructure, ensuring that your code is stored securely and accessible whenever you need it. CodeCommit supports all Git commands, allowing you to perform typical version control operations like creating branches, committing changes, and merging code.

Some key features and benefits of CodeCommit include:

  1. Secure and Scalable: CodeCommit utilizes AWS security best practices, including encryption at rest and in transit, access control, and fine-grained permissions. It can scale to accommodate large codebases and teams.

  2. Integration with DevOps Tools: CodeCommit seamlessly integrates with other AWS services and popular development tools, such as AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy. This enables end-to-end automation and streamlined workflows in your software development lifecycle.

  3. Collaboration and Teamwork: Multiple developers can work on the same codebase simultaneously, making it easy to collaborate and track changes. CodeCommit allows you to manage access permissions, branch policies, and code reviews, ensuring proper control and visibility over your code.

  4. Code Versioning and History: CodeCommit automatically tracks and maintains a complete history of your code changes. You can easily compare versions, revert changes, and track who made specific changes, providing a clear audit trail.

  5. Easy Migration and Integration: CodeCommit is compatible with Git, making it straightforward to migrate existing repositories or integrate with Git-based tools and workflows. You can push and pull code using standard Git commands or popular Git clients.


Task-01 :

  • Set up a code repository on CodeCommit and clone it on your local.

  • You need to set up GitCredentials in your AWS IAM.

  • Use those credentials in your local and then clone the repository from CodeCommit

Here are the steps to set up the repository, configure Git credentials, and clone the repository locally:

  • Create a CodeCommit Repository:

    • Go to the AWS Management Console and navigate to the CodeCommit service.

    • Click on "Create repository" and name it "demo-app".

NOTE:- You are signed in using a root account. You cannot configure SSH connections for a root account, and HTTPS connections for a root account are not recommended. Consider signing in as an IAM user and then setting up your connection.

  • Configure Git Credentials in AWS IAM:

    • Go to the AWS Management Console and navigate to the IAM service.

    • In IAM, create a new user.

    • Add the necessary permissions for the user to access CodeCommit like AWScodeCommitPowerUser policy).

    • Generate Git credentials for this user:

      * Under the "Security credentials" tab of the user, click on the "Create access key."

      * Download or take note of the "Access key ID" and "Secret access key" that will be generated. You will use these to configure Git credentials locally.

  • Configure Git Credentials Locally and Clone the CodeCommit Repository:

    • Open your terminal on your local machine where you want to clone the repository.

  • Go back to the AWS Management Console and navigate to the "demo-app" repository in CodeCommit.

  • Click on the "Clone URL with HTTPs" button to get the repository URL.

  • In your terminal, navigate to the directory where you want to clone the repository.

  • Clone the repository using Git:

      git clone <repository_url> #https://git-codecommit.us-east-1.amazonaws.com/v1/repos/demo-app
    

    Replace <repository_url> with the URL obtained from the CodeCommit repository.

  • Enter the "username" and "password" when prompted.

  • Now, you have cloned the CodeCommit repository locally.


Task-02 :

  • Add a new file from local and commit to your local branch

  • Push the local changes to the CodeCommit repository.

To add a new file locally, commit it to your local branch, and then push the changes to the CodeCommit repository.

  • Create and Add a New File Locally:

    • Navigate to the directory where you recently cloned the CodeCommit repository on your local machine.

    • Create a new file in the project directory such as index.html

  • Add and Commit the New File Locally:

    • Use the following Git commands to add and commit the new file to your local branch:

        git add .
        git commit -m "added demo-app sample file"
      
  • Push Local Changes to CodeCommit Repository:

    After committing the changes locally, you can push them to the CodeCommit repository using the following Git command:

      git push origin <your_branch_name> #Replace <your_branch_name> with the name of the branch you are working on.
      git push origin master
    

    If you are working on a different branch, replace master with the appropriate branch name.

  • Verify Changes in CodeCommit:

    • Go back to the AWS Management Console and navigate to your CodeCommit repository.

    • You should see the newly added index.html


Thank you for reading. I hope you were able to understand and learn something new from my blog.

Happy Learning!

Please follow me on Hashnode and do connect with me on LinkedIn ArnavSingh.

Did you find this article valuable?

Support Arnav Singh by becoming a sponsor. Any amount is appreciated!