【发布时间】:2022-01-03 03:44:52
【问题描述】:
问题
我正在尝试在 AWS Redshift 集群上启用审计日志记录。我一直在遵循 AWS 提供的说明:https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-enable-logging
当前配置
我已将相关的 IAM 角色定义如下
resource "aws_iam_role" "example-role" {
name = "example-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "redshift.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
并已将以下 IAM 权限授予example-role 角色:
{
"Sid": "AllowAccessForAuditLogging",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetBucketAcl"
],
"Resource": [
"arn:aws:s3:::example-bucket",
"arn:aws:s3:::example-bucket/*"
]
},
redshift集群配置相关部分如下:
resource "aws_redshift_cluster" "example-cluster-name" {
cluster_identifier = "example-cluster-name"
...
# redshift audit logging to S3
logging {
enable = true
bucket_name = "example-bucket-name"
}
master_username = var.master_username
iam_roles = [aws_iam_role.example-role.arn]
...
错误
terraform plan 运行正常,并根据上述配置产生预期的计划。但是,在运行terraform apply 时会出现以下错误:
Error: error enabling Redshift Cluster (example-cluster-name) logging: InsufficientS3BucketPolicyFault: Cannot read ACLs of bucket example-bucket-name. Please ensure that your IAM permissions are set up correctly.
注意:我已将所有资源标识符替换为 example-* 资源名称和标识符。
【问题讨论】:
-
您需要将您的角色作为存储桶策略。可能您将其附加为 IAM 角色?
-
你是对的,做到了!谢谢!
标签: amazon-web-services terraform amazon-redshift amazon-iam terraform-provider-aws