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ヶ月前291ビュー
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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