AWS emr: Rework Spark agents setup to use existing IAM identity
Summary
Replaces the CloudFormation-based setup (which created a dedicated IAM role and exposed parameters like TroubleshootingRoleName, EnableEMREC2/EMRServerless/EMREKS/Glue, and CloudWatchKmsKeyArn) with instructions to point the MCP client at an existing AWS profile/role. Adds a new 'How the agents access your resources' section explaining that the MCP server authorizes at the AWS service level using the client's IAM identity, that agents can only access what that identity permits, and links to IAM permissions and fine-grained control guidance. Also adds MCP client configuration sections (Cline, Claude Code, GitHub Copilot) and renames headings.
Security assessment
The change documents the authorization model for the Spark agents: they inherit the IAM identity configured in the MCP client and are bounded by that identity's permissions, with pointers to IAM permission requirements and fine-grained scoping. This is security-relevant IAM/least-privilege guidance rather than a fix for a specific vulnerability or incident, so it is security documentation with medium severity.
Evidence
+The MCP server authorizes operations at the AWS service level using the IAM identity that your MCP client is configured with. The agents act as that identity, so they can only access what that identity is permitted to access. No separate MCP-specific permissions are required.
Diff
diff --git a/emr/latest/ReleaseGuide/spark-troubleshooting-agent-setup.md b/emr/latest/ReleaseGuide/spark-troubleshooting-agent-setup.md index 90508f7..c1924ca 100644 --- a//emr/latest/ReleaseGuide/spark-troubleshooting-agent-setup.md +++ b//emr/latest/ReleaseGuide/spark-troubleshooting-agent-setup.md @@ -7 +7 @@ -PrerequisitesSetup Resources +PrerequisitesHow the agents access your resourcesAdd the Apache Spark agents to your MCP clientConfigure your MCP client @@ -9 +9 @@ PrerequisitesSetup Resources -# Setup for Troubleshooting Agent +# Set up the Apache Spark agents @@ -13 +13,5 @@ Note -The Apache Spark Troubleshooting Agent uses cross-region inference to process natural language requests and generate responses. For more details, please refer to [Cross-Region Processing for the Apache Spark Troubleshooting Agent](./spark-troubleshooting-cross-region-processing.html). +The Apache Spark agents use cross-Region inference to process natural language requests and generate responses. For more information, see [Cross-Region processing for the Apache Spark agents](./spark-troubleshooting-cross-region-processing.html). + +Note + +Both agents use the `sagemaker-unified-studio-mcp-troubleshooting` server and the `/spark-troubleshooting/mcp` endpoint, despite "troubleshooting" in the names. Only the Troubleshooting Agent uses the code recommendation server, `sagemaker-unified-studio-mcp-code-rec` (`/spark-code-recommendation/mcp`). If you use only the Optimization Agent, you can skip it. @@ -17 +21 @@ The Apache Spark Troubleshooting Agent uses cross-region inference to process na -Before we begin our setup process for integration with Kiro CLI, make sure you have the following installed on your workstation: +Before you begin the setup for integration with Kiro CLI, make sure that you have the following installed on your workstation: @@ -19 +23 @@ Before we begin our setup process for integration with Kiro CLI, make sure you h - * [ Install AWS CLI ](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) + * [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) @@ -27,37 +31 @@ Before we begin our setup process for integration with Kiro CLI, make sure you h - * AWS local credentials configured (via [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), environment variables, or IAM roles) - for local operations such uploading upgraded job artifacts for EMR validation job execution. - - - - -## Setup Resources - -You can use an AWS CloudFormation template to setup the resource for the MCP server. These templates are samples that you should modify to meet your requirements. The template creates the following resources for the troubleshooting process: - - 1. IAM role which has permissions to call MCP Server and required permissions for troubleshooting process 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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) | [  ](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) -Europe (Frankfurt) | [  ](https://console.aws.amazon.com/cloudformation/home?region=eu-central-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-eu-central-1.s3.eu-central-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) -Europe (Stockholm) | [  ](https://console.aws.amazon.com/cloudformation/home?region=eu-north-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-eu-north-1.s3.eu-north-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) -Europe (London) | [  ](https://console.aws.amazon.com/cloudformation/home?region=eu-west-2#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-eu-west-2.s3.eu-west-2.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) -Europe (Paris) | [  ](https://console.aws.amazon.com/cloudformation/home?region=eu-west-3#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-eu-west-3.s3.eu-west-3.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) -Asia Pacific (Seoul) | [  ](https://console.aws.amazon.com/cloudformation/home?region=ap-northeast-2#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ap-northeast-2.s3.ap-northeast-2.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) -Asia Pacific (Mumbai) | [  ](https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/new?templateURL=https%3A%2F%2Fsmus-mcp-cfn-template-prod-ap-south-1.s3.ap-south-1.amazonaws.com%2Fcloudformation%2Fspark-troubleshooting-mcp-setup.yaml&stackName=spark-troubleshooting-mcp-setup) - -Proceed to the **Specify stack details** page, enter the **Stack name**. Enter additional information under **Parameters**. Provide the following information and proceed to create the stack. - - * **TroubleshootingRoleName** \- Name of the IAM role to create for troubleshooting operations + * AWS local credentials configured (through the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), environment variables, or IAM roles). The MCP Proxy for AWS uses these credentials to authenticate the agents' requests to AWS services as your IAM identity. @@ -65 +32,0 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a - * **EnableEMREC2** \- Enable EMR-EC2 troubleshooting permissions (default: true) @@ -67 +33,0 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a - * **EnableEMRServerless** \- Enable EMR-Serverless troubleshooting permissions (default: true) @@ -69 +34,0 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a - * **EnableEMREKS** \- Enable EMR on EKS troubleshooting permissions (default: true) @@ -71 +36 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a - * **EnableGlue** \- Enable Glue troubleshooting permissions (default: true) +## How the agents access your resources @@ -73 +38 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a - * **CloudWatchKmsKeyArn** \- (Optional) ARN of existing KMS key for CloudWatch Logs encryption (EMR Serverless only, leave empty for default encryption) +The MCP server authorizes operations at the AWS service level using the IAM identity that your MCP client is configured with. The agents act as that identity, so they can only access what that identity is permitted to access. No separate MCP-specific permissions are required. @@ -74,0 +40 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a +Point the MCP client at an AWS profile for a role that you already use to analyze your Spark jobs. The agents' access then matches your own. Make sure that the role has the permissions described in [IAM permissions for the Apache Spark agents](./spark-troubleshooting-agent-iam-setup.html), so that the agents can read all the signals from your Spark jobs. @@ -75,0 +42 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a +If you want tighter, scoped control over what the agents can access, see [How can I get more fine-grained control over the agents' permissions?](./spark-troubleshooting-agent-troubleshooting.html#spark-agents-qa-fine-grained). @@ -76,0 +44 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a +## Add the Apache Spark agents to your MCP client @@ -78 +46 @@ Proceed to the **Specify stack details** page, enter the **Stack name**. Enter a -You may also download and review [the CloudFormation template](https://github.com/aws-samples/aws-emr-utilities/blob/03c20fece616de23ec0ea5389f0113a5bc65fc3a/utilities/apache-spark-agents/spark-troubleshooting-agent-cloudformation/spark-troubleshooting-mcp-setup.yaml), specify the options above and launch the template by yourself with CloudFormation CLI commands, see below for an example: +To set your Region and add the MCP servers, run the following commands. Point `--profile` at the profile for the role that you use. This example uses the `default` profile. Replace it with your own. @@ -81,8 +49 @@ You may also download and review [the CloudFormation template](https://github.co - # deploy the stack with CloudFormation CLI commands - aws cloudformation deploy \ - --template-file spark-troubleshooting-mcp-setup.yaml \ - --stack-name spark-troubleshooting-mcp-setup \ - --region <your Spark MCP server launch region> \ - --capabilities CAPABILITY_NAMED_IAM \ - --parameter-overrides \ - TroubleshootingRoleName=spark-troubleshooting-role + export SMUS_MCP_REGION=<your mcp server launch region> @@ -90,22 +50,0 @@ You may also download and review [the CloudFormation template](https://github.co - - # retrieve the 1-line instruction to set the local environment variables, which will be used for the following MCP server configuration - aws cloudformation describe-stacks \ - --stack-name spark-troubleshooting-mcp-setup \ - --region <your Spark MCP server launch region> \ - --query "Stacks[0].Outputs[?OutputKey=='ExportCommand'].OutputValue" \ - --output text - -Open the Outputs tab (or retrieve from the CloudFormation describe-stacks CLI command above) and copy the 1-line instruction from the CloudFormation output to set your environment variables, then execute it in your local environment. Example 1-line instruction: - - - export SMUS_MCP_REGION=<your mcp server launch region> && export IAM_ROLE=arn:aws:iam::111122223333:role/spark-troubleshooting-role-xxxxxx - -Then run the following command locally to setup the IAM profile and MCP server configuration: - - - # Step 1: Configure AWS CLI Profile - aws configure set profile.smus-mcp-profile.role_arn ${IAM_ROLE} - aws configure set profile.smus-mcp-profile.source_profile <AWS CLI Profile to assume the IAM role - ex: default> - aws configure set profile.smus-mcp-profile.region ${SMUS_MCP_REGION} - - # Step 2: if you are using kiro CLI, use the following command to add the MCP configuration @@ -116 +55 @@ Then run the following command locally to setup the IAM profile and MCP server c - --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-troubleshooting/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"smus-mcp-profile\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ + --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-troubleshooting/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"default\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ @@ -124 +63 @@ Then run the following command locally to setup the IAM profile and MCP server c - --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-code-recommendation/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"smus-mcp-profile\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ + --args "[\"mcp-proxy-for-aws@latest\",\"https://sagemaker-unified-studio-mcp.${SMUS_MCP_REGION}.api.aws/spark-code-recommendation/mcp\", \"--service\", \"sagemaker-unified-studio-mcp\", \"--profile\", \"default\", \"--region\", \"${SMUS_MCP_REGION}\", \"--read-timeout\", \"180\"]" \ @@ -128 +67 @@ Then run the following command locally to setup the IAM profile and MCP server c -This should update `~/.kiro/settings/mcp.json` to include the MCP server configuration as below. +This updates `~/.kiro/settings/mcp.json` to include the MCP server configuration as follows. @@ -142 +81 @@ This should update `~/.kiro/settings/mcp.json` to include the MCP server configu - "smus-mcp-profile", + "default", @@ -160 +99 @@ This should update `~/.kiro/settings/mcp.json` to include the MCP server configu - "smus-mcp-profile", + "default", @@ -172 +111,12 @@ This should update `~/.kiro/settings/mcp.json` to include the MCP server configu -See [Supported Interfaces](./spark-troubleshooting-using-troubleshooting-agent.html#supported-interfaces) for the configuration guidance for different MCP clients like Kiro, Cline and GitHub CoPilot. +## Configure your MCP client + +You can also use the preceding configuration in other MCP clients and IDEs to connect to the managed MCP server: + + * **Integration with Cline** – To use the MCP server with Cline, modify `cline_mcp_settings.json` and add the MCP server configuration shown earlier. For more information about how to manage MCP configuration, see the [Cline documentation](https://docs.cline.bot/mcp/configuring-mcp-servers). + + * **Integration with Claude Code** – To use the MCP server with Claude Code, modify the configuration file to include the MCP configuration. The file path varies depending on your operating system. For detailed setup, see [https://code.claude.com/docs/en/mcp](https://code.claude.com/docs/en/mcp). + + * **Integration with GitHub Copilot** – To use the MCP server with GitHub Copilot, follow the instructions in [Extending Copilot Chat with MCP](https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp) to modify the corresponding configuration file, and follow the instructions for each IDE to activate the setup. + + + @@ -180 +130 @@ To use the Amazon Web Services Documentation, Javascript must be enabled. Please -Use Spark Troubleshooting Agent +Spark Troubleshooting and Optimization Agents @@ -182 +132 @@ Use Spark Troubleshooting Agent -Using the Troubleshooting Agent +IAM permissions