CI/CD pipeline on AWS-Code Commit

CI/CD pipeline on AWS-Code Commit

ยท

5 min read

Introduction:)

Day 50 of #90DaysOfDevOps brings us to a pivotal task where we delve into AWS CodeCommit, a powerful source control service. We'll set up repositories, establish GitCredentials, and work through the process of version control, ensuring a seamless development workflow.

What is Code Commit?

AWS CodeCommit is a fully managed source control service provided by Amazon Web Services (AWS). It's a version control service that makes it easy for teams to host secure and scalable Git repositories. It allows you to store code, documents, and other assets, track changes, and collaborate with team members.

  • AWS CodeCommit is an alternative to traditional code hosting platforms like GitHub.

  • It serves as a version control system for hosting code repositories within the AWS ecosystem.

  • CodeCommit provides features such as secure storage of code, collaboration capabilities, and integration with other AWS services.

Traditional CI/CD Tools vs. AWS Managed Services

AspectTraditional CI/CD ToolsAWS Managed Services
Version ControlTools like GitHub, GitLab, and Bitbucket are commonly usedAWS CodeCommit is a managed Git service
for version control.designed to securely host repositories.
Pipeline OrchestrationJenkins is a widely used tool for orchestrating CI/CDAWS CodePipeline is a fully managed service
pipelines.for creating and managing CI/CD pipelines.
Building ApplicationsTools like Docker, Jenkins (with plugins), and othersAWS CodeBuild is a fully managed build service
are used for building applications.that compiles source code, runs tests, and produces ready-to-deploy software packages.
DeploymentTools like Jenkins, Kubernetes, or custom shell scripts are used for deploying applications.AWS CodeDeploy is a fully managed deployment service that automates software deployments to various compute services, including EC2, Lambda, and on-premises instances.

Benefits of Using CodeCommit

  1. Fully Managed Service: AWS handles infrastructure, maintenance, and scaling.

  2. Integration with AWS Services: Works seamlessly with AWS CodePipeline, CodeBuild, and CodeDeploy.

  3. Security and Compliance: Provides encryption, IAM access control, and KMS integration.

  4. Scalability: Handles large repositories and concurrent users effectively.

  5. Global Availability: Accessible in multiple AWS regions worldwide.

  6. Private Repositories: Offers confidentiality for code access.

  7. Branching and Merging: Supports collaborative development workflows.

  8. Code Reviews and Pull Requests: Facilitates code quality maintenance.

  9. Web-Based Interface: User-friendly for repository management.

  10. Cross-Account Access: Allows sharing between AWS accounts.

  11. Notifications and Triggers: Sends updates via SNS or Lambda functions.

  12. Cost-Effective: Eliminates the need for external version control systems.

Tasks:)

Task 1:

  • Set up a code repository on CodeCommit

    1. Go to the AWS Management Console.

    2. Navigate to the "CodeCommit" service.

    3. Click on the "Create repository" button.

    4. Provide a name for your repository, and optionally, a description.

    5. Click on "Create repository".

  • Set up GitCredentials in AWS IAM

    1. Access IAM in AWS Console:

      • Go to the AWS Management Console.

      • Navigate to "IAM" (Identity and Access Management) from the services.

    2. Select Users:

      • In the left navigation pane, click on "Users".

    3. Choose IAM User:

      • Select the IAM user that will be used for Git access.

      • Ensure the user has policies like "AWSCodeCommitFullAccess" and "AWSCodeCommitPowerUser" attached.

    4. Generate Git Credentials:

      • Under the "Security credentials" tab, click "Create access key" to generate GitCredentials.

    5. Navigate to Repository:

      • Go back to the AWS CodeCommit service.

      • Select the repository you created earlier.

    6. Add a File:

      • Inside the repository, click on "Create file".

      • Add the necessary information for the file.

    7. Copy Repository URL:

      • Copy the HTTPS URL doing simply click on the clone URL of the repository for future use.

  • Clone the Repository regionally

    1. Open your Terminal:

      Open your terminal to execute the subsequent instructions.

    2. Execute the Clone Command:

      In the terminal, run the following command, replacing <your-codecommit-repo-clone-https-url> with the URL of your CodeCommit repository:

       git clone <your-codecommit-repo-clone-https-url>
      
    3. Start Working:

      You are now ready to start working with your code

Task 2:

  • Adding a New File, Committing Locally, and Pushing to CodeCommit Repository

    1. Create a New File Locally:

      • In your local repository directory, create a new file with the desired content.

    2. Stage and Commit the New File:

      • In your terminal, navigate to your local repository.

      • Use the following commands:

          git add <filename>   # Replace <filename> with the actual name of your new file
          git commit -m "Added a new file"
        

    3. Push Changes to CodeCommit:

      • In your terminal, use the following command to push the changes to your CodeCommit repository:

          git push origin <brach-name>   # Assuming 'main' is your branch name, replace if needed
        

        To check the branch name:

        1. Go to the repository that you want to know the branch name

        2. Navigate to the branch from the left-hand side panel

        3. You will get your Branch name

      • If prompted, enter your GitCredentials (username and password) which were set up earlier.

    4. Verify changes on CodeCommit:

      • Go to the AWS CodeCommit console and navigate to your repository.

      • You should see the newly added file in the repository.

Conclusion:)

In today's task, we successfully navigated AWS CodeCommit, understanding its role in version control. We adeptly set up repositories, configured GitCredentials, and seamlessly managed code locally and on the cloud. This experience further enriches our journey in mastering DevOps practices. Onward to more exciting explorations!


Thank you for diving into this blog with me! I trust you found the information both helpful and enlightening. To stay updated on the latest in DevOps ๐Ÿš€, make sure to follow me. Remember, staying informed means staying ahead in the dynamic world of DevOps!

Feel free to connect with me on:

LinkedIn

Twitter

GitHub

For more updates and engaging discussions on DevOps, let's connect! ๐Ÿš€ #DevOpsCommunity

Happy Learning! Keep pushing those boundaries! ๐Ÿ˜Š

ย