From b08b8d5ce226cceae5e874a287db300f6fb9d41b Mon Sep 17 00:00:00 2001 From: nanohanno <44575187+nanohanno@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:47:42 +0200 Subject: [PATCH] feat: Add tags to dynamodb config (#4100) * Add tags to dynamodb config Signed-off-by: hkuepers * Only add tags to dynamodb when configured Signed-off-by: hkuepers --------- Signed-off-by: hkuepers Co-authored-by: hkuepers --- .../feast/infra/online_stores/dynamodb.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sdk/python/feast/infra/online_stores/dynamodb.py b/sdk/python/feast/infra/online_stores/dynamodb.py index a049189de7..4a74f9e27f 100644 --- a/sdk/python/feast/infra/online_stores/dynamodb.py +++ b/sdk/python/feast/infra/online_stores/dynamodb.py @@ -65,6 +65,9 @@ class DynamoDBOnlineStoreConfig(FeastConfigBaseModel): consistent_reads: StrictBool = False """Whether to read from Dynamodb by forcing consistent reads""" + tags: Union[Dict[str, str], None] = None + """AWS resource tags added to each table""" + class DynamoDBOnlineStore(OnlineStore): """ @@ -104,7 +107,18 @@ def update( dynamodb_resource = self._get_dynamodb_resource( online_config.region, online_config.endpoint_url ) - + # Add Tags attribute to creation request only if configured to prevent + # TagResource permission issues, even with an empty Tags array. + kwargs = ( + { + "Tags": [ + {"Key": key, "Value": value} + for key, value in online_config.tags.items() + ] + } + if online_config.tags + else {} + ) for table_instance in tables_to_keep: try: dynamodb_resource.create_table( @@ -114,6 +128,7 @@ def update( {"AttributeName": "entity_id", "AttributeType": "S"} ], BillingMode="PAY_PER_REQUEST", + **kwargs, ) except ClientError as ce: # If the table creation fails with ResourceInUseException,