我正在尝试通过terraform构建EMR集群。但是我在应用代码时遇到以下错误。 IAM_EMR_for_EC2是我为集群中的EC2创建的实例配置文件角色。
发生1个错误:
aws_emr_cluster.tf-test-cluster:发生了1个错误:
aws_emr_cluster.tf-test-cluster:ValidationException:实例配置文件'arn:aws:iam ::: role / IAM_EMR_for_EC2'不是 良好的。期望INSTANCE_PROFILE类型的资源。 状态代码:400,请求ID:6bd4461c-637f-11e8-8605-c930816c10b8
有人可以帮助我,因为我无法理解这个错误,也无法找到谷歌的任何细节。
答案 0 :(得分:2)
您正在应用角色而不是实例配置文件,它们实际上是不同的。 ARN必须采用#!/bin/sh
REPOS="$1"
TXN="$2"
GREP=/bin/grep
SED=/bin/sed
AWK=/usr/bin/awk
SVNLOOK=/usr/bin/svnlook
AUTHOR=`$SVNLOOK author -t "$TXN" "$REPOS"`
if [ "$AUTHOR" == "testuser" ]; then
exit 0
fi
if [ "$AUTHOR" == "" ]; then
exit 0
fi
CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" | $GREP "^[U|A]" | $AWK '{print $2}'`
COMPARE=`$SVNLOOK diff -t "$TXN" "$REPOS"`
#Operation 001 Beginning
#Restrict users from commiting against testfile
for PATH in $CHANGED
do
if [[ "$PATH" == *path/to/file/testfile.txt ]]; then
#allow testuser to have universal commit permissions in this path.
if [ "$AUTHOR" == "testuser" ]; then
exit 0
else
#User is trying to modify testfile.txt
echo "Only testuser can edit testfile.txt." 1>&2
exit 1
fi
fi
done
#Operation 001 Completed
#Operation 002 Beginning
#Restrict commits based on string found in file
for PATH in $COMPARE
do
if [[ "$PATH" == *path/to/look/at/only/* ]]; then
$SVNLOOK diff -t "$TXN" "$REPOS" | egrep 'string1|string2|string3' > /dev/null && { echo "Cannot commit using string1, string2 or string3 in files trying to commit" 1>&2; exit 1; }
else exit 0;
fi
done
#Operation 002 Completed
。
需要将角色附加到实例配置文件资源。
答案 1 :(得分:1)
您应该写instance_profile = "${aws_iam_instance_profile.emr_profile.arn}"
。
并创建emr_profile资源:
resource "aws_iam_instance_profile" "emr_profile" {
name = "emr_profile"
role = "${aws_iam_role.EMR_EC2_DefaultRole.name}"
}