I have a sagemaker instance which I want to auto scale, currently it is working on 4 instances but I want to auto-scale it from 1 to 4, as per the load.
This is the code I am using to auto-scale
resource_id = 'endpoint/[end-point-name]/variant/config1'
sc_client = boto3.client('application-autoscaling')
role = 'arn:aws:iam::[1234]:role/service-role/AmazonSageMaker-ExecutionRole-[1234]'
response = sc_client.register_scalable_target(
ServiceNamespace='sagemaker',
ResourceId=resource_id,
ScalableDimension='sagemaker:variant:DesiredInstanceCount',
MinCapacity=1,
MaxCapacity=4,
RoleARN= role,
SuspendedState={
'DynamicScalingInSuspended': True,
'DynamicScalingOutSuspended': True,
'ScheduledScalingSuspended': True
}
)
I have given all the access (sagemaker and cloudwatch) on all resources to this role : AmazonSageMaker-ExecutionRole-[1234]
Now I am getting this error whenever i ran this code
ClientError: An error occurred (AccessDeniedException) when calling the RegisterScalableTarget
operation: User: arn:aws:sts::[1234]:assumed-role/AmazonSageMaker-ExecutionRole-[1234]/SageMaker
is not authorized to perform: iam:PassRole on resource: arn:aws:iam::[1234]:role/service-role/AmazonSageMaker-ExecutionRole-[1234]
Now I am not sure how it is pickin 'assumed-role' instead of 'service-role' and how to fix the issue, I am using admin account which have all the access and the above 'service-role' also have all the access