feat(parameters): DynamoDBProvider support - #1202
Merged
Merged
Conversation
4 tasks
dreamorosi
force-pushed
the
1174-feature-request-implement-dynamodbprovider
branch
from
December 29, 2022 16:47
8736473 to
0aa6b56
Compare
dreamorosi
force-pushed
the
1174-feature-request-implement-dynamodbprovider
branch
3 times, most recently
from
January 5, 2023 20:12
2446278 to
a777f0b
Compare
dreamorosi
force-pushed
the
1174-feature-request-implement-dynamodbprovider
branch
from
January 6, 2023 17:07
a777f0b to
9e1c6c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
This PR implements the
DynamoDBProviderclass which will allow the future Parameters utility to support retrieving parameters from DynamoDB.The
DynamoDBProvidersupports the following retrieval modes:getthis class method allows customers to retrieve a single parameter by name and allows to specify transform, max age.The provider comes with defaults thanks to which the user only has to specify the table name and the the name of the parameter to retrieve:
The table named
some-tableexpects an item that looks like this:{ "id": "foo", "value": "bar" }However, if users have items with other type of shapes, like for instance:
{ "key": "foo", "val": "bar" }they can instantiate the provider like so:
In both cases, they can retrieve the parameter using the
getmethod:getMultiplethis class method allows customers to retrieve multiple parameters by path and allows to specify a shared config object that changes the behavior around transform, max age.Similarly to what described above, the default come also for path-based retrieval:
The table named
some-tableexpects an item that looks like this:{ "id": "foo", "sk": "a", "value": "value-param-a" } { "id": "foo", "sk": "b", "value": "value-param-b" }Which will result, when used, in this:
Just like before, if users have items with a different shape, say this:
{ "key": "foo", "sort": "a", "val": "value-param-a" } { "key": "foo", "sort": "b", "val": "value-param-b" }They can customize the provider's behavior by instantiating it with different attribute names:
Both
getandgetMultiplealso allow an optionaloptionsargument that allow to customize the provider's behavior around caching and transform/errors.The
optionsobject also accepts asdkOptionsobject, which allows the user to pass additional inputs to the SDK client API call (i.e. specifyConsistentRead). There are however some SDK options that cannot be passed as they are managed by the provider, these are:TableNameProjectionExpressionKey(applies only toget)KeyConditionExpression(applies only togetMultiple)ExpressionAttributeValues(applies only togetMultiple)How to verify this change
See the newly added unit test cases & optionally compare also the API surface with the implementation found in Powertools for Python.
Related issues, RFCs
Issue number: #1174
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.