DynamoDB
Amazon DynamoDB parameter retrieval and caching utility
CLASS | DESCRIPTION |
---|---|
DynamoDBProvider |
Amazon DynamoDB Parameter Provider |
DynamoDBProvider ¶
DynamoDBProvider(
table_name: str,
key_attr: str = "id",
sort_attr: str = "sk",
value_attr: str = "value",
endpoint_url: str | None = None,
config: Config | None = None,
boto_config: Config | None = None,
boto3_session: boto3.session.Session | None = None,
boto3_client: DynamoDBServiceResource | None = None,
)
Bases: BaseProvider
Amazon DynamoDB Parameter Provider
PARAMETER | DESCRIPTION | ||
---|---|---|---|
table_name
|
Name of the DynamoDB table that stores parameters
TYPE:
|
||
key_attr
|
Hash key for the DynamoDB table (default to 'id')
TYPE:
|
||
sort_attr
|
Name of the DynamoDB table sort key (defaults to 'sk'), used only for get_multiple
TYPE:
|
||
value_attr
|
Attribute that contains the values in the DynamoDB table (defaults to 'value')
TYPE:
|
||
endpoint_url
|
Complete url to reference local DynamoDB instance, e.g. http://localhost:8080
TYPE:
|
||
config
|
Botocore configuration to pass during client initialization
TYPE:
|
||
boto3_session
|
TYPE:
|
||
boto3_client
|
TYPE:
|
Example
Retrieves a parameter value from a DynamoDB table
In this example, the DynamoDB table uses id
as hash key and stores the value in the value
attribute. The parameter item looks like this:
1 2 3 4 5 6 7 8 9 |
|
Retrieves a parameter value from a DynamoDB table that has custom attribute names
1 2 3 4 5 6 7 8 9 10 11 |
|
Retrieves a parameter value from a DynamoDB table in another AWS region
1 2 3 4 5 6 7 8 9 10 |
|
Retrieves a parameter value from a DynamoDB table passing options to the SDK call
1 2 3 4 5 6 7 |
|
Retrieves multiple values from a DynamoDB table
In this case, the provider will use a sort key to retrieve multiple values using a query under
the hood. This expects that the sort key is named sk
. The DynamoDB table contains three items
looking like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Retrieves multiple values from a DynamoDB table that has custom attribute names
In this case, the provider will use a sort key to retrieve multiple values using a query under the hood.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Retrieves multiple values from a DynamoDB table passing options to the SDK calls
1 2 3 4 5 6 7 8 9 10 |
|
Source code in aws_lambda_powertools/utilities/parameters/dynamodb.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|