boto3
を使用してEC2 instance
を開始しようとしています。私は以下のコードを実行すると、それは細かいAWS EC2のstart_instances()はキーワード引数のみを受け入れます。
import boto3
ec2client = boto3.client('ec2')
class StartInstances:
def start_ec_instances(self):
response = ec2client.start_instances(InstanceIds=['i-XXXXXXXXXX'])
return
StartInstances().start_ec_instances()
に動作します。しかし、私は下のコードを実行するとき、私は
import boto3
ec2client = boto3.client('ec2')
class StartInstances:
def start_ec_instances(self, instanceid):
response = ec2client.start_instances(instanceid)
return
StartInstances().start_ec_instances('InstanceIds=[\'i-XXXXXXXXXX\']')
Traceback (most recent call last): File "/Users/xxx/PycharmProjects/ctm-scripting-utils/ec2/start_instances.py", line 25, in StartInstances().start_ec_instances("InstanceIds=[\'i-XXXXXXXXXX\']") File "/Users/xxx/PycharmProjects/ctm-scripting-utils/ec2/start_instances.py", line 11, in start_ec_instances response = ec2client.start_instances(instanceids) File "/Users/xxx/Library/Python/3.6/lib/python/site-packages/botocore/client.py", line 310, in _api_call "%s() only accepts keyword arguments." % py_operation_name) TypeError: start_instances() only accepts keyword arguments.