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!
CodePudding user response:
You can add inline policy to AmazonSageMaker-ExecutionRole-20220208T112132
role:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "geo:SearchPlaceIndexForText",
"Resource": "arn:aws:geo:us-east-1:713361781863:place-index/explore.place"
}
]
}