boto3-refresh-session 1.0.36__py3-none-any.whl → 6.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boto3_refresh_session/__init__.py +12 -3
- boto3_refresh_session/exceptions.py +51 -0
- boto3_refresh_session/methods/__init__.py +10 -0
- boto3_refresh_session/methods/custom.py +141 -0
- boto3_refresh_session/methods/iot/__init__.py +7 -0
- boto3_refresh_session/methods/iot/core.py +40 -0
- boto3_refresh_session/methods/iot/x509.py +570 -0
- boto3_refresh_session/methods/sts.py +230 -0
- boto3_refresh_session/session.py +67 -134
- boto3_refresh_session/utils/__init__.py +10 -0
- boto3_refresh_session/utils/cache.py +94 -0
- boto3_refresh_session/utils/internal.py +437 -0
- boto3_refresh_session/utils/typing.py +133 -0
- boto3_refresh_session-6.2.7.dist-info/METADATA +569 -0
- boto3_refresh_session-6.2.7.dist-info/RECORD +18 -0
- {boto3_refresh_session-1.0.36.dist-info → boto3_refresh_session-6.2.7.dist-info}/WHEEL +1 -1
- boto3_refresh_session-1.0.36.dist-info/METADATA +0 -164
- boto3_refresh_session-1.0.36.dist-info/RECORD +0 -7
- {boto3_refresh_session-1.0.36.dist-info → boto3_refresh_session-6.2.7.dist-info/licenses}/LICENSE +0 -0
- {boto3_refresh_session-1.0.36.dist-info → boto3_refresh_session-6.2.7.dist-info/licenses}/NOTICE +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: boto3-refresh-session
|
|
3
|
-
Version: 1.0.36
|
|
4
|
-
Summary: A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically.
|
|
5
|
-
License: MIT
|
|
6
|
-
Keywords: boto3,botocore,aws
|
|
7
|
-
Author: Mike Letts
|
|
8
|
-
Author-email: lettsmt@gmail.com
|
|
9
|
-
Maintainer: Michael Letts
|
|
10
|
-
Maintainer-email: lettsmt@gmail.com
|
|
11
|
-
Requires-Python: >=3.10
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Requires-Dist: boto3
|
|
19
|
-
Requires-Dist: botocore
|
|
20
|
-
Project-URL: Documentation, https://michaelthomasletts.github.io/boto3-refresh-session/index.html
|
|
21
|
-
Project-URL: Repository, https://github.com/michaelthomasletts/boto3-refresh-session
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
|
|
24
|
-
<div align="center">
|
|
25
|
-
<img src="https://raw.githubusercontent.com/michaelthomasletts/boto3-refresh-session/refs/heads/main/doc/brs.png" />
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
</br>
|
|
29
|
-
|
|
30
|
-
<div align="center"><em>
|
|
31
|
-
A simple Python package for refreshing the temporary security credentials in a <code>boto3.session.Session</code> object automatically.
|
|
32
|
-
</em></div>
|
|
33
|
-
|
|
34
|
-
</br>
|
|
35
|
-
|
|
36
|
-
<div align="center">
|
|
37
|
-
|
|
38
|
-
<a href="https://pypi.org/project/boto3-refresh-session/">
|
|
39
|
-
<img src="https://img.shields.io/pypi/v/boto3-refresh-session?color=%23FF0000FF&logo=python" alt="PyPI - Version"/>
|
|
40
|
-
</a>
|
|
41
|
-
|
|
42
|
-
<a href="https://github.com/michaelthomasletts/boto3-refresh-session/actions/workflows/push.yml">
|
|
43
|
-
<img src="https://img.shields.io/github/actions/workflow/status/michaelthomasletts/boto3-refresh-session/push.yml?logo=github&color=%23FF0000FF" alt="Workflow"/>
|
|
44
|
-
</a>
|
|
45
|
-
|
|
46
|
-
<a href="https://pypi.org/project/boto3-refresh-session/">
|
|
47
|
-
<img src="https://img.shields.io/pypi/pyversions/boto3-refresh-session?style=pypi&color=%23FF0000FF&logo=python" alt="Python Version"/>
|
|
48
|
-
</a>
|
|
49
|
-
|
|
50
|
-
<a href="https://github.com/michaelthomasletts/boto3-refresh-session/commits/main">
|
|
51
|
-
<img src="https://img.shields.io/github/last-commit/michaelthomasletts/boto3-refresh-session?logo=github&color=%23FF0000FF" alt="GitHub last commit"/>
|
|
52
|
-
</a>
|
|
53
|
-
|
|
54
|
-
<a href="https://pepy.tech/project/boto3-refresh-session">
|
|
55
|
-
<img src="https://img.shields.io/badge/downloads-45.6K-red?logo=python&color=%23FF0000" alt="Downloads"/>
|
|
56
|
-
</a>
|
|
57
|
-
|
|
58
|
-
<a href="https://michaelthomasletts.github.io/boto3-refresh-session/index.html">
|
|
59
|
-
<img src="https://img.shields.io/badge/official%20documentation-📘-FF0000?style=flat&labelColor=555&logo=readthedocs" alt="Documentation Badge"/>
|
|
60
|
-
</a>
|
|
61
|
-
|
|
62
|
-
<a href="https://github.com/michaelthomasletts/boto3-refresh-session">
|
|
63
|
-
<img src="https://img.shields.io/badge/source%20code-💻-FF0000?style=flat&labelColor=555&logo=github" alt="Source Code Badge"/>
|
|
64
|
-
</a>
|
|
65
|
-
|
|
66
|
-
<a href="https://michaelthomasletts.github.io/boto3-refresh-session/qanda.html">
|
|
67
|
-
<img src="https://img.shields.io/badge/Q%26A-❔-FF0000?style=flat&labelColor=555&logo=vercel" alt="Q&A Badge"/>
|
|
68
|
-
</a>
|
|
69
|
-
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
## Features
|
|
73
|
-
|
|
74
|
-
- Auto-refreshing credentials for long-lived `boto3` sessions
|
|
75
|
-
- Drop-in replacement for `boto3.session.Session`
|
|
76
|
-
- Supports `assume_role` configuration, custom STS clients, and profile / region configuration, as well as all other parameters supported by `boto3.session.Session`
|
|
77
|
-
- Tested, documented, and published to PyPI
|
|
78
|
-
- Used in production at major tech companies
|
|
79
|
-
|
|
80
|
-
## Adoption
|
|
81
|
-
|
|
82
|
-
The following line plot illustrates the adoption of BRS in terms of total downloads over a rolling seven day window since the inception of BRS.
|
|
83
|
-
|
|
84
|
-
<p align="center">
|
|
85
|
-
<img src="https://raw.githubusercontent.com/michaelthomasletts/boto3-refresh-session/refs/heads/main/doc/downloads.png" />
|
|
86
|
-
</p>
|
|
87
|
-
|
|
88
|
-
## Testimonials
|
|
89
|
-
|
|
90
|
-
From a Cyber Security Engineer at a FAANG company:
|
|
91
|
-
|
|
92
|
-
> _Most of my work is on tooling related to AWS security, so I'm pretty choosy about boto3 credentials-adjacent code. I often opt to just write this sort of thing myself so I at least know that I can reason about it. But I found boto3-refresh-session to be very clean and intuitive . . . we're using the RefreshableSession class as part of a client cache construct . . . we're using AWS Lambda to perform lots of operations across several regions in hundreds of accounts, over and over again, all day every day. And it turns out that there's a surprising amount of overhead to creating boto3 clients (mostly deserializing service definition json), so we can run MUCH more efficiently if we keep a cache of clients, all equipped with automatically refreshing sessions._
|
|
93
|
-
|
|
94
|
-
## Installation
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
pip install boto3-refresh-session
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Usage
|
|
101
|
-
|
|
102
|
-
```python
|
|
103
|
-
import boto3_refresh_session as brs
|
|
104
|
-
|
|
105
|
-
# you can pass all of the params associated with boto3.session.Session
|
|
106
|
-
profile_name = '<your-profile-name>'
|
|
107
|
-
region_name = 'us-east-1'
|
|
108
|
-
...
|
|
109
|
-
|
|
110
|
-
# as well as all of the params associated with STS.Client.assume_role
|
|
111
|
-
assume_role_kwargs = {
|
|
112
|
-
'RoleArn': '<your-role-arn>',
|
|
113
|
-
'RoleSessionName': '<your-role-session-name>',
|
|
114
|
-
'DurationSeconds': '<your-selection>',
|
|
115
|
-
...
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
# as well as all of the params associated with STS.Client, except for 'service_name'
|
|
119
|
-
sts_client_kwargs = {
|
|
120
|
-
'region_name': region_name,
|
|
121
|
-
...
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
# basic initialization of boto3.session.Session
|
|
125
|
-
session = brs.RefreshableSession(
|
|
126
|
-
assume_role_kwargs=assume_role_kwargs, # required
|
|
127
|
-
sts_client_kwargs=sts_client_kwargs,
|
|
128
|
-
region_name=region_name,
|
|
129
|
-
profile_name=profile_name,
|
|
130
|
-
...
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
# now you can create clients, resources, etc. without worrying about expired temporary
|
|
134
|
-
# security credentials
|
|
135
|
-
s3 = session.client(service_name='s3')
|
|
136
|
-
buckets = s3.list_buckets()
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Raison d'être
|
|
140
|
-
|
|
141
|
-
It is common for data pipelines and workflows that interact with the AWS API via
|
|
142
|
-
`boto3` to run for a long time and, accordingly, for temporary credentials to
|
|
143
|
-
expire.
|
|
144
|
-
|
|
145
|
-
Usually, engineers deal with that problem one of two ways:
|
|
146
|
-
|
|
147
|
-
- `try except` blocks that catch `ClientError` exceptions
|
|
148
|
-
- A similar approach as that used in this project -- that is, using methods available
|
|
149
|
-
within `botocore` for refreshing temporary credentials automatically.
|
|
150
|
-
|
|
151
|
-
Speaking personally, variations of the code found herein exists in code bases at
|
|
152
|
-
nearly every company where I have worked. Sometimes, I turned that code into a module;
|
|
153
|
-
other times, I wrote it from scratch. Clearly, that is inefficient.
|
|
154
|
-
|
|
155
|
-
I decided to finally turn that code into a proper Python package with unit testing,
|
|
156
|
-
automatic documentation, and quality checks; the idea being that, henceforth, depending
|
|
157
|
-
on my employer's open source policy, I may simply import this package instead of
|
|
158
|
-
reproducing the code herein for the Nth time.
|
|
159
|
-
|
|
160
|
-
If any of that sounds relatable, then `boto3-refresh-session` should help you.
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
📄 Licensed under the MIT License.
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
boto3_refresh_session/__init__.py,sha256=WGwUI6m0hFjXzTL0PwB9X7KK1rx1l-o9fE0IX40mv5I,158
|
|
2
|
-
boto3_refresh_session/session.py,sha256=jDSjEHIZkGvMEOKzCtcOT7j41rOOoR_tei_dffS0Cww,5887
|
|
3
|
-
boto3_refresh_session-1.0.36.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
|
|
4
|
-
boto3_refresh_session-1.0.36.dist-info/METADATA,sha256=r6Ns0Voo3H1Hp8LH2GxSP9to_4uOrClhLcoqSE9tqNE,6797
|
|
5
|
-
boto3_refresh_session-1.0.36.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
|
|
6
|
-
boto3_refresh_session-1.0.36.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
7
|
-
boto3_refresh_session-1.0.36.dist-info/RECORD,,
|
{boto3_refresh_session-1.0.36.dist-info → boto3_refresh_session-6.2.7.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
{boto3_refresh_session-1.0.36.dist-info → boto3_refresh_session-6.2.7.dist-info/licenses}/NOTICE
RENAMED
|
File without changes
|