Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
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
33 changes: 24 additions & 9 deletions localstack-core/localstack/services/opensearch/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,24 @@ def _stop_clusters(self):
for domain_name in store.opensearch_domains.keys():
cluster_manager().remove(DomainKey(domain_name, region, account_id).arn)

def _add_tags(self, context: RequestContext, arn: ARN, tag_list: TagList) -> None:
self.get_store(context.account_id, context.region).TAGS.tag_resource(arn, tag_list)

def _remove_tags(self, context: RequestContext, arn: ARN, tag_keys: StringList) -> None:
self.get_store(context.account_id, context.region).TAGS.untag_resource(arn, tag_keys)

def _remove_all_tags(self, context: RequestContext, arn: ARN) -> None:
self.get_store(context.account_id, context.region).TAGS.del_resource(arn)

def _list_tags(self, context: RequestContext, arn: ARN) -> TagList:
# The tagging service returns a dictionary with the given root name
store = self.get_store(context.account_id, context.region)
tags = store.TAGS.list_tags_for_resource(arn=arn, root_name="root")
# Extract the actual list of tags for the typed response
tag_list: TagList = tags["root"]

return tag_list

@handler("CreateDomain", expand=False)
def create_domain(
self, context: RequestContext, request: CreateDomainRequest
Expand Down Expand Up @@ -558,7 +576,8 @@ def create_domain(
)

# set the tags
self.add_tags(context, domain_key.arn, request.get("TagList"))
if tags := request.get("TagList", []):
self._add_tags(context, domain_key.arn, tags)

# get the (updated) status
status = get_domain_status(domain_key)
Expand All @@ -580,6 +599,7 @@ def delete_domain(

status = get_domain_status(domain_key, deleted=True)
_remove_cluster(domain_key)
self._remove_all_tags(context, domain_key.arn)

return DeleteDomainResponse(DomainStatus=status)

Expand Down Expand Up @@ -724,20 +744,15 @@ def describe_domain_config(

def add_tags(self, context: RequestContext, arn: ARN, tag_list: TagList, **kwargs) -> None:
_ensure_domain_exists(arn)
self.get_store(context.account_id, context.region).TAGS.tag_resource(arn, tag_list)
self._add_tags(context, arn, tag_list)

def list_tags(self, context: RequestContext, arn: ARN, **kwargs) -> ListTagsResponse:
_ensure_domain_exists(arn)

# The tagging service returns a dictionary with the given root name
store = self.get_store(context.account_id, context.region)
tags = store.TAGS.list_tags_for_resource(arn=arn, root_name="root")
# Extract the actual list of tags for the typed response
tag_list: TagList = tags["root"]
tag_list = self._list_tags(context, arn)
return ListTagsResponse(TagList=tag_list)

def remove_tags(
self, context: RequestContext, arn: ARN, tag_keys: StringList, **kwargs
) -> None:
_ensure_domain_exists(arn)
self.get_store(context.account_id, context.region).TAGS.untag_resource(arn, tag_keys)
self._remove_tags(context, arn, tag_keys)
Loading