Skip to content

Commit

Permalink
feat: Add tags to dynamodb config (#4100)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
nanohanno and hkuepers committed Apr 17, 2024
1 parent a683939 commit b08b8d5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion sdk/python/feast/infra/online_stores/dynamodb.py
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit b08b8d5

Please sign in to comment.