'Calling AWS Location API from Sagemaker: Access Denied Exception Error

I have been trying to run the following code in AWS Sagemaker

location = boto3.client('location', region_name='us-east-1')
Response = location.search_place_index_for_text(IndexName = 'explore.place', Text = 'Boston, MA')
print(Response)

but I get the following error

AccessDeniedException: An error occurred (AccessDeniedException) when calling the SearchPlaceIndexForText operation: User: arn:aws:sts::713361781863:assumed-role/AmazonSageMaker-ExecutionRole-20220208T112132/SageMaker is not authorized to perform: geo:SearchPlaceIndexForText on resource: arn:aws:geo:us-east-1:713361781863:place-index/explore.place

If I run the same code from my local python I get the correct response. I imagine is a permission issue connecting Sagemaker to the AWS Location Service - how do I grant access to sagemaker/update my IAM?

thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source