lambda在弹性搜索中删除早于x天的索引
我用了这个脚本
import boto3
from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection
import curator
host = 'XXXXXXXXXXXXXXXX.us-east-1.es.amazonaws.com'
region = 'us-east-1'
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
def lambda_handler(event, context):
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
index_list = curator.IndexList(es)
index_list.filter_by_age(source='creation_date', direction='older', timestring='%Y-%m-%d', unit='days', unit_count=7)
print("Found %s indices to delete" % len(index_list.indices))
if index_list.indices:
curator.DeleteIndices(index_list).do_action()
print('Indices deleted successfully')
运行此脚本时,会显示属性错误
如何解决这个问题
Traceback (most recent call last):
File "curator_03.py", line 10, in <module>
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
AttributeError: 'NoneType' object has no attribute 'access_key'
目前没有回答
相关问题 更多 >
编程相关推荐