AWS Security ChangesHomeSearch

AWS emr: Restructure Spark agent IAM setup docs with least-privilege guidance

Service: emr · 2026-11-19 · Documentation medium

File: emr/latest/ReleaseGuide/spark-troubleshooting-agent-iam-setup.md · Type: iam

Summary

Rewrites the Apache Spark troubleshooting agent IAM setup page: replaces the old step-based structure with sections on how agents use your permissions, how requests are authorized (SigV4 plus aws:ViaAWSMCPService and aws:CalledViaAWSMCP condition keys), choosing an identity, confirming role permissions (permissions policy vs. trust policy), an FAQ with fine-grained Deny examples, dedicated-role creation via CLI/CloudFormation, KMS permissions for encrypted CloudWatch Logs, and an appendix of example IAM policies per platform.

Security assessment

The diff is a documentation restructure that adds IAM security guidance: least-privilege dedicated roles, trust-policy scoping to a specific principal, Deny statements gated on the aws:ViaAWSMCPService/aws:CalledViaAWSMCP condition keys, and kms:Decrypt/kms:DescribeKey for encrypted CloudWatch Logs. It documents security best practices rather than fixing a specific vulnerability, so it is not security_issue_related, but it is security documentation with medium severity given the IAM authorization and encryption-permission content.

Evidence

+  * **A dedicated role** – Create a role that has only the read permissions that the agents need. This option follows the practice of least privilege. For instructions, see How do I create a dedicated IAM role for the agents?.

Diff

