AWS DevOps Assignment - 1
Problem Statement: You work for XYZ Corporation. Your corporation wants the files to be stored on a private repository on the AWS Cloud.
Tasks To Be Performed:
- Create a CodeCommit repository and import a GitHub repository content into it.
1. Creating an IAM User:
- I log into AWS.
- I navigate to IAM.
- I create a user named “GitUser.”
- I attach the
AWSCodeCommitFullAccess
policy.
2. Uploading Public SSH Key to the IAM User:
- I click on the user.
- I select the “Security credentials” tab.
- I press the “Upload SSH public keys” button.
- A window appears.
- I paste my public key into the provided input box.
- I click the “Upload SSH public key” button.
- Once done, AWS gives me an SSH Key ID.
- I note down this ID for future use.
3. Setting Up the SSH Client:
- I open the
~/.ssh/config
file, or create it if it doesn’t exist. - I add the following configuration:
Host git-codecommit.*.amazonaws.com User APKAG4NQRHE3SUWI647 IdentityFile ~/.ssh/id_rsa
4. Set Up CodeCommit Repository
- I go to AWS CodeCommit in the AWS Management Console.
- I click the “Create repository” button.
- I name the repository “Packer”, matching the GitHub repo name.
- I press “Create”.
5. Cloning GitHub Repository
I navigate to my GitHub repository and copy the SSH URL: git@github.com:hectorproko/Packer.git
.
On my local machine, I run:
git clone git@github.com:hectorproko/Packer.git
cd Packer
6. Adding CodeCommit Repository as a New Remote:
I go to the AWS CodeCommit console and navigate to the repository I just set up. I click on the Clone URL dropdown and choose Clone SSH, then I copy this URL.
Back in my local repository directory on my machine, I enter:
git remote add codecommit ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Packer
To verify the remote was successfully added, I type:
git remote -v
7. Pushing Repository Content to CodeCommit:
Ensuring my SSH setup is correct, I can now push my local repository content to CodeCommit. I use the command:
git push codecommit main
8. Verifying the Repository Content:
I open the CodeCommit repository in the AWS Management Console. By checking the listed files and their commit history, I ensure they match what’s in my original GitHub repository.
Success
The files in CodeCommit are the same as those in my GitHub repository.