2016-04-27 62 views
5

我正在尝试运行Spark EC2脚本来启动IAM角色下的我的用户在我的root帐户下可以承担的集群。运行带有IAM角色的Spark EC2脚本

this JIRA ticket,我们现在可以运行星火EC2脚本时指定--profilecomments on the pull request说,--profile选项指的是什么,我相信作为AWSCLI轮廓。

当我运行脚本,

ec2/spark-ec2 -k key-name -i key-name.pem -s 1 --profile myprofile --instance-type=t2.medium launch test-cluster 

我得到

Profile "myprofile" not found! 

但是,运行

aws s3 ls s3://mybucket --profile myprofile 

作品如预期,导致我联想到IAM角色正确指定在~/.aws/config(我不认为你在中指定了IAM角色10)。

然而,当我添加一个测试配置文件到~/.aws/credentials

[foobar] 
aws_secret_access_key=xxxxxxx 
aws_access_key_id=xxxxxxx 

星火发现foobar轮廓。然而,加入后

[foobar] 
role_arn = arn:aws:iam::12345:role/MY_ROLE 
aws_secret_access_key=xxxxxxx 
aws_access_key_id=xxxxxxx 

星火发现foobar配置文件,但它不能正常登录到IAM角色。我得到

boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request 
<?xml version="1.0" encoding="UTF-8"?> 
<Response><Errors><Error><Code>InvalidKeyPair.NotFound</Code><Message>The key pair 'key-name' does not exist</Message></Error></Errors><RequestID>fcebd475-a895-4a5b-9a29-9783fd6b7f3d</RequestID></Response> 

这是因为密钥对key-name没有我的用户下存在的,但它确实在我需要承担的IAM角色存在。这告诉我Spark没有正确登录到IAM角色。


~/.aws/config

[default] 
region = us-east-1 
aws_secret_access_key = xxxxx 
aws_access_key_id = xxxxx 

[profile myprofile] 
role_arn = arn:aws:iam::12345:role/MY_ROLE 
source_profile = default 

~/.aws/credentials

[default] 
aws_secret_access_key = xxxxx 
aws_access_key_id = xxxxx 

边笔记记录也试过:

一与

aws sts assume-role --role-arn arn:aws:iam::12345:role/MY_ROLE --role-session-name temp-session 

然后导出AWS_SECRET_ACCESS_KEYAWS_SESSION_TOKEN,并AWS_ACCESS_KEY_ID环境变量手动ssuming的作用。 然后我跑了EC2脚本,而无需指定的任何个人资料,并得到

boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized 
<?xml version="1.0" encoding="UTF-8"?> 
<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>11402f6e-074c-478c-84c1-11fb92ad0bff</RequestID></Response> 

边笔记记录也试过:

this JIRA on Spark scripts with IAM roles,我们可以指定--instance-profile-name的一个实例配置文件只有这样才能使用IAM角色?ie ..我必须问我们的管理员IAM列表/创建权限来启动具有IAM角色的群集吗?)。我一直在使用arn:aws:iam::12345:role/MY_ROLEMY_ROLE但得到

boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request 
<?xml version="1.0" encoding="UTF-8"?> 
<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value (arn:aws:iam::12345:role/MY_ROLE) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name</Message></Error></Errors><RequestID>ffeffef9-acad-4a34-a925-31f6b5bbbb3e</RequestID></Response> 

回答

0

我设法通过提供“--instance瞩目的名”参数与火花EC2脚本,你可以通过配置文件分配一个角色的EC2实例尝试名称。

实例里面一定要在我的问题上运行

sudo yum update 

看也: Running Spark EC2 scripts with IAM role

好运