'Upload to S3 bucket using Python and authentication is with SAML
I am trying to write a piece of code in Python that will allow me to upload a file into an S3 bucket.
I have read articles on using boto3, however in order to validate authentication you need the ACCESS_KEY and SECRET_KEY.
I am using AD and we have a SAML setup for authentication.
I have manged to upload to S3 bucket using the AWS CLI and SAML, in order to do this i had to set up my endpoint and create a role profile using the conmmands below.
Set-AWSSamlEndpoint -xxxxxxxx
Set-AWSSamlRoleProfile -xxxxxx
so that i can do
write-S3Object -BucketName xxxx -Key "xxxx"-file xxxx.txt -ProfileName foo_bar
Am i able to use these values with Boto3?
I am stuck as all example code using the ACCESS and SECRET Keys.
``` import boto3
boto3.setup_default_session(profile_name='foo_bar') s3 = boto3.client('s3')
raise ProfileNotFound(profile=profile_name)
botocore.exceptions.ProfileNotFound: The config profile (foo_bar) could not be found
I have found the SAML set up does not populate the config and credentials files. Also when i run this commmand on the AWS CLI no profile is there
aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
i have looked to use the code from the following AWS sample. https://aws.amazon.com/blogs/security/how-to-implement-federated-api-and-cli-access-using-saml-2-0-and-ad-fs/ i am able to connect, however i do not get a SAML returned, this is confirmed when i do an inspection on the web page in chrome.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
