Call AWS API from external

0

Hello all!

I have a real scenario case in which implementing I have a problem. I want to call AWS API (ex. ec2:DescribeInstances) from external Azure Function so the traffic goes through the internet. I want to use short-term credentials.

Solutions that I rejected for now:

  1. Cognito + client_credentials -> client_credentials can't be exchanged into AWS credentials
  2. Iam roles anywhere - expensive -> $400/m for CA and it is designed for servers not serverless as i know

What cost-effective solution do you recommend to use?

Mateusz
已提问 2 个月前290 查看次数
3 回答
2
已接受的回答
profile picture
专家
已回答 2 个月前
profile picture
专家
已审核 2 个月前
  • Thanks for your and all replies! This answer resolved my issue, however step-by-step instructions in the article could be more precise.

2

To assume an AWS IAM role from an Azure Function, you can follow these steps:

  1. Set up cross-account access in AWS: First, you must create an IAM role in AWS that your Azure Function can assume. This role must have a trust relationship with an identity provider that supports SAML 2.0 (like Azure AD). You'll define a policy allowing you to perform the actions you want in AWS (ex. ec2:DescribeInstances)

  2. Configure Azure AD for SSO to AWS: In Azure AD, you'll set up a single sign-on (SSO) to AWS. This involves configuring Azure AD as a SAML identity provider in AWS. You'll download the metadata XML from Azure and upload it to AWS to establish trust.

  3. Assign users or groups in Azure AD: Assign the Azure AD users or groups with access to assume the AWS IAM role. These are typically the identities associated with your Azure Functions.

  4. Acquire Azure AD token: Your Azure Function needs to authenticate with Azure AD to get a SAML assertion token. You can use the Microsoft identity platform (Azure AD for developers) to obtain tokens.

  5. Assume the AWS role using the SAML assertion: Once you have the SAML assertion, you use the AWS Security Token Service (STS) AssumeRoleWithSAML API to exchange the SAML assertion for AWS temporary security credentials.

  6. Use AWS credentials in your Azure Function: Your Azure Function can make authenticated requests to AWS services with temporary security credentials (access key ID, secret access key, and session token).

profile picture
专家
已回答 2 个月前
profile picture
专家
Artem
已审核 2 个月前
profile picture
专家
shibata
已审核 2 个月前
1

Another approach could be to create an api gateway in aws with a lambda making the call, which the azure function can consume. Thought involving a bit more manual work, you separate the logic clearly into e.g. a lambda function, protected by either IAM auth or another lambda authorizer.

Also this stipulate clear contract between two different cloud vendor sources and makes the interaction more visible.

profile picture
专家
已回答 2 个月前
profile picture
专家
已审核 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则