AWS Python Script

Hello all,

I am trying to use boto3 module in a python script for a workflow.

I have a question in regards to the session management. For testing, we hardcoded the keys and session tokens into the script, but we are now trying to use #8 method from the following link:
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#credentials

The role has been configured and when I do a test run of the following lines, it fails with “botocore.exceptions.NoCredentialsError: Unable to locate credentials” error.

def run(params={}):
import boto3
import boto3.session
session = boto3.Session(region_name=‘us-east-1’)
client = session.client(‘sts’)
response = client.get_caller_identity()
return(response)

However, when I run the above with the ‘response’ commented out and just return{}. It succeeds.

When I run these scripts to interact with AWS, isn’t the orchestrator running this script? Our orchestrator is also in AWS, so we did assign the role, but still failing.

Please let me know if I am understanding this wrong.

The orchestrator is running the script in a docker container. Its possible you may have to do something with the docker config to allow it to use OS level credentials, but I’m not versed enough in AWS permissions to say what’s possible here. Its also possible you might be able to use the instance profile as permissions.