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

已提問 4 年前檢視次數 299 次
2 個答案
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

已回答 4 年前
0

Thanks for posting your solution.

已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南