You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-30Lines changed: 57 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,47 +11,56 @@ The AWS Secrets Manager Python caching client enables in-process caching of secr
11
11
12
12
To use this client you must have:
13
13
14
-
* Python 3.8 or newer. Use of Python versions 3.7 or older are not supported.
15
-
* An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager.
16
-
***To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
14
+
- Python 3.8 or newer. Use of Python versions 3.7 or older are not supported.
15
+
- An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager.
17
16
18
-
***To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
17
+
-**To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
19
18
20
-
* This library makes use of botocore, the low-level core functionality of the boto3 SDK. For more information on boto3 and botocore, please review the [AWS SDK for Python](https://aws.amazon.com/sdk-for-python/) and [Botocore](https://botocore.amazonaws.com/v1/documentation/api/latest/index.html) documentation.
19
+
-**To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
20
+
21
+
- This library makes use of botocore, the low-level core functionality of the boto3 SDK. For more information on boto3 and botocore, please review the [AWS SDK for Python](https://aws.amazon.com/sdk-for-python/) and [Botocore](https://botocore.amazonaws.com/v1/documentation/api/latest/index.html) documentation.
21
22
22
23
### Dependencies
24
+
23
25
This library requires the following standard dependencies:
24
-
* botocore
25
-
* setuptools_scm
26
-
* setuptools
26
+
27
+
- botocore
28
+
- setuptools_scm
29
+
- setuptools
27
30
28
31
For development and testing purposes, this library requires the following additional dependencies:
29
-
* pytest
30
-
* pytest-cov
31
-
* pytest-sugar
32
-
* codecov
33
-
* pylint
34
-
* sphinx
35
-
* flake8
36
-
* tox
32
+
33
+
- pytest
34
+
- pytest-cov
35
+
- pytest-sugar
36
+
- codecov
37
+
- pylint
38
+
- sphinx
39
+
- flake8
40
+
- tox
37
41
38
42
Please review the `requirements.txt` and `dev-requirements.txt` file for specific version requirements.
Assuming that you have Python and virtualenv installed, set up your environment and install the required dependencies like this instead of the `pip install aws_secretsmanager_caching` defined above:
**NOTE:** Please use [Ruff](https://docs.astral.sh/ruff/formatter/) for formatting.
77
+
67
78
#### Running Tests
79
+
68
80
You can run tests in all supported Python versions using tox. By default, it will run all of the unit and integration tests, but you can also specify your own arguments to past to `pytest`.
$ tox -- test/unit/test_decorators.py # runs specific test file
72
85
$ tox -e py37 -- test/integ/ # runs specific test directory
73
86
```
74
87
75
88
#### Documentation
89
+
76
90
You can locally-generate the Sphinx-based documentation via:
91
+
77
92
```bash
78
93
$ tox -e docs
79
94
```
95
+
80
96
Which will subsequently be viewable at `file://${CLONE_DIR}/.tox/docs_out/index.html`
81
97
82
98
### Usage
99
+
83
100
Using the client consists of the following steps:
84
-
1. Instantiate the client while optionally passing in a `SecretCacheConfig()` object to the `config` parameter. You can also pass in an existing `botocore.client.BaseClient` client to the client parameter.
101
+
102
+
1. Instantiate the client while optionally passing in a `SecretCacheConfig()` object to the `config` parameter. You can also pass in an existing `botocore.client.BaseClient` client to the client parameter.
You can configure the cache config object with the following parameters:
100
-
*`max_cache_size` - The maximum number of secrets to cache. The default value is `1024`.
101
-
*`exception_retry_delay_base` - The number of seconds to wait after an exception is encountered and before retrying the request. The default value is `1`.
102
-
*`exception_retry_growth_factor` - The growth factor to use for calculating the wait time between retries of failed requests. The default value is `2`.
103
-
*`exception_retry_delay_max` - The maximum amount of time in seconds to wait between failed requests. The default value is `3600`.
104
-
*`default_version_stage` - The default version stage to request. The default value is `'AWSCURRENT'`
105
-
*`secret_refresh_interval` - The number of seconds to wait between refreshing cached secret information. The default value is `3600.0`.
106
-
*`secret_cache_hook` - An implementation of the SecretCacheHook abstract class. The default value is `None`.
120
+
121
+
-`max_cache_size` - The maximum number of secrets to cache. The default value is `1024`.
122
+
-`exception_retry_delay_base` - The number of seconds to wait after an exception is encountered and before retrying the request. The default value is `1`.
123
+
-`exception_retry_growth_factor` - The growth factor to use for calculating the wait time between retries of failed requests. The default value is `2`.
124
+
-`exception_retry_delay_max` - The maximum amount of time in seconds to wait between failed requests. The default value is `3600`.
125
+
-`default_version_stage` - The default version stage to request. The default value is `'AWSCURRENT'`
126
+
-`secret_refresh_interval` - The number of seconds to wait between refreshing cached secret information. The default value is `3600.0`.
127
+
-`secret_cache_hook` - An implementation of the SecretCacheHook abstract class. The default value is `None`.
107
128
108
129
#### Decorators
130
+
109
131
The library also includes several decorator functions to wrap existing function calls with SecretString-based secrets:
110
-
*`@InjectedKeywordedSecretString` - This decorator expects the secret id and cache as the first and second arguments, with subsequent arguments mapping a parameter key from the function that is being wrapped to a key in the secret. The secret being retrieved from the cache must contain a SecretString and that string must be JSON-based.
111
-
*`@InjectSecretString` - This decorator also expects the secret id and cache as the first and second arguments. However, this decorator simply returns the result of the cache lookup directly to the first argument of the wrapped function. The secret does not need to be JSON-based but it must contain a SecretString.
132
+
133
+
-`@InjectedKeywordedSecretString` - This decorator expects the secret id and cache as the first and second arguments, with subsequent arguments mapping a parameter key from the function that is being wrapped to a key in the secret. The secret being retrieved from the cache must contain a SecretString and that string must be JSON-based.
134
+
-`@InjectSecretString` - This decorator also expects the secret id and cache as the first and second arguments. However, this decorator simply returns the result of the cache lookup directly to the first argument of the wrapped function. The secret does not need to be JSON-based but it must contain a SecretString.
135
+
112
136
```python
113
137
from aws_secretsmanager_caching import SecretCache
114
138
from aws_secretsmanager_caching import InjectKeywordedSecretString, InjectSecretString
Please use these community resources for getting help:
131
-
* Ask a question on [Stack Overflow](https://stackoverflow.com/) and tag it with [aws-secrets-manager](https://stackoverflow.com/questions/tagged/aws-secrets-manager).
132
-
* Open a support ticket with [AWS Support](https://console.aws.amazon.com/support/home#/)
133
-
* If it turns out that you may have found a bug, or have a feature request, please [open an issue](https://github.com/aws/aws-secretsmanager-caching-python/issues/new).
156
+
157
+
- Ask a question on [Stack Overflow](https://stackoverflow.com/) and tag it with [aws-secrets-manager](https://stackoverflow.com/questions/tagged/aws-secrets-manager).
158
+
- Open a support ticket with [AWS Support](https://console.aws.amazon.com/support/home#/)
159
+
- If it turns out that you may have found a bug, or have a feature request, please [open an issue](https://github.com/aws/aws-secretsmanager-caching-python/issues/new).
160
+
134
161
## License
135
162
136
-
This library is licensed under the Apache 2.0 License.
163
+
This library is licensed under the Apache 2.0 License.
0 commit comments