diff --git a/aws_lambda_powertools/utilities/parameters/base.py b/aws_lambda_powertools/utilities/parameters/base.py index 2317ebc82d9..0b7bab5cb95 100644 --- a/aws_lambda_powertools/utilities/parameters/base.py +++ b/aws_lambda_powertools/utilities/parameters/base.py @@ -39,7 +39,7 @@ from mypy_boto3_ssm import SSMClient -DEFAULT_MAX_AGE_SECS = "5" +DEFAULT_MAX_AGE_SECS = "300" # These providers will be dynamically initialized on first use of the helper functions DEFAULT_PROVIDERS: Dict[str, Any] = {} diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index 92c0c53ce86..f9cf00324a3 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -9,7 +9,7 @@ The parameters utility provides high-level functions to retrieve one or multiple ## Key features * Retrieve one or multiple parameters from the underlying provider -* Cache parameter values for a given amount of time (defaults to 5 seconds) +* Cache parameter values for a given amount of time (defaults to 5 minutes) * Transform parameter values from JSON or base 64 encoded strings * Bring Your Own Parameter Store Provider @@ -143,7 +143,7 @@ The following environment variables are available to configure the parameter uti | Setting | Description | Environment variable | Default | |-----------------------|--------------------------------------------------------------------------------|-------------------------------------|---------| -| **Max Age** | Adjusts for how long values are kept in cache (in seconds). | `POWERTOOLS_PARAMETERS_MAX_AGE` | `5` | +| **Max Age** | Adjusts for how long values are kept in cache (in seconds). | `POWERTOOLS_PARAMETERS_MAX_AGE` | `300` | | **Debug Sample Rate** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store. | `POWERTOOLS_PARAMETERS_SSM_DECRYPT` | `false` | You can also use [`POWERTOOLS_PARAMETERS_MAX_AGE`](#adjusting-cache-ttl) through the `max_age` parameter and [`POWERTOOLS_PARAMETERS_SSM_DECRYPT`](#ssmprovider) through the `decrypt` parameter to override the environment variable values. @@ -155,7 +155,7 @@ You can also use [`POWERTOOLS_PARAMETERS_MAX_AGE`](#adjusting-cache-ttl) through ???+ tip `max_age` parameter is also available in underlying provider functions like `get()`, `get_multiple()`, etc. -By default, we cache parameters retrieved in-memory for 5 seconds. If you want to change this default value and set the same TTL for all parameters, you can set the `POWERTOOLS_PARAMETERS_MAX_AGE` environment variable. **You can still set `max_age` for individual parameters**. +By default, we cache parameters retrieved in-memory for 300 seconds (5 minutes). If you want to change this default value and set the same TTL for all parameters, you can set the `POWERTOOLS_PARAMETERS_MAX_AGE` environment variable. **You can still set `max_age` for individual parameters**. You can adjust how long we should keep values in cache by using the param `max_age`, when using `get_parameter()`, `get_parameters()` and `get_secret()` methods across all providers. @@ -446,8 +446,8 @@ Here is the mapping between this utility's functions and methods and the underly | SSM Parameter Store | `SSMProvider.get_multiple` | `ssm` | [get_parameters_by_path](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ssm.html#SSM.Client.get_parameters_by_path){target="_blank"} | | Secrets Manager | `get_secret` | `secretsmanager` | [get_secret_value](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html#SecretsManager.Client.get_secret_value){target="_blank"} | | Secrets Manager | `SecretsProvider.get` | `secretsmanager` | [get_secret_value](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html#SecretsManager.Client.get_secret_value){target="_blank"} | -| DynamoDB | `DynamoDBProvider.get` | `dynamodb` | ([Table resource](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#table){target="_blank"}) | [get_item](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.get_item) | -| DynamoDB | `DynamoDBProvider.get_multiple` | `dynamodb` | ([Table resource](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#table){target="_blank"}) | [query](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.query) | +| DynamoDB | `DynamoDBProvider.get` | `dynamodb` | ([Table resource](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#table){target="_blank"}) | +| DynamoDB | `DynamoDBProvider.get_multiple` | `dynamodb` | ([Table resource](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#table){target="_blank"}) | | App Config | `get_app_config` | `appconfigdata` | [start_configuration_session](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appconfigdata.html#AppConfigData.Client.start_configuration_session){target="_blank"} and [get_latest_configuration](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appconfigdata.html#AppConfigData.Client.get_latest_configuration){target="_blank"} | ### Bring your own boto client diff --git a/tests/unit/data_classes/test_sqs_event.py b/tests/unit/data_classes/test_sqs_event.py index b1664924c5e..0cd18bd8a90 100644 --- a/tests/unit/data_classes/test_sqs_event.py +++ b/tests/unit/data_classes/test_sqs_event.py @@ -65,10 +65,7 @@ def test_sqs_dlq_trigger_event(): assert attributes.sequence_number is None assert attributes.message_group_id is None assert attributes.message_deduplication_id is None - assert ( - attributes.dead_letter_queue_source_arn - == raw_attributes["DeadLetterQueueSourceArn"] - ) + assert attributes.dead_letter_queue_source_arn == raw_attributes["DeadLetterQueueSourceArn"] def test_decode_nested_s3_event(): diff --git a/tests/unit/parser/test_sqs.py b/tests/unit/parser/test_sqs.py index acae8c1093f..d28f1093d15 100644 --- a/tests/unit/parser/test_sqs.py +++ b/tests/unit/parser/test_sqs.py @@ -117,7 +117,4 @@ def test_sqs_dlq_trigger_event(): convert_time = int(round(attributes.SentTimestamp.timestamp() * 1000)) assert convert_time == int(raw_record["attributes"]["SentTimestamp"]) - assert ( - attributes.DeadLetterQueueSourceArn - == raw_record["attributes"]["DeadLetterQueueSourceArn"] - ) + assert attributes.DeadLetterQueueSourceArn == raw_record["attributes"]["DeadLetterQueueSourceArn"]