Signing REST requests using IAM access key

0

I have a two part problem. I have a bash script running within a Jenkins container that needs to send a simple post request using CURL to an HTTPS endpoint hosted within ECS container. The Jenkins container runs using assumed role jenkins. The ECS container runs using assumed role ecscontainer. This is what I would like to do:

(1) Sign the CURL request originating from Jenkins. In order to do this I need to be able to set the Authorization header with the signature. How can my bash script get the access key of the role jenkins? There is no AWS CLI command in aws iam or aws sts I can find that will return the access key id and/or secret access key.

(2) On the ECS container end I want to be able to use AWS-SDK to verify the signature used in (1) so that I only allow requests from role jenkins to be processed.

Any help will be greatly appreciated.

Edited by: sshekhar on May 15, 2020 3:30 PM

demandé il y a 4 ans299 vues
2 réponses
0

Okay I have figured this out, not sure if others need to know how to do this but here it is:

curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role_nm>

Each AWS EC2 instance resolves the above IP to a server that provides meta-data associated with that particular EC2 instance.

Edited by: sshekhar on May 24, 2020 9:23 AM

répondu il y a 4 ans
0

Thanks for posting your solution.

répondu il y a 4 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions