简体   繁体   English

AWS SSO、Codecommit(GRC git 克隆链接)和 npm 安装

[英]AWS SSO, Codecommit (GRC git clone link) and npm install

Single Sign On (SSO) is implemented on AWS account.单点登录 (SSO) 在 AWS 账户上实施。 After running aws sso login , cloning a node a repo using (GRC link) works.运行aws sso login后,使用(GRC 链接)克隆一个节点是可行的。 However, running npm install in repo results in different errors.但是,在 repo 中运行npm install会导致不同的错误。

ex.前任。 package.json package.json

...
"dependencies": {
    ...
    "common-resource-1": "git+https://git-codecommit.us-east-1.amazonaws.com/v1/repos/common-resource-1#develop",
   ...
}
...

The errors错误

npm ERR! Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t https://git-codecommit.us-east-1.amazonaws.com/v1/repos/common-resource-1
npm ERR!
npm ERR! some-user@git-codecommit.us-east-1.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.
npm ERR!
npm ERR! exited with error code: 128

That makes sense because there are no ssh or https creds.这是有道理的,因为没有 ssh 或 https 信用。 git-remote-codecommit python package is installed as recommended buy AWS https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html git-remote-codecommit python package is installed as recommended buy AWS https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html

However, the following returns repo information: /usr/local/bin/git ls-remote -h -t codecommit://common-resource-1但是,以下返回 repo 信息: /usr/local/bin/git ls-remote -h -t codecommit://common-resource-1

also tried with putting the following in package.json "common-resource-2": "codecommit::east-1://common-resource-2#develop" , The error I get is还尝试将以下内容放入 package.json "common-resource-2": "codecommit::east-1://common-resource-2#develop" ,我得到的错误是

npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "codecommit:": codecommit::east-1://common-resource-2#develop

This is an issue for many repos, since other repos use common-resource-1 and common-resource-2 repos.这是许多存储库的问题,因为其他存储库使用common-resource-1common-resource-2存储库。

Any help with this would be greatly appreciated.对此的任何帮助将不胜感激。

NPM CLI custom protocol NPM CLI 自定义协议

I am posting this answer here, but there should be a better one that is more robust.我在这里发布了这个答案,但应该有一个更强大的更好的答案。

For npm-cli (which is the same as what is run when using npm on commandline) in file node_modules/npm-package-arg/npa.js around line 232, add another case statement like:对于 npm-cli(与在命令行上使用 npm 时运行的内容相同)在文件 node_modules/npm-package-arg/npa.js 的第 232 行附近,添加另一个 case 语句,例如:

case 'git+codecommit:':案例'git + codecommit:':

And that is it.就是这样。

There is an issue here though.不过这里有一个问题。 The GRC links also user codecommit::us-east-1: protocol, where after the:: is the region where codecommit and the repo reside. GRC 还链接用户 codecommit::us-east-1: 协议,其中:: 之后是 codecommit 和 repo 所在的区域。

The current use of the case statements will not work for something like codecommit::us-east-1:. case 语句的当前使用不适用于 codecommit::us-east-1: 之类的内容。 So to make it more robust, there will need to be better parsing of the "urls" in dependencies.因此,为了使其更健壮,需要更好地解析依赖项中的“url”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM