23

AWS CodeCommit and Windows Git: Repository Management

 4 years ago
source link: https://www.tuicool.com/articles/fIvEFjY
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Amazon CodeCommit allows for secure storing of repositories in the AWS cloud. While GitHub is commonly used when sharing repositories, AWS CodeCommit is frequently used by companies who are looking for more privacy in repository storage.

The below example illustrates how to create a repository in AWS CodeCommit, and clone and push to the relevant repository. For this particular example, I used a local copy of the hotel-cancellations-lstm repository. However, the below steps can be carried out with any repository of your choice.

To start off — one needs to create an IAM account in order to form a repository with AWS CodeCommit.

In the AWS Management Console, navigate to IAM (Identity and Access Management).

1. Click on Users and select “Add User”.

uuMBriR.png!web

Assign a name to this new user and allow Programmatic Access and AWS Management Console access. This is also where a password for the relevant user account is added.

2. Apply the following permissions policies.

  • AWSCodeCommitPowerUser
  • AWSCodeCommitFullAccess
  • AWSCodeCommitReadOnly

eIJ3qqb.png!web

3. The next step is to generate HTTPS credentials for AWS CodeCommit. This is necessary in order to allow for cloning the repository locally, and subsequently pushing back to the AWS cloud.

QVZvqmE.png!web

Click “Generate” under HTTPS Git Credentials for AWS CodeCommit, and a notice with the relevant credentials will display:

ErquEnE.png!web

Under the Sign-in credentials tab, you are provided with the link to sign into the new console, e.g. https://123456789.signin.aws.amazon.com/console

yUfUFr7.png!web

4. Now that the account has been set up, the next task is to clone the repository, and then push back with Git.

Go to Developer Tools -> CodeCommit -> Repositories -> Create repository , and assign a name to the new repository.

ZNR7jeQ.png!web

The repository now appears in the Repositories section. There is an option to clone the URL — in this case select HTTPS.

qeIFvaR.png!web

In this case, let us assume the name of the link is https://git-codecommit.location.amazonaws.com/v1/repos/hotellstmuser. However, the exact link will depend on which location you are using, and the name of the repository.

5. The empty repository is cloned, the relevant files are inserted locally, and the repository is pushed back to AWS.

git clone is used to clone the repository.

>>> C:\Users\michaeljgrogan>cd C:\Users\michaeljgrogan\Documents>>> C:\Users\michaeljgrogan\Documents>git clone https://git-codecommit.location.amazonaws.com/v1/repos/hotellstmuser
Cloning into 'hotellstmuser'...
warning: You appear to have cloned an empty repository.

Note that when the repository is cloned, it is necessary to enter the appropriate username and password — these are the HTTPS Git credentials that were generated when the repository was created:

uaqARr3.png!web

Now, it is necessary to navigate to the local clone of the repository and add the relevant files.

>>> C:\Users\michaeljgrogan\Documents>cd C:\Users\michaeljgrogan\Documents\hotellstmuser>>> C:\Users\michaeljgrogan\Documents\hotellstmuser>git init
Reinitialized existing Git repository in C:/Users/michaeljgrogan/Documents/hotellstmuser/.git/

The relevant files are added locally:

YrY3M3u.png!web

The files are then added and pushed to the repository on AWS CodeCommit. git add , git commit , and git push are used for this purpose.

>>> C:\Users\michaeljgrogan\Documents\hotellstmuser>git add .
warning: LF will be replaced by CRLF in H1full.csv.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in H2full.csv.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in _config.yml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in hotel_cancellations lstm h1.ipynb.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in hotel_cancellations lstm h2.ipynb.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in index.md.
The file will have its original line endings in your working directory.>>> C:\Users\michaeljgrogan\Documents\hotellstmuser>git commit -m "initial commit"
[master (root-commit) 89c7c7e] initial commit
 13 files changed, 129725 insertions(+)
 create mode 100644 H1full.csv
 create mode 100644 H2full.csv
 create mode 100644 README.md
 create mode 100644 _config.yml
 create mode 100644 arima-model.png
 create mode 100644 cancellationweeks.png
 create mode 100644 h1predictiongraph.png
 create mode 100644 h2predictions.png
 create mode 100644 hotel_cancellations lstm h1.ipynb
 create mode 100644 hotel_cancellations lstm h2.ipynb
 create mode 100644 index.md
 create mode 100644 predicted-vs-test-2.png
 create mode 100644 predicted-vs-test.png>>> C:\Users\michaeljgrogan\Documents\hotellstmuser>git push -f origin master
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.84 MiB | 299.00 KiB/s, done.
Total 14 (delta 1), reused 0 (delta 0)
To https://git-codecommit.location.amazonaws.com/v1/repos/hotellstmuser
 * [new branch]      master -> master

IVJBBnz.png!web

In some instances, it might be the case that incorrect credentials are entered the first time — and a 403 error message subsequently appears when attempting to access the repository.

Should this happen, the same can be deleted through Windows Credentials (this can be found through the Windows search bar):

IRzmYb3.png!web

When it comes to cloning the repository locally once again, this is done using git clone as before. However, in this instance, the local repository will now contain the relevant files that were previously committed.

Conclusion

To conclude, you have seen:

  • How to set up an IAM account in AWS
  • Setting up a repository in AWS CodeCommit
  • Using Git to clone the repository and push back to AWS

Many thanks for your time. You can find the original article (and more) at michael-grogan.com .


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK