我有一个与我的EC2实例关联的IAM角色,其中有关于Redshift的以下政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"redshift:*"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
但是,从我的AWS SDK或CLI的EC2实例,我无法创建群集。
两个
InstanceProfileCredentialsProvider creds = new InstanceProfileCredentialsProvider(false);
AmazonRedshift redshift = AmazonRedshiftClientBuilder.standard().withCredentials(creds).build();
CreateClusterRequest request = new CreateClusterRequest();
request.setAllowVersionUpgrade(true);
request.setClusterType("multi-node");
request.setClusterIdentifier("identifier");
request.setDBName("dbname");
request.setIamRoles(Collections.singleton("iam_role_arn")));
request.setPubliclyAccessible(true);
request.setNodeType("dc1.8xlarge");
request.setNumberOfNodes(2);
request.setPort(8192);
request.setMasterUsername("username");
request.setMasterUserPassword("Password1");
Cluster cluster = redshift.createCluster(request);
和
aws redshift create-cluster --cluster-identifier identifier --master-username username --master-user-password Password1 --node-type dc1.8xlarge --region us-west-2 --number-of-nodes 2
结果:
An error occurred (UnauthorizedOperation) when calling the CreateCluster operation: Access Denied. Please ensure that your IAM Permissions allow this operation.
使用IAM策略模拟工具,我能够确认我的实例角色是否具有创建Redshift群集的权限。
理解这一点的任何帮助都将受到赞赏。
答案 0 :(得分:2)
如果您能够调用其他Redshift操作并且仅在createCluster()
上失败,那么错误可能是由传递给Redshift的IAM角色引起的。< / p>
您需要Grant a User Permissions to Pass a Role to an AWS Service。
背后的逻辑是:
PassRole
权限,说明是否允许他们将角色传递给Redshift,甚至允许他们通过哪些角色。这同样适用于将角色传递到Amazon EC2实例。