Granting Access via through SSH on AWS CodeCommit Repo to an Ionic Apps Build.

Goal:

So I am working with a project where I created a private library in Angular and saved it to an AWS code-commit repository.

I want to install this library to my Ionic app which I can then use freely within the application via npm.

Version:

Ionic 4.2.0 (Angular build)

First Try:

I first tried to npm install it using an HTTPS Git Credentials url in the package.json which allowed me to install it locally; after putting in the appropriate credentials my libraries functionality worked the way it should. When I pushed this project to the ionic dashboard and did a build on the ionic dashboard it gave me an error clarifying that it cannot access the AWS repo.

[17:22:05]: ▸ npm ERR!
[17:22:05]: ▸ npm ERR! fatal: unable to access 'https://git-codecommit.us-east-2.amazonaws.com/*url*': The requested URL returned error: 403
[17:22:05]: ▸ npm ERR!

After some thought this makes sense as there is no way for ionic to have access to a repo via HTTPS.

So I moved towards the use of SSH as Ionic has the settings of using public SSH keys.

Second Try:

I already have an Ionic SSH key setup with my Ionic pro Account where I currently have my project. So I believe that I could just copy this public key to the Amazon IAM User SSH and I should then be able to still npm install my library locally and on the ionic dashboard build.

I changed my url for the library to the SSH url in the package.json and ran an npm install

Well the console gave me the following error locally and on the Ionic Dashboard Build:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git-codecommit.us-east-2.amazonaws.com/*url*
npm ERR!
npm ERR! user@git-codecommit.us-east-2.amazonaws.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

So now I cannot access it on my local machine or on ionic.

I researched a bit into this issue and the aws docs to SSH are not very helpful and ionic is also quiet on this issue.

Questions:

  • Is there a possibility in hooking up an Ionic Dashboard app to have access to private repos on an npm install without using SSH?

  • If there is no other way except using SSH, what are some hints and steps to take to debug or perhaps clarify my public SSH key works locally?

  • Lastly, after it works locally, what is the best way into hooking it up with the Ionic dashboard? (Note: I already have an ssh key to grant me access to push and pull to this repo which stands alone from my Macs public ssh key. I don’t want to lose access by implementing a second ssh key.)

1 Like