Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add tags to dynamodb config #4100

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion sdk/python/feast/infra/online_stores/dynamodb.py
Original file line number Diff line number Diff line change
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
Loading