创建 boto3 会话会触发对 AWS API 的 http 请求吗?

Does creating a boto3 session trigger an http request to the AWS API?

创建 boto3 会话是否会触发对 AWS 的 http 请求API?

还是仅在资源操作发生时才发生?

不,不是。 boto3 会话是配置数据和状态的本地集合,例如凭据、区域等。与 AWS 后端没有交互 API。要实际调用 AWS API,您需要使用会话创建一个 boto3 客户端或资源,然后调用该客户端或资源上的各种方法。

reference documentation for Session 显示它确实公开了可能导致 API 调用 AWS 的方法,但我不相信这些被调用(除非 you决定打电话给他们)。它们包括:

  • get_available_partitions
  • get_available_regions

您可以查看 source code for Session 以了解它似乎只是配置和状态的容器。这是 class:

的内联文档的开头

A session stores configuration state and allows you to create service clients and resources.