I'm trying to run this AWS CLI command:
aws ecr get-login --no-include-email --region <my-region>
But using the JavaScript SDK with new AWS.ECR(..).getAuthorizationToken method but I'm getting this error:
Error response from daemon: login attempt to https://xxxxx.dkr.ecr.<my-region>.amazonaws.com/v2/ failed with status: 400 Bad Request
From my understanding, I need to use some flag that is equal to the --no-include-email argument in the CLI command but I cannot find how to set it with the JavaScript SDK.
This is my code:
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
]);
Do anyone know how to do it?