I have an EKS cluster with a Fargate profile for compute. I've configured the Pod execution role on the Fargate profile with the 2 managed policies.
- AmazonEKSFargatePodExecutionRolePolicy
- AmazonDynamoDBFullAccess
The code is run as a CronJob, it starts off by pulling a configuration from DynamoDb:
dynamodb = boto3.resource('dynamodb', region_name=region)
table = dynamodb.Table(table_name)
response = table.get_item(
Key = {
'Id': config_id
})
When the code reaches this point it always exceptions out with:
raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials
I know I can pass the AWS credentials straight in when I initialise the boto3 client but I don't want to do that for security reasons.
I had originally tested the code using an EC2 instance in an auto-scaling group for compute instead of Fargate, which worked.
How do I resolve this error?