【问题标题】:Lambda function to stop RDS instance using tag filters使用标签过滤器停止 RDS 实例的 Lambda 函数
【发布时间】:2018-05-16 17:19:42
【问题描述】:

我正在尝试使用用 Python 2.7 编写的 AWS Lambda 函数来停止 RDS 实例。但是我无法使用标签过滤器获取实例。

import boto3
import logging
rds = boto3.client('rds')

def lambda_handler(event, context):
    filters = [{
            'Name': 'tag:Application',
            'Values': ['appname']
        },
        {
            'Name': 'instance-state-name', 
            'Values': ['running']
        }
    ]

    instances = rds.get_all_dbinstances.filter(Filters=filters)
    instances.status

获取所有带有指定标签的实例

这是我得到的错误:

{
  "stackTrace": [
    [
      "/var/task/lambda_function.py",
      18,
      "lambda_handler",
      "instances = rds.get_all_dbinstances(Filters=filters)"
    ],
    [
      "/var/runtime/botocore/client.py",
      553,
      "__getattr__",
      "self.__class__.__name__, item)"
    ]
  ],
  "errorType": "AttributeError",
  "errorMessage": "'RDS' object has no attribute 'get_all_dbinstances'"
}

【问题讨论】:

    标签: python aws-lambda aws-sdk amazon-rds boto3


    【解决方案1】:

    我相信您正在寻找的功能是describe_db_instances。没有名为get_all_dbinstances 的函数。请参考文档。

    【讨论】:

    • 有没有办法获取所有 RDS 实例及其状态?
    猜你喜欢
    • 2021-07-13
    • 2017-11-28
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-13
    相关资源
    最近更新 更多