问题
The following code is given below for my lambda funciton
import boto3
client = boto3.client('neptune') response =
client.stop_db_cluster(DBClusterIdentifier='qa-n1-cluster')
output is given below
Response: { "errorMessage": "'Neptune' object has no attribute 'stop_db_cluster'", "errorType": "AttributeError", "stackTrace": [ " File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n", " File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n module = _load(spec)\n", " File \"\", line 702, in _load\n", " File \"\", line 671, in _load_unlocked\n", " File \"\", line 783, in exec_module\n", " File \"\", line 219, in _call_with_frames_removed\n", " File \"/var/task/lambda_function.py\", line 4, in \n response = client.stop_db_cluster(DBClusterIdentifier='qa-n1-cluster')\n", " File \"/var/runtime/botocore/client.py\", line 514, in getattr\n raise AttributeError(\n" ] }
回答1:
stop_db_cluster() and start_db_cluster() are newer APIs (only released as of a couple of weeks ago. Can you please validate that you're on the latest version of boto3?
pip install --upgrade boto3
回答2:
You need boto version 1.11.721 (2020-02-12) or higher to be exact.
Change Log: https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md
1.11.721 2020-02-12
Amazon Neptune
This launch enables Neptune start-db-cluster and stop-db-cluster. Stopping and starting Amazon Neptune clusters helps you manage costs for development and test environments. You can temporarily stop all the DB instances in your cluster, instead of setting up and tearing down all the DB instances each time that you use the cluster.
Upgrade your boto version, and confirm that you are on a version newer than this.
来源:https://stackoverflow.com/questions/60528110/errormessage-neptune-object-has-no-attribute-stop-db-cluster