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.