【发布时间】:2018-09-10 10:05:08
【问题描述】:
我用 redshift 集群和一个 masteruser:testuser 创建了一个 cloudformation 堆栈
"RedshiftCluster" : {
"IamRoles" : [
{
"Fn::GetAtt": [
"IAMInstanceRole",
"Arn"
]
}
]
... other configurations
它使用以下 IAM 角色 (IAMInstanceRole),该角色处于同步状态,并且 redshift 集群已启动并运行:
"IAMInstanceRole": {
"Properties": {
"RoleName": "test-iam-role",
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com",
"redshift.amazonaws.com",
"s3.amazonaws.com"
]
}
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "root",
"PolicyDocument": {
"Version" : "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
}
]
}
我正在尝试使用复制命令和 iam_role 作为凭据将 csv 文件从 s3 加载到 redshift。 iam_role 具有 IAMInstanceRole 的 arn(如上所述)。 每当我执行以下命令时:
copy test_table from 's3://test-bucket/test.csv' CREDENTIALS 'aws_iam_role=arn:aws:iam::<account-id>:role/test-iam-role' MAXERROR 100000 removequotes TRIMBLANKS emptyasnull blanksasnull delimiter '|';
我得到错误:
ERROR: User arn:aws:redshift:us-west-2:189675173661:dbuser:automated-data-sanity-redshiftcluster-fbp9fgls6lri/sanityuser is not authorized to assume IAM Role arn:aws:iam::189675173661:role/sanity-test-iam-instance-role
DETAIL:
-----------------------------------------------
error: User arn:aws:redshift:us-west-2:<account-id>:dbuser:test-redshiftcluster-fbp9fgls6lri/testuser is not authorized to assume IAM Role arn:aws:iam::<account-id>:role/test-iam-role
code: 8001
context: IAM Role=arn:aws:iam::<account-id>:role/test-iam-role
query: 1139
location: xen_aws_credentials_mgr.cpp:236
process: padbmaster [pid=29280]
-----------------------------------------------
请提出一些解决方案。
【问题讨论】:
-
正如约翰的回答所定义的,您的代理角色文档不能有超过 1 个 AWS 服务。为每个服务创建单独的 IAM 角色。
-
即使在创建了单独的红移角色后,我仍然遇到同样的错误,您能否建议可能出了什么问题?
标签: amazon-web-services amazon-redshift amazon-iam