运行 本地 AWS SageMaker 线性学习器时角色名称验证错误

Validation error on Role name when running AWS SageMaker linear-learner locally

我正在尝试使用 AWS SageMaker 在本地构建机器学习模型,但我在 IAM 角色名称上遇到了验证错误。尽管这是我在控制台上创建的确切角色名称。

这是我的代码

    import boto3
    import sagemaker
    from sagemaker import get_execution_role
    from sagemaker.amazon.amazon_estimator import image_uris
    from sagemaker.amazon.amazon_estimator import RecordSet

    sess = sagemaker.Session()


    bucket = sagemaker.Session().default_bucket()
    prefix = 'sagemaker/ccard19'

    role ='arn:aws:iam::94911111111542:role/SageMaker-Full-Access '

    container = image_uris.retrieve('linear-learner',boto3.Session().region_name)
    
    # Some other code

   linear = sagemaker.LinearLearner(role=role,
                                               instance_count=1,
                                               instance_type='ml.m4.xlarge',
                                               predictor_type='binary_classifier')
  
  # Some other code

  ### Fit the classifier
  linear.fit([train_records,val_records,test_records], wait=True, logs='All')

这是错误信息

ClientError: An error occurred (ValidationException) when calling the CreateTrainingJob operation: 1 validation error detected: Value 'arn:aws:iam::949010940542:role/SageMaker-Full-Access ' at 'roleArn' failed to satisfy constraint: Member must satisfy regular expression pattern: ^arn:aws[a-z\-]*:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+$

有什么帮助吗?

您的名字中有 space。应该是:

role ='arn:aws:iam::94911111111542:role/SageMaker-Full-Access'