Skip to content

Commit b08b8d5

Browse files
nanohannohkuepers
andauthored
feat: Add tags to dynamodb config (#4100)
* Add tags to dynamodb config Signed-off-by: hkuepers <hanno.kuepers@ratepay.com> * Only add tags to dynamodb when configured Signed-off-by: hkuepers <hanno.kuepers@ratepay.com> --------- Signed-off-by: hkuepers <hanno.kuepers@ratepay.com> Co-authored-by: hkuepers <hanno.kuepers@ratepay.com>
1 parent a683939 commit b08b8d5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

sdk/python/feast/infra/online_stores/dynamodb.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class DynamoDBOnlineStoreConfig(FeastConfigBaseModel):
6565
consistent_reads: StrictBool = False
6666
"""Whether to read from Dynamodb by forcing consistent reads"""
6767

68+
tags: Union[Dict[str, str], None] = None
69+
"""AWS resource tags added to each table"""
70+
6871

6972
class DynamoDBOnlineStore(OnlineStore):
7073
"""
@@ -104,7 +107,18 @@ def update(
104107
dynamodb_resource = self._get_dynamodb_resource(
105108
online_config.region, online_config.endpoint_url
106109
)
107-
110+
# Add Tags attribute to creation request only if configured to prevent
111+
# TagResource permission issues, even with an empty Tags array.
112+
kwargs = (
113+
{
114+
"Tags": [
115+
{"Key": key, "Value": value}
116+
for key, value in online_config.tags.items()
117+
]
118+
}
119+
if online_config.tags
120+
else {}
121+
)
108122
for table_instance in tables_to_keep:
109123
try:
110124
dynamodb_resource.create_table(
@@ -114,6 +128,7 @@ def update(
114128
{"AttributeName": "entity_id", "AttributeType": "S"}
115129
],
116130
BillingMode="PAY_PER_REQUEST",
131+
**kwargs,
117132
)
118133
except ClientError as ce:
119134
# If the table creation fails with ResourceInUseException,

0 commit comments

Comments
 (0)