您好,我正在尝试在 Terraform 中添加 AWS Config。我已经像这样设置了以下策略附件:
resource aws_iam_policy policy {
name = "test-policy"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"config:PutEvaluations",
"config:PutConfigRule",
"config:DeleteConfigRule",
"config:GetComplianceDetailsByConfigRule",
"config:DescribeConfigRuleEvaluationStatus"
],
"Effect": "Allow",
"Resource": [
"arn:aws:config:*:*:config-rule/aws-service-rule/*securityhub*"
]
}
]
}
POLICY
}
我已验证 AWS 中的策略与上述策略附件相匹配。但是,当我在控制台中访问 AWS Config 服务时,我的每个配置规则都会出现以下错误:
Unable to perform config:PutEvaluations due to the lack of permissions on the role.
我在这个问题上没有找到任何好的资源。我一直在四处搜寻,但什么都没有出现。我只看到这篇文章:https ://aws.amazon.com/premiumsupport/knowledge-center/config-error-security-hub/ 。对此问题的任何帮助将不胜感激。作为参考,我将策略附加到 IAM 角色,如下所示:
resource aws_iam_role_policy_attachment "test-attach" {
role = aws_iam_role.config.name
policy_arn = aws_iam_policy.policy.arn
}
resource aws_iam_role config {
name = "myconfig"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "config.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}