AWS ECR token to Postman

To send my POST request, which are related to AWS ECR, I had to also send authorization token. Curently I’m getting ECR token manually with AWS CLI:

  • use “aws ecr get-login” command
  • then copy token from command line
  • then I select ‘Bearer Token’ authorization type in Postman, and past my token to ‘Token’ field.

It works well, but I wonder how I could automate this workflow.
Is there a way to make Postman to request the token from AWS ECR and put it to my collection?

Thank you in advance.

Hey @Sir_Ejik, this can be done as follows:

  1. Add a request to your Postman collection that uses AWS Signature auth using https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_GetAuthorizationToken.html as a reference. (you’ll need to create an AWS API keypair with the ECR Get Authorization token permission for this to work: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey)
  2. Once the request is ready, you can parse its response to extract the ECR auth token.
  3. This token can be set as an environment variable to be used for future requests.