Closed
Description
Expected Behaviour
Reusing a DynamoDB table that uses a composite primary key
example should be valid python syntax
Current Behaviour
Current code example has syntax errors
Code snippet
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer, idempotent
persistence_layer = DynamoDBPersistenceLayer(
table_name="IdempotencyTable",
sort_key_attr='sort_key')
@idempotent(persistence_store=persistence_layer)
def handler(event, context):
return {"message": "success": "id": event['body']['id]}
Possible Solution
Fix code example like in PR #1119 , example deployed at https://gyft.github.io/aws-lambda-powertools-python/latest/utilities/idempotency/#using-a-dynamodb-table-with-a-composite-primary-key
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer, idempotent
persistence_layer = DynamoDBPersistenceLayer(
table_name="IdempotencyTable",
sort_key_attr="sort_key",
)
@idempotent(persistence_store=persistence_layer)
def handler(event, context):
return {"message": "success", "id": event["body"]["id"]}
Steps to Reproduce
- Go to https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/idempotency/#using-a-dynamodb-table-with-a-composite-primary-key
- Copy example
Reusing a DynamoDB table that uses a composite primary key
- Try to compile
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
N/A