View a markdown version of this page

IAM 역할 설정 - Amazon EMR

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

IAM 역할 설정

사전 조건

시작하기 전에 다음을 갖추었는지 확인하세요.

후속 명령에 사용할 다음 변수를 설정합니다.

ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) REGION=$(aws configure get region)

1단계 - IAM 역할 생성

SMUS MCP 서버는 IAM 역할을 사용하여 AWS 서비스 수준에서 작업을 승인합니다. 별도의 MCP별 권한은 필요하지 않습니다.

IAM 역할을 생성하려면(AWS CLI)

  1. 계정이 역할을 수임할 수 있도록 허용하는 신뢰 정책 문서를 생성합니다.

    cat > mcp-trust-policy.json << EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowAccountToAssumeRole", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${ACCOUNT_ID}:root" }, "Action": "sts:AssumeRole" } ] } EOF
  2. 역할을 생성합니다.

    aws iam create-role \ --role-name SparkTroubleshootingMCPRole \ --assume-role-policy-document file://mcp-trust-policy.json

2단계: 배포 모드에 대한 권한 연결

Spark 배포 플랫폼과 일치하는 권한 정책을 연결합니다. 사용하는 플랫폼에 따라 다음 중 하나 이상을 연결할 수 있습니다.

옵션 A: EC2의 EMR

  1. 정책 문서를 생성합니다.

    cat > emr-ec2-policy.json << 'EOF' { "Version": "2012-10-17", "Statement": [ { "Sid": "EMREC2ReadAccess", "Effect": "Allow", "Action": [ "elasticmapreduce:DescribeCluster", "elasticmapreduce:DescribeStep", "elasticmapreduce:ListSteps", "elasticmapreduce:ListClusters", "elasticmapreduce:DescribeJobFlows" ], "Resource": ["*"] }, { "Sid": "EMRS3LogAccess", "Effect": "Allow", "Action": ["s3:GetObject", "s3:ListBucket"], "Resource": "*" }, { "Sid": "EMRPersistentApp", "Effect": "Allow", "Action": [ "elasticmapreduce:CreatePersistentAppUI", "elasticmapreduce:DescribePersistentAppUI", "elasticmapreduce:GetPersistentAppUIPresignedURL" ], "Resource": ["*"] } ] } EOF
  2. 정책을 생성하고 연결합니다.

    aws iam put-role-policy \ --role-name SparkTroubleshootingMCPRole \ --policy-name EMREC2TroubleshootingAccess \ --policy-document file://emr-ec2-policy.json

또는 역할이 이미 사용하는 경우 AmazonElasticMapReduceFullAccess AWS 관리형 정책을 연결할 수 있습니다.

aws iam attach-role-policy \ --role-name SparkTroubleshootingMCPRole \ --policy-arn arn:aws:iam::aws:policy/AmazonElasticMapReduceFullAccess

옵션 B: AWS Glue

  1. 정책 문서를 생성합니다.

    cat > glue-policy.json << EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "GlueReadAccess", "Effect": "Allow", "Action": [ "glue:GetJob", "glue:GetJobRun", "glue:GetJobRuns", "glue:GetJobs", "glue:BatchGetJobs" ], "Resource": ["arn:aws:glue:*:${ACCOUNT_ID}:job/*"] }, { "Sid": "GlueCloudWatchLogsAccess", "Effect": "Allow", "Action": ["logs:GetLogEvents", "logs:FilterLogEvents"], "Resource": ["arn:aws:logs:*:${ACCOUNT_ID}:log-group:/aws/glue/*"] }, { "Sid": "GlueSparkWebUI", "Effect": "Allow", "Action": [ "glue:RequestLogParsing", "glue:GetLogParsingStatus", "glue:GetEnvironment", "glue:GetStage", "glue:GetStages", "glue:GetStageFiles", "glue:BatchGetStageFiles", "glue:GetStageAttempt", "glue:GetStageAttemptTaskList", "glue:GetStageAttemptTaskSummary", "glue:GetExecutors", "glue:GetExecutorsThreads", "glue:GetStorage", "glue:GetStorageUnit", "glue:GetQueries", "glue:GetQuery", "glue:GetDashboardUrl" ], "Resource": ["arn:aws:glue:*:${ACCOUNT_ID}:job/*"] }, { "Sid": "GluePassRoleAccess", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "*", "Condition": { "StringLike": { "iam:PassedToService": "glue.amazonaws.com" } } } ] } EOF
  2. 정책을 연결합니다.

    aws iam put-role-policy \ --role-name SparkTroubleshootingMCPRole \ --policy-name GlueTroubleshootingAccess \ --policy-document file://glue-policy.json

