Working example of using assume_role_with_saml
?
#884
-
I'm trying to find out how to get My code looks like this, where the let shared_config = aws_config::from_env().region(region_provider).load().await;
let aws_client = aws_sdk_sts::Client::new(&shared_config);
let result = aws_client.assume_role_with_saml()
.role_arn("arn:aws:iam::MY_ACCOUNT_NUMBER:role/MY_ROLE")
.principal_arn("arn:aws:iam::MY_ACCOUNT_NUMBER:saml-provider/MY_PROVIDER")
.saml_assertion(saml_token)
.send()
.await;
let aws_creds = result?.credentials; |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hi @relausen-tlg, thank you for reporting this. What version of cc @DavidSouther for an example for |
Beta Was this translation helpful? Give feedback.
-
Ok - thanks for replying! That being said: What I was hoping to find somewhere was a "complete" example of |
Beta Was this translation helpful? Give feedback.
-
Alright, I finally figured it out. My suspicion about an errorneous client setup was right. My mistake was that I followed the instructions in the readme for the STS crate: https://docs.rs/aws-sdk-sts/latest/aws_sdk_sts/index.html. After lots of searching and probing I finally stumbled over a test showing how to create a client the right way: https://github.com/awslabs/smithy-rs/blob/8a3b8f3a00f52c8b16ee6b5a080b8dcf4d89faf5/aws/sdk/integration-tests/sts/tests/signing-it.rs#L45. Using the code here (without the for me unnecessary |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Thank you for spending time on my stupid questions 😄.
Yes, the
region_provider
is the same in both snippets. I really like that!I also like the original snippet better, and now I'm really embarrassed, since I managed to overlook the
ConfigLoader::no_credentials
method. Adding a call to that method in the loader made the original snippet work!So now I have this working code, which lives up to your recommendation 😄: