feat(parameters): DynamoDBProvider support #1202
Merged
+7,081
−7,786
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
DynamoDBProvider
class which will allow the future Parameters utility to support retrieving parameters from DynamoDB.The
DynamoDBProvider
supports the following retrieval modes:get
this 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-table
expects an item that looks like this:However, if users have items with other type of shapes, like for instance:
they can instantiate the provider like so:
In both cases, they can retrieve the parameter using the
get
method:getMultiple
this 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-table
expects an item that looks like this:Which will result, when used, in this:
Just like before, if users have items with a different shape, say this:
They can customize the provider's behavior by instantiating it with different attribute names:
Both
get
andgetMultiple
also allow an optionaloptions
argument that allow to customize the provider's behavior around caching and transform/errors.The
options
object also accepts asdkOptions
object, 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:TableName
ProjectionExpression
Key
(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.