옵션 C: EMR Serverless

  1. 정책 문서를 생성합니다.

    cat > emr-serverless-policy.json << EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "EMRServerlessReadAccess", "Effect": "Allow", "Action": [ "emr-serverless:GetJobRun", "emr-serverless:GetApplication", "emr-serverless:ListApplications", "emr-serverless:ListJobRuns", "emr-serverless:ListJobRunAttempts", "emr-serverless:GetDashboardForJobRun", "emr-serverless:ListTagsForResource" ], "Resource": ["*"] }, { "Sid": "EMRServerlessCloudWatchLogsAccess", "Effect": "Allow", "Action": ["logs:GetLogEvents", "logs:FilterLogEvents"], "Resource": ["arn:aws:logs:*:${ACCOUNT_ID}:log-group:/aws/emr-serverless/*"] }, { "Sid": "EMRServerlessS3LogsAccess", "Effect": "Allow", "Action": ["s3:GetObject", "s3:ListBucket"], "Resource": "*" } ] } EOF
  2. 정책을 연결합니다.

    aws iam put-role-policy \ --role-name SparkTroubleshootingMCPRole \ --policy-name EMRServerlessTroubleshootingAccess \ --policy-document file://emr-serverless-policy.json

선택 사항: 암호화된 CloudWatch Logs에 대한 KMS 권한

CloudWatch Logs가 고객 관리형 KMS 키로 암호화된 경우 다음을 추가합니다(KMS 키 ID<KEY_ID>로 대체).

aws iam put-role-policy \ --role-name SparkTroubleshootingMCPRole \ --policy-name KMSCloudWatchLogsDecrypt \ --policy-document "{ \"Version\": \"2012-10-17\", \"Statement\": [{ \"Effect\": \"Allow\", \"Action\": [\"kms:Decrypt\", \"kms:DescribeKey\"], \"Resource\": \"arn:aws:kms:${REGION}:${ACCOUNT_ID}:key/<KEY_ID>\" }] }"

3단계: MCP 클라이언트 구성

생성한 역할 ARN을 사용하도록 MCP 클라이언트(예: Claude Desktop 또는 Amazon Q Developer)를 구성합니다.

echo "arn:aws:iam::${ACCOUNT_ID}:role/SparkTroubleshootingMCPRole"

자격 AWS 증명을 구성하는 방법은 MCP 클라이언트의 설명서를 참조하세요(일반적으로이 역할을 수임하는 AWS 프로필을 통해).

MCP 서버 요청에 사용되는 조건 키

SMUS MCP 서버를 통해 이루어진 모든 요청에 두 개의 조건 키가 자동으로 추가됩니다.

  • aws:ViaAWSMCPService - AWS 관리형 MCP 서버를 통해 이루어진 모든 요청에 true 대해를 로 설정합니다.

  • aws:CalledViaAWSMCP - MCP 서버 서비스 보안 주체(예: sagemaker-unified-studio-mcp.amazonaws.com)로 설정합니다.

이러한 조건 키를 사용하여 요청이 AWS 관리형 MCP 서버에서 시작될 때 리소스에 대한 액세스를 제어할 수 있습니다.

예: SMUS MCP 서버를 통해 액세스할 때만 Glue 읽기 작업 허용:

{ "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" } } } ] }

예: 관리형 MCP 서버를 통해 AWS 액세스할 때 삭제 작업 거부:

{ "Effect": "Deny", "Action": ["s3:DeleteObject", "s3:DeleteBucket"], "Resource": "*", "Condition": { "Bool": { "aws:ViaAWSMCPService": "true" } } }

조건 키에 대한 자세한 내용은 IAM 사용 설명서AWS 전역 조건 컨텍스트 키를 참조하세요.