amazon-web-services - 无法使用 terraform 创建 elasticSearch 域
问题描述
我正在尝试使用 terraform 创建弹性搜索集群。
使用 terraform 0.11.13
请有人指出为什么我无法创建日志组?什么是资源访问策略?它与我正在创建的数据“aws_iam_policy_document”相同吗?
注意:我使用的是 elasticsearch_version = "7.9"
代码:
resource "aws_cloudwatch_log_group" "search_test_log_group" {
name = "/aws/aes/domains/test-es7/index-logs"
}
resource "aws_elasticsearch_domain" "amp_search_test_es7" {
domain_name = "es7"
elasticsearch_version = "7.9"
.....
log_publishing_options {
cloudwatch_log_group_arn = "${aws_cloudwatch_log_group.search_test_log_group.arn}"
log_type = "INDEX_SLOW_LOGS"
enabled = true
}
access_policies = "${data.aws_iam_policy_document.elasticsearch_policy.json}"
}
data "aws_iam_policy_document" "elasticsearch_policy" {
version = "2012-10-17"
statement {
effect = "Allow"
principals {
identifiers = ["*"]
type = "AWS"
}
actions = ["es:*"]
resources = ["arn:aws:es:us-east-1:xxx:domain/test_es7/*"]
}
statement {
effect = "Allow"
principals {
identifiers = ["es.amazonaws.com"]
type = "Service"
}
actions = [
"logs:PutLogEvents",
"logs:PutLogEventsBatch",
"logs:CreateLogStream",
]
resources = ["arn:aws:logs:*"]
}
}
我收到此错误
aws_elasticsearch_domain.test_es7: Error creating ElasticSearch domain: ValidationException: The Resource Access Policy specified for the CloudWatch Logs log group /aws/aes/domains/test-es7/index-logs does not grant sufficient permissions for Amazon Elasticsearch Service to create a log stream. Please check the Resource Access Policy.
解决方案
要使 ElasticSearch (ES) 能够写入 CloudWatch (CW) 日志,您必须在 CW 日志上提供基于资源的策略。
这是使用您的代码中缺少的aws_cloudwatch_log_resource_policy来实现的。
事实上,TF 文档有一个现成的例子来说明如何为 ES 做这件事,因此你应该能够复制和粘贴它。
ES访问策略与 CW 日志策略不同,因为它们决定了谁可以在您的 ES 域上做什么。因此,您必须调整代码的那部分以满足您的要求。
推荐阅读
- firebase - 当来自 rnfirebase 的 firestore 包时,数据未存储在 Firestore 中
- sql - 根据某些列过滤表中的记录
- excel - 如何过滤第一个日期和时间
- angular - 元素隐式具有“任何”类型,因为“任何”类型的表达式不能用于索引类型,任何人都可以告诉我
- php - 获取存储路径的正确 URL (Laravel)
- r - 从“popgenome”R包中通过readData导入multiVCF的问题
- vue.js - VueJS + NuxtJS + Vuetify - 未应用文本大小
- node.js - nodejs的h12请求超时heroku服务器
- node.js - 修剪失败后的 aws cloudformation 包
- javascript - 将 Javascript 日期转换为 java 日期