boto3-refresh-session 1.0.4__py3-none-any.whl → 1.0.6__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.
@@ -3,5 +3,6 @@ __all__ = []
3
3
  from . import session
4
4
  from .session import RefreshableSession
5
5
 
6
- __all__.extend(["session", "RefreshableSession"])
7
- __version__ = "1.0.4"
6
+ __all__.extend(session.__all__)
7
+ __version__ = "1.0.6"
8
+ __author__ = "Mike Letts"
@@ -7,6 +7,7 @@ credentials.
7
7
  __all__ = ["RefreshableSession"]
8
8
 
9
9
  from typing import Any, Dict
10
+ from warnings import warn
10
11
 
11
12
  from boto3 import client
12
13
  from boto3.session import Session
@@ -30,8 +31,8 @@ class RefreshableSession(Session):
30
31
  immediately upon expiration. It is highly recommended that you use ``True``.
31
32
  Default is ``True``.
32
33
  sts_client_kwargs : dict, optional
33
- Optional keyword arguments for the :class:`STS.Client` object. Default is
34
- None.
34
+ Optional keyword arguments for the :class:`STS.Client` object. Do not provide
35
+ values for ``service_name``. Default is None.
35
36
 
36
37
  Other Parameters
37
38
  ----------------
@@ -109,6 +110,12 @@ class RefreshableSession(Session):
109
110
 
110
111
  # initializing the STS client
111
112
  if sts_client_kwargs is not None:
113
+ # overwriting 'service_name' in case it appears in sts_client_kwargs
114
+ if "service_name" in sts_client_kwargs:
115
+ warn(
116
+ "The sts_client_kwargs parameter cannot contain values for service_name. Reverting to service_name = 'sts'."
117
+ )
118
+ del sts_client_kwargs["service_name"]
112
119
  self._sts_client = client(service_name="sts", **sts_client_kwargs)
113
120
  else:
114
121
  self._sts_client = client(service_name="sts")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3-refresh-session
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically.
5
5
  License: MIT
6
6
  Keywords: boto3,botocore,aws
@@ -32,71 +32,76 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  A simple Python package for refreshing the temporary security credentials in a `boto3.session.Session` object automatically.
34
34
 