diff --git a/emr/latest/ReleaseGuide/spark-troubleshooting-agent-iam-setup.md b/emr/latest/ReleaseGuide/spark-troubleshooting-agent-iam-setup.md
index c0d99e8..c929033 100644
--- a//emr/latest/ReleaseGuide/spark-troubleshooting-agent-iam-setup.md
+++ b//emr/latest/ReleaseGuide/spark-troubleshooting-agent-iam-setup.md
@@ -7 +7 @@
-PrerequisitesHow the Apache Spark agents use your permissionsStep 1: (Optional) Create a dedicated agent roleStep 2: Attach permissions for your deployment modeStep 3: Configure your MCP clientCondition keys for MCP server requests
+How the Apache Spark agents use your permissionsConfirm your role's permissionsFrequently asked questionsAppendix: Example IAM policies
@@ -11 +11 @@ PrerequisitesHow the Apache Spark agents use your permissionsStep 1: (Optional)
-## Prerequisites
+## How the Apache Spark agents use your permissions
@@ -13 +13 @@ PrerequisitesHow the Apache Spark agents use your permissionsStep 1: (Optional)
-Before you begin, make sure that you have the following:
+The Apache Spark agents use the IAM identity that your MCP client is configured with, which is the identity in your AWS CLI profile. Authorization works the same way as when you run AWS CLI or AWS SDK commands yourself. The agents can access only what that identity is allowed to access, and your existing IAM policies control every request. You don't need to grant any MCP-specific permissions.
@@ -15 +15 @@ Before you begin, make sure that you have the following:
-  * An AWS account with IAM administrative access
+### What the agents do with your permissions
@@ -17 +17 @@ Before you begin, make sure that you have the following:
-  * AWS CLI installed and configured. For more information, see [Installing the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
+  * **Read only** – The agents read your job runs, job metadata, logs, and Spark UI (Spark History Server) data. They don't start, modify, or stop your jobs.
@@ -18,0 +19 @@ Before you begin, make sure that you have the following:
+  * **No access of their own** – For each request, the Amazon SageMaker Unified Studio (SMUS) MCP server uses short-lived credentials for your identity. The server has no access of its own to your resources, and it doesn't store your credentials.
@@ -19,0 +21 @@ Before you begin, make sure that you have the following:
+  * **Auditable** – AWS CloudTrail logs the API calls that the agents make, in the same way that it logs any other call from your identity.
@@ -22 +23,0 @@ Before you begin, make sure that you have the following:
-Set the following variables for use in later commands:
@@ -25,2 +26 @@ Set the following variables for use in later commands:
-    ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
-    REGION=$(aws configure get region)
+### How requests are authorized
@@ -28 +28,79 @@ Set the following variables for use in later commands:
-## How the Apache Spark agents use your permissions
+The SMUS MCP server authenticates each request with SigV4, adds two IAM condition keys to it, and forwards it to the AWS service, such as AWS Glue or Amazon EMR. That service then authorizes the request against your IAM policies.
+
+  * `aws:ViaAWSMCPService` – Set to `true` for requests made through an AWS managed MCP server.
+
+  * `aws:CalledViaAWSMCP` – Set to the service principal of the MCP server, `sagemaker-unified-studio-mcp.amazonaws.com`.
+
+
+
+
+You don't need to reference these keys in your policies for the agents to work. If your identity can already read your job metadata, logs, and Spark History Server data, the agents work without any policy changes.
+
+Because these keys mark requests that come from the agents, you can write policies that treat those requests differently from requests that you make directly. For example, you can deny an action to the agents while your own access to that action stays the same. For more information, see [Understanding IAM for Managed AWS MCP Servers](https://aws.amazon.com/blogs/security/understanding-iam-for-managed-aws-mcp-servers/).
+
+### Choose an identity for the agents
+
+You can give the agents either of the following identities:
+
+  * **A dedicated role** – Create a role that has only the read permissions that the agents need. This option follows the practice of least privilege. For instructions, see How do I create a dedicated IAM role for the agents?.
+
+  * **A role that you already have** – Reuse the role that you use to analyze your jobs, or the job run role for your Spark jobs. If the role has more permissions than the agents need, add a `Deny` statement that uses the condition keys. The deny applies only to requests from the agents, so the jobs that use the role aren't affected. For examples, see How can I get more fine-grained control over the agents' permissions?.
+
+
+
+
+To check that your role has what the agents need, see Confirm your role's permissions.
+
+## Confirm your role's permissions
+
+Two policies on an IAM role control whether the agents can use it:
+
+  * **Permissions policy** – Controls what the role can do. The agents need read access to your job runs, logs, and Spark History Server data.
+
+  * **Trust policy** – Controls who can assume the role. Your IAM principal must be allowed to assume the role so that your MCP client can use it.
+
+
+
+
+Use the following steps to confirm that your role is ready.
+
+  1. Check the permissions policy. Compare the policies attached to the role with the permissions for each Spark platform that you use:
+
+     * EMR on EC2
+
+     * AWS Glue
+
+     * EMR Serverless
+
+     * EMR on EKS
+
+You need permissions only for the platforms that you want the agents to analyze. If the role is missing a permission, the agents can't read that data.
+
+  2. If you reuse a job run role, check its trust policy. A job run role usually trusts only its service, such as `glue.amazonaws.com` or `emr-serverless.amazonaws.com`. Keep the existing service statement, and add a statement that allows your IAM principal to assume the role. Allow only the specific principal that runs your MCP client, as in the following example:
+    
+        {
+      "Effect": "Allow",
+      "Principal": { "AWS": "arn:aws:iam::111122223333:role/your-developer-role" },
+      "Action": "sts:AssumeRole"
+    }
+
+
+
+
+If your CloudWatch Logs are encrypted with a customer managed KMS key, the role also needs permission to use that key. For more information, see How do the agents access encrypted CloudWatch Logs?.
+
+To configure your MCP client to use your role, see [Set up the Apache Spark agents](./spark-troubleshooting-agent-setup.html).
+
+## Frequently asked questions
+
+The following questions cover common objections and ways to tailor the agents' access.
+
+### How can I get more fine-grained control over the agents' permissions?
+
+Your role (for example, a job run role) might have more permissions than you want the agents to use. You can keep using it and deny the extra permissions to the agents with condition keys. You don't need to create a new role, and the jobs that use the role aren't affected, because the deny applies only to requests made through the MCP server.
+
+Two condition keys are automatically added to all requests made through the SMUS MCP server:
+
+  * `aws:ViaAWSMCPService` – Set to `true` for any request made through an AWS managed MCP server.
+
+  * `aws:CalledViaAWSMCP` – Set to the MCP server service principal (for example, `sagemaker-unified-studio-mcp.amazonaws.com`).
@@ -30 +107,0 @@ Set the following variables for use in later commands:
-The Amazon SageMaker Unified Studio (SMUS) MCP server authorizes operations at the AWS service level using the IAM identity that your MCP client is configured with. No separate MCP-specific permissions are required. The agents act as that identity, so they can only access what that identity is permitted to access.
@@ -32 +108,0 @@ The Amazon SageMaker Unified Studio (SMUS) MCP server authorizes operations at t
-The policies on this page describe the permissions that the agents use at full capability. You choose how much of that access to grant. The agents use these permissions to read your job runs, logs, and Spark UI data. They don't start, modify, or stop your jobs. Attach the permissions that you want the agents to have to the IAM identity that your MCP client uses. This is normally the role that you already use to analyze your Spark jobs. Confirm that the role has the permissions in Step 2: Attach permissions for your deployment mode, and point your MCP client at it, as described in Step 3: Configure your MCP client.
@@ -34 +109,0 @@ The policies on this page describe the permissions that the agents use at full c
-If you want the agents to run under a separate, scoped identity instead of your own, create a dedicated role, as described in Step 1: (Optional) Create a dedicated agent role. For an AWS CloudFormation template that creates the role, and for other ways to tighten the agents' access, see [How can I get more fine-grained control over the agents' permissions?](./spark-troubleshooting-agent-troubleshooting.html#spark-agents-qa-fine-grained).
@@ -36 +111,45 @@ If you want the agents to run under a separate, scoped identity instead of your
-## Step 1: (Optional) Create a dedicated agent role
+You can use these condition keys to control access to your resources when requests originate from an AWS managed MCP server.
+
+To deny the extra permissions to the agents, add a `Deny` statement like the second of the following examples to your role.
+
+**Example: Allow AWS Glue read operations only when accessed through the SMUS MCP server:**
+    
+    
+    {
+      "Version": "2012-10-17",
+      "Statement": [
+        {
+          "Sid": "AllowGlueReadViaSMUSMCP",
+          "Effect": "Allow",
+          "Action": ["glue:GetJob", "glue:GetJobRun", "glue:GetJobRuns"],
+          "Resource": "*",
+          "Condition": {
+            "StringEquals": {
+              "aws:CalledViaAWSMCP": "sagemaker-unified-studio-mcp.amazonaws.com"
+            }
+          }
+        }
+      ]
+    }
+
+**Example: Deny delete operations when accessed through any AWS managed MCP server:**
+    
+    
+    {
+      "Effect": "Deny",
+      "Action": ["s3:DeleteObject", "s3:DeleteBucket"],
+      "Resource": "*",
+      "Condition": {
+        "Bool": {
+          "aws:ViaAWSMCPService": "true"
+        }
+      }
+    }
+
+For more information about condition keys, see [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) in the _IAM User Guide_.
+
+If you'd rather give the agents a role with only the permissions they need, see How do I create a dedicated IAM role for the agents?.
+
+### How do I create a dedicated IAM role for the agents?
+
+You might want to create a new IAM role dedicated to the agents, so that you don't have to modify any existing roles.
@@ -38 +157 @@ If you want the agents to run under a separate, scoped identity instead of your
-Skip this step if you use your existing IAM role. Complete it only if you want to give the agents their own identity: a dedicated role that you create for the MCP server and grant only the access that you choose.
+#### Create the role with the AWS CLI
@@ -40 +159 @@ Skip this step if you use your existing IAM role. Complete it only if you want t
-**To create the IAM role (AWS CLI)**
+The trust policy uses your account ID. Set `ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)`, or replace `${ACCOUNT_ID}` with your account ID.
@@ -61 +180 @@ Skip this step if you use your existing IAM role. Complete it only if you want t
-      --role-name SparkTroubleshootingMCPRole \
+      --role-name your-role-name \
@@ -67 +186,40 @@ Skip this step if you use your existing IAM role. Complete it only if you want t
-## Step 2: Attach permissions for your deployment mode
+After you create the role, attach the permissions policies for the platforms you use from Appendix: Example IAM policies.
+
+#### Create the role with AWS CloudFormation
+
+The following AWS CloudFormation template is a quick way to create the role and its assume-role profile. These templates are only samples; modify them to meet your requirements.
+
+The template creates the following resources:
+
+  1. An IAM role that has permissions to call the MCP server and the permissions required for the selected platform.
+
+
+
+
+Choose one of the **Launch Stack** buttons in the following table. This launches the stack on the AWS CloudFormation console in the respective Region.
+
+Region | Launch  
+---|---  
+US East (Ohio) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-us-east-2.s3.us-east-2.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+US East (N. Virginia) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-us-east-1.s3.us-east-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+US West (Oregon) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-us-west-2.s3.us-west-2.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+Asia Pacific (Tokyo) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=ap-northeast-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ap-northeast-1.s3.ap-northeast-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+Europe (Ireland) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-eu-west-1.s3.eu-west-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+Asia Pacific (Singapore) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ap-southeast-1.s3.ap-southeast-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+Asia Pacific (Sydney) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ap-southeast-2.s3.ap-southeast-2.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+Canada (Central) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=ca-central-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ca-central-1.s3.ca-central-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)  
+South America (São Paulo) |  [ ![Launch Stack button with information icon.](/images/emr/latest/ReleaseGuide/images/cloudformation-launch-stack-button.png) ](https://console.aws.amazon.com/cloudformation/home?region=sa-east-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-sa-east-1.s3.sa-east-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup)