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
asked a month ago275 views
3 Answers
2
Accepted Answer
profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • 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
EXPERT
answered a month ago
profile picture
EXPERT
Artem
reviewed a month ago
profile picture
EXPERT
shibata
reviewed a month ago
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
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month 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