35
- - [Documentation](https://michaelthomasletts.github.io/boto3-refresh-session/index.html)
35
+ - [Official Documentation](https://michaelthomasletts.github.io/boto3-refresh-session/index.html)
36
36
  - [Source Code](https://github.com/michaelthomasletts/boto3-refresh-session)
37
37
  - [PyPI](https://pypi.org/project/boto3-refresh-session/)
38
38
  - [Contributing](https://michaelthomasletts.github.io/boto3-refresh-session/contributing.html)
39
+ - [Authorization](https://michaelthomasletts.github.io/boto3-refresh-session/authorization.html)
39
40
 
40
- ### Why should I use this?
41
-
42
- It is common for data pipelines and workflows that interact with the AWS API via
43
- `boto3` to run for a long time and, accordingly, for temporary credentials to
44
- expire.
45
-
46
- Usually, engineers deal with that problem one of two different ways:
47
-
48
- - A `try except` block that catches `botocore.exceptions.ClientError` exceptions
49
- - A similar approach as that used in this project -- that is, using methods available
50
- within `botocore` for refreshing temporary credentials automatically.
51
-
52
- Speaking personally, variations of the code found herein exists in code bases at
53
- nearly every company where I have worked. Sometimes, I turned that code into a module;
54
- other times, I wrote it from scratch. Clearly, that is inefficient.
55
-
56
- I decided to finally turn that code into a proper Python package with unit testing,
57
- automatic documentation, and quality checks; the idea being that, henceforth, depending
58
- on my employer's open source policy, I may simply import this package instead of
59
- reproducing the code herein for the Nth time.
41
+ ### Installation
60
42
 
61
- If any of that sounds relatable, then `boto3-refresh-session` should help you!
43
+ ```bash
44
+ pip install boto3-refresh-session
45
+ ```
62
46
 
63
47
  ### Usage
64
48
 
65
- Simply pass the basic parameters and initialize the `RefreshableSession` object;
66
- that's it! You're good to go!
67
-
68
- `RefreshableSession` will refresh
69
- temporary credentials for you in the background. In the following example,
70
- continue using the `s3_client` object without worry of using `try` and
71
- `except` blocks!
72
-
73
- To use this package, your machine must be configured with AWS
74
- credentials. To learn more about how `boto3` searches for credentials on a
75
- machine, check [this documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html).
76
-
77
49
  ```python
78
50
  import boto3_refresh_session as brs
79
51
 
52
+ # you can pass all of the params associated with boto3.session.Session
53
+ profile_name = '<your-profile-name>'
54
+ region_name = 'us-east-1'
55
+ ...
56
+
57
+ # as well as all of the params associated with STS.Client.assume_role
80
58
  assume_role_kwargs = {
81
59
  'RoleArn': '<your-role-arn>',
82
60
  'RoleSessionName': '<your-role-session-name>',
83
61
  'DurationSeconds': '<your-selection>',
84
62
  ...
85
63
  }
64
+
65
+ # as well as all of the params associated with STS.Client, except for 'service_name'
66
+ sts_client_kwargs = {
67
+ 'region_name': region_name,
68
+ ...
69
+ }
70
+
71
+ # basic initialization of boto3.session.Session
86
72
  session = brs.RefreshableSession(
87
- assume_role_kwargs=assume_role_kwargs
73
+ assume_role_kwargs=assume_role_kwargs, # required
74
+ sts_client_kwargs=sts_client_kwargs,
75
+ region_name=region_name,
76
+ profile_name=profile_name,
77
+ ...
88
78
  )
79
+
80
+ # now you can create clients, resources, etc. without worrying about expired temporary
81
+ # security credentials
89
82
  s3 = session.client(service_name='s3')
90
83
  buckets = s3.list_buckets()
91
84
  ```
92
85
 
93
- ### Installation
86
+ ### Raison d'être
94
87
 
95
- ```bash
96
- pip install boto3-refresh-session
97
- ```
88
+ It is common for data pipelines and workflows that interact with the AWS API via
89
+ `boto3` to run for a long time and, accordingly, for temporary credentials to
90
+ expire.
91
+
92
+ Usually, engineers deal with that problem one of two ways:
98
93
 
99
- ### Authors
94
+ - `try except` blocks that catch `ClientError` exceptions
95
+ - A similar approach as that used in this project -- that is, using methods available
96
+ within `botocore` for refreshing temporary credentials automatically.
97
+
98
+ Speaking personally, variations of the code found herein exists in code bases at
99
+ nearly every company where I have worked. Sometimes, I turned that code into a module;
100
+ other times, I wrote it from scratch. Clearly, that is inefficient.
100
101
 
101
- - [Michael Letts](https://michaelthomasletts.github.io/)
102
+ I decided to finally turn that code into a proper Python package with unit testing,
103
+ automatic documentation, and quality checks; the idea being that, henceforth, depending
104
+ on my employer's open source policy, I may simply import this package instead of
105
+ reproducing the code herein for the Nth time.
102
106
 
107
+ If any of that sounds relatable, then `boto3-refresh-session` should help you.
@@ -0,0 +1,6 @@
1
+ boto3_refresh_session/__init__.py,sha256=vTbdcWjz7-Ome4q7lh7OC0lNtQh04Y5zJK_g8O1s2Wk,157
2
+ boto3_refresh_session/session.py,sha256=p4adQ4G2rVm8PPT8xOVV8oMPLS-2h6pSgZNeFd1E1uI,5775
3
+ boto3_refresh_session-1.0.6.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
4
+ boto3_refresh_session-1.0.6.dist-info/METADATA,sha256=1eE7DHx9w0AS8Pnks6Q_KxoN50nJtKbxn-craK8uyEQ,4450
5
+ boto3_refresh_session-1.0.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
+ boto3_refresh_session-1.0.6.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- boto3_refresh_session/__init__.py,sha256=OFlvwxa3cKjI5tUhRqSBsKy8Svx65CFxQNpg6xlsiqw,149
2
- boto3_refresh_session/session.py,sha256=rQHJDvOAz0glymYXQBfSt1keFvQAM_G8AQXgMDLZq2U,5349
3
- boto3_refresh_session-1.0.4.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
4
- boto3_refresh_session-1.0.4.dist-info/METADATA,sha256=16Y5Ua36XnllNclnwHXqcFmGMT8_hTeL8EVIUuv1ln8,4395
5
- boto3_refresh_session-1.0.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
- boto3_refresh_session-1.0.4.dist-info/RECORD,,