Programmatically get temporary AWS credentials using Azure AD integrated with AWS SSO

VijayJ 5 Reputation points
2023-05-19T06:24:49.36+00:00

I have Integrated a AWS Identity Center Enterprise application with Azure AD. Using Azure Single Sign-On I am able to access the AWS Account. How do I programmatically (using python or powershell or something else) achieve this. When I provide a Azure AD user credentials (in a script or code) I should get AWS temporary credentials (AccessKey, SecretKey, Token) which I can use to access the AWS account.

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2023-05-19T09:21:07.7566667+00:00

    @VijayJ

    Welcome to Microsoft Q&A, thank you for posting your question here!

    Interesting to know you would like to programmatically get temporary AWS credentials using Azure AD integrated with AWS SSO, which I can use to access the AWS account.

    To programmatically get temporary AWS credentials from Azure AD integrated with AWS SSO using PowerShell, you can use the AWS PowerShell module.

    You can use the following command to get temporary credentials:

    $sts = Get-STSCallerIdentity
    $roleArn = "arn:aws:iam::123456789012:role/RoleName"
    $sessionName = "SessionName"
    $sessionDuration = 3600
    $roleSessionName = "RoleSessionName"
    $credentials = $sts.Credentials.GetFederationToken($roleArn,$sessionName,$sessionDuration,$null,$null,$null,$null,$roleSessionName)
    
    

    The above can be modified to suite your need. This will return temporary credentials that you can use to access AWS resources. You can then use these credentials to make API calls to AWS services.

    For more information, you can read from the link below:

    ID Credential Temp Request

    ID Credential Temp Resources

    Kindly let us know if the above helps or you need more assistance.

    Best Regards,

    Sina


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.