我正在尝试运行此 AWS CLI 命令:
aws ecr get-login --no-include-email --region <my-region>
但是使用带有方法的 JavaScript SDKnew AWS.ECR(..).getAuthorizationToken
但我收到了这个错误:
Error response from daemon: login attempt to https://xxxxx.dkr.ecr.<my-region>.amazonaws.com/v2/ failed with status: 400 Bad Request
据我了解,我需要使用一些--no-include-email
与 CLI 命令中的参数相等的标志,但我找不到如何使用 JavaScript SDK 设置它。
这是我的代码:
const ecr = new AWS.ECR({
apiVersion: '2015-09-21',
region: 'my-region'
});
const { authorizationData } = await ecr.getAuthorizationToken().promise();
if(!authorizationData || !authorizationData[0] || !authorizationData[0].authorizationToken){
throw new Error('AWS getAuthorizationToken failed');
}
const password = authorizationData[0].authorizationToken;
const proxyEndpoint = authorizationData[0].proxyEndpoint;
await childProcessP.spawn('docker', [
'login',
'-u', 'AWS',
'-p', password,
proxyEndpoint
]);
有谁知道该怎么做?