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
* Configurable update interval: you can ask the library to update your configuration as often as needed, but it will only call the AWS AppConfig API at the configured interval (in seconds).
10
10
* Uses best practices for updates: the API is called with the version of the last received configuration, which results in a lower charge for the API call if no new configuration has been deployed. Automatically generates a client ID if you do not specify one.
11
11
* Flexible: Can automatically fetch the current configuration on initialisation, every time the configuration is read by your code, or on demand. You can override the caching interval if needed.
12
-
* Handles YAML, JSON and plain text configurations, stored in any supported AppConfig store.
12
+
* Handles YAML, JSON and plain text configurations, stored in any supported AppConfig store. Any other content type is returned unprocessed as the Python `bytes` type.
13
13
* Supports AWS Lambda, Amazon EC2 instances and on-premises use.
14
14
15
15
## Installation
16
16
17
17
```bash
18
-
pip install aws-appconfig-helper
18
+
pip install sample-helper-aws-appconfig
19
19
```
20
20
21
21
## Example
@@ -28,7 +28,7 @@ appconfig = AppConfigHelper(
28
28
"MyAppConfigApp",
29
29
"MyAppConfigEnvironment",
30
30
"MyAppConfigProfile",
31
-
30# minimum interval between update checks
31
+
45# minimum interval between update checks
32
32
)
33
33
34
34
app = FastAPI()
@@ -61,7 +61,7 @@ AWS AppConfig needs clients to specify a unique client ID to allow deployment st
61
61
62
62
The configuration from AWS AppConfig is available as the `config` property. Before accessing it, you should call `update_config()`, unless you specified fetch_on_init or fetch_on_read during initialisation. If you want to force a config fetch, even if the number of seconds specified have not yet passed, call `update_config(True)`.
63
63
64
-
`update_config()` returns `True` if a new version of the configuration was received. If no attempt was made to fetch it, or the configuration received was the same as current one, it returns `False`. It will raise `ValueError` if the received configuration data could not be processed (e.g. invalid JSON, unknown type). If needed, the inner exception for JSON or YAML parsing is available as `__context__` on the raised exception.
64
+
`update_config()` returns `True` if a new version of the configuration was received. If no attempt was made to fetch it, or the configuration received was the same as current one, it returns `False`. It will raise `ValueError` if the received configuration data could not be processed (e.g. invalid JSON). If needed, the inner exception for JSON or YAML parsing is available as `__context__` on the raised exception.
65
65
66
66
To read the values in your configuration, access the `config` property. For JSON and YAML configurations, this will contain the structure of your data. For plain text configurations, this will be a simple string.
67
67
@@ -88,17 +88,9 @@ you would see the following when using the library:
88
88
89
89
You can check which version of the configuration was last received by examining the `config_version` property. Note that this value is opaque and depends on the service being used to store the configuration data. For example, if Amazon S3 is being used, then the version will be the version identifier of the object, not an integer.
90
90
91
-
### Creating a Lambda layer
92
-
93
-
To create a Lambda layer containing the library, follow these steps:
94
-
95
-
1. In a temporary directory, `mkdir python`
96
-
1. Install the library in the python directory: `pip install -t python aws-appconfig-helper`
97
-
1. Create a zip file containing the installed library: `zip -r layer.zip python`
98
-
1. Upload the zip file as a Lambda layer (e.g. via the AWS Console)
99
-
100
-
You can now specify the layer in your function configuration to have it included.
91
+
### Use in AWS Lambda
101
92
93
+
AWS AppConfig is best used in Lambda by taking advantage of [Lambda Extensions](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html)
102
94
## Security
103
95
104
96
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
0 commit comments