我试图重新启动远程实例:EC2实例重新启动 - 实例ID不存在
ec2 = boto.connect_ec2(aws_access_key_id = key_id, aws_secret_access_key = access_key)
ec2.reboot_instances([instanceId])
,并得到了错误The instance ID 'i-xxxxx' does not exist
貌似我应该连接到区域 - 我怎样才能得到这个值如果实例ID是唯一的输入参数?
我试图重新启动远程实例:EC2实例重新启动 - 实例ID不存在
ec2 = boto.connect_ec2(aws_access_key_id = key_id, aws_secret_access_key = access_key)
ec2.reboot_instances([instanceId])
,并得到了错误The instance ID 'i-xxxxx' does not exist
貌似我应该连接到区域 - 我怎样才能得到这个值如果实例ID是唯一的输入参数?
你的实例是否处于运行状态?尝试使用下面的命令: - 如访问密钥,秘密访问密钥和区域相关的信息
reservations = ec2_conn.get_all_instances(filters={'instance-id' : 'i-xxxxxxxx'})
new_instance = reservations[0].instances[0]
证书应的代码之外进行配置。这是为了确保可移植性。
boto3查找凭据的机制是搜索可能位置的列表,并在找到凭据后立即停止。其中Boto3搜索证书的顺序是:
boto.client()
方法~/.aws/credentials
)~/.aws/config
)/etc/boto.cfg
和~/.boto
)如果脚本本身在EC2实例中运行,则最佳做法是依赖将采用IAM角色的实例元数据。
假设你从本地机器调用脚本,最简单的方法是修改~/.aws/credentials
运行$ aws configure
并指定该区域。
阅读更多:http://boto3.readthedocs.io/en/latest/guide/configuration.html