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

asked 4 years ago292 views
2 Answers
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

answered 4 years ago
0

Thanks for posting your solution.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions