Skip to content

PySparkProcessor Uses Local Role Instead of Passed Role For Initial S3 File Movement #1988

Closed

Description

@jimmycfa

Describe the bug
PySparkProcessor uses the role used to call it when using the sagemaker SDK when it attempts to load local submit_files to S3 instead of using the role passed into it. The normal ScriptProcessor seems to use the passed in role. I got an access denied the first time I used PySparkProcessor when my calling role and passed in role were different.

To reproduce
Create a PySparkProcessor and run it with a different role than the role passed into the instantiation. If the calling role doesn't have S3 permissions on sagemaker you will get an access denied even if the passed-in role does have sagemaker S3 permissions. I added "Resource": "arn:aws:s3:::*sagemaker*" to my calling role to get passed this.

Expected behavior
PySparkProcessor would use the passed in role to upload the local files to S3.

Screenshots or logs
Normal access denied error.

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 2.16.2
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): PySparkProcessor
  • Framework version: Unknown
  • Python version: 3.7
  • CPU or GPU: CPU
  • Custom Docker image (Y/N): Yes but just using sagemakerk==2.16.2

Additional context
None

Activity

  1. icywang86rui commented on Nov 18, 2020

    @icywang86rui
    Contributor

    @jimmycfa The SDK doesn't use the role passed in the Processor locally by design. The role parameter is passed to SageMaker service to start training jobs, processing jobs etc. Locally SDK caller could have different way to setup their credential, whatever local credential is used may not have permission to assumed the role specified in the parameter.

    We do have a get_execution_role here you can use to get the role name you are running the sdk code with -

    def get_execution_role(sagemaker_session=None):

    Then you can pass that to the Processor constructor if desired. This is pattern in a lot of our example notebooks. Hope this answers your question. Resolving the issue. Feel free to reopen if you have any follow up questions.

  2. added a commit that references this issue on Jun 3, 2026
  3. added a commit that references this issue on Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions