aws cli 工具设置 - 无法连接 ec2 并检索实例信息

aws cli 工具设置 - 无法连接 ec2 并检索实例信息

我正在尝试使用aws configure设置 cli 工具

aws configure --profile work
AWS Access Key ID [None]: ABCD
AWS Secret Access Key [None]: 123456
Default region name [None]: 
Default output format [None]: 

它创建一个文件:

cat ~/.aws/config 
[profile work]
aws_access_key_id = ABCD
aws_secret_access_key = 123456

work在 bash shell 中将默认配置文件设置为

export AWS_DEFAULT_PROFILE=work

并执行aws ec2 describe-instances

但是它似乎挂了。等待 5 分钟后,我按 Ctrl-C 执行命令。我毫无困难地从 ec2 控制台获取实例信息。

出了什么问题?我注意到有些文档说 SDK 和 CLI 需要不同的配置文件格式。这是一个因素吗?

这是 ctrl-c 的堆栈跟踪

Traceback (most recent call last):
  File "/Users/antkong/aws/aws-ve/bin/aws", line 23, in <module>
    sys.exit(main())
  File "/Users/antkong/aws/aws-ve/bin/aws", line 19, in main
    return awscli.clidriver.main()
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 49, in main
    return driver.main()
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 195, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 343, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 450, in __call__
    self._operation_object, call_parameters, parsed_globals)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 553, in invoke
    parsed_globals)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/clidriver.py", line 566, in _display_response
    formatter(operation, response)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/awscli/formatter.py", line 224, in __call__
    for _, page in response:
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/paginate.py", line 156, in __iter__
    **current_kwargs)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/operation.py", line 68, in call
    response = endpoint.make_request(self, params)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/endpoint.py", line 69, in make_request
    return self._send_request(prepared_request, operation)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/endpoint.py", line 123, in _send_request
    attempts)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/endpoint.py", line 132, in _get_response
    proxies=self.proxies, timeout=self.timeout)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/vendored/requests/sessions.py", line 464, in send
    r = adapter.send(request, **kwargs)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/vendored/requests/adapters.py", line 321, in send
    timeout=timeout
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 471, in urlopen
    body=body, headers=headers)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 285, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 995, in request
    self._send_request(method, url, body, headers)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/awsrequest.py", line 116, in _send_request
    self, method, url, body, headers)
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1029, in _send_request
    self.endheaders(body)
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 991, in endheaders
    self._send_output(message_body)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/awsrequest.py", line 130, in _send_output
    self.send(msg)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/awsrequest.py", line 203, in send
    return HTTPConnection.send(self, str)
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 806, in send
    self.connect()
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 73, in connect
    timeout=self.timeout,
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 562, in create_connection
    sock.connect(sa)
  File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
KeyboardInterrupt

编辑

当我打开调试标志时,我得到了这些信息:

2014-10-02 13:16:04,019 - MainThread - botocore.retryhandler - DEBUG - retry needed, retryable exception caught: (<botocore.awsrequest.AWSHTTPSConnection instance at 0x1091c1cf8>, 'Connection to ec2.us-west-2a.amazonaws.com timed out. (connect timeout=60)')
Traceback (most recent call last):
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/retryhandler.py", line 262, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/retryhandler.py", line 310, in __call__
    caught_exception)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/retryhandler.py", line 219, in __call__
    return self._check_caught_exception(attempt_number, caught_exception)
  File "/Users/antkong/aws/aws-ve/lib/python2.7/site-packages/botocore/retryhandler.py", line 352, in _check_caught_exception
    raise caught_exception
Timeout: (<botocore.awsrequest.AWSHTTPSConnection instance at 0x1091c1cf8>, 'Connection to ec2.us-west-2a.amazonaws.com timed out. (connect timeout=60)')
2014-10-02 13:16:04,019 - MainThread - botocore.retryhandler - DEBUG - Retry needed, action of: 2.20577344724
2014-10-02 13:16:04,019 - MainThread - botocore.endpoint - DEBUG - Response received to retry, sleeping for 2.20577344724 seconds
2014-10-02 13:16:06,225 - MainThread - botocore.endpoint - DEBUG - Sending http request: <PreparedRequest [POST]>
2014-10-02 13:16:06,226 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (4): ec2.us-west-2a.amazonaws.com

显然我可以 ping 该 URL:ec2.us-west-2a.amazonaws.com

那么为什么超时?

相关内容