Tagging HealthLake data stores
You can assign metadata to HealthLake data stores in the form of tags. Each tag is a label
consisting of a user-defined key and value. Tags help you manage, identify, organize, search
for, and filter data stores.
Do not store protected health information (PHI), personally identifiable information (PII), or other confidential or sensitive information in tags.
Tags are not intended to be used for private or sensitive data.
The following topics describe how to use HealthLake tagging operations using the AWS Management Console,
AWS CLI, and AWS SDKs. For more information, see Tagging your AWS resources in the
AWS General Reference Guide.
Tagging a HealthLake data store
Use TagResource to tag a HealthLake data store. The following menus provide a
procedure for the AWS Management Console and code examples for the AWS CLI and AWS SDKs. For more
information, see TagResource in the AWS HealthLake API Reference.
To tag a HealthLake data store
Choose a menu based on your access preference to AWS HealthLake.
- CLI
-
- AWS CLI
-
To add a tag to data store
The following tag-resource example shows how to add a tag to a data store.
aws healthlake tag-resource \
--resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe" \
--tags '[{"Key": "key1", "Value": "value1"}]'
This command produces no output.
- Python
-
- SDK for Python (Boto3)
-
@classmethod
def from_client(cls) -> "HealthLakeWrapper":
"""
Creates a HealthLakeWrapper instance with a default AWS HealthLake client.
:return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
"""
health_lake_client = boto3.client("healthlake")
return cls(health_lake_client)
def tag_resource(self, resource_arn: str, tags: list[dict[str, str]]) -> None:
"""
Tags a HealthLake resource.
:param resource_arn: The resource ARN.
:param tags: The tags to add to the resource.
"""
try:
self.health_lake_client.tag_resource(ResourceARN=resource_arn, Tags=tags)
except ClientError as err:
logger.exception(
"Couldn't tag resource %s. Here's why %s",
resource_arn,
err.response["Error"]["Message"],
)
raise
- SAP ABAP
-
- SDK for SAP ABAP
-
TRY.
" iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
lo_hll->tagresource(
iv_resourcearn = iv_resource_arn
it_tags = it_tags
).
MESSAGE 'Resource tagged successfully.' TYPE 'I'.
CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_validation_ex.
CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_notfound_ex.
ENDTRY.
Can't find what you need? Request a code example using the Provide
feedback link on the right sidebar of this page.
-
Sign in to the Data stores page on the HealthLake Console.
-
Choose a data store.
The Data store details page opens.
-
Under the Tags section, choose Manage
tags.
The Manage tags page opens.
-
Choose Add new tag.
-
Enter a Key and Value (optional).
-
Choose Save.
Use ListTagsForResource to list tags for a HealthLake data store. The following
menus provide a procedure for the AWS Management Console and code examples for the AWS CLI and AWS SDKs.
For more information, see ListTagsForResource in the AWS HealthLake API
Reference.
To list tags for a HealthLake data store
Choose a menu based on your access preference to AWS HealthLake.
- CLI
-
- AWS CLI
-
To list tags for a data store
The following list-tags-for-resource example lists the tags associated with the specified data store.:
aws healthlake list-tags-for-resource \
--resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/0725c83f4307f263e16fd56b6d8ebdbe"
Output:
{
"tags": {
"key": "value",
"key1": "value1"
}
}
- Python
-
- SDK for Python (Boto3)
-
@classmethod
def from_client(cls) -> "HealthLakeWrapper":
"""
Creates a HealthLakeWrapper instance with a default AWS HealthLake client.
:return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
"""
health_lake_client = boto3.client("healthlake")
return cls(health_lake_client)
def list_tags_for_resource(self, resource_arn: str) -> dict[str, str]:
"""
Lists the tags for a HealthLake resource.
:param resource_arn: The resource ARN.
:return: The tags for the resource.
"""
try:
response = self.health_lake_client.list_tags_for_resource(
ResourceARN=resource_arn
)
return response["Tags"]
except ClientError as err:
logger.exception(
"Couldn't list tags for resource %s. Here's why %s",
resource_arn,
err.response["Error"]["Message"],
)
raise
- SAP ABAP
-
- SDK for SAP ABAP
-
TRY.
" iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
DATA(lo_result) = lo_hll->listtagsforresource(
iv_resourcearn = iv_resource_arn
).
ot_tags = lo_result->get_tags( ).
DATA(lv_tag_count) = lines( ot_tags ).
MESSAGE |Found { lv_tag_count } tag(s).| TYPE 'I'.
CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_validation_ex.
CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_notfound_ex.
ENDTRY.
Can't find what you need? Request a code example using the Provide
feedback link on the right sidebar of this page.
-
Sign in to the Data stores page on the HealthLake Console.
-
Choose a data store.
The Data store details page opens. Under the
Tags section, all data store tags are listed.
Untagging a HealthLake data
store
Use UntagResource to remove a tag from a HealthLake data store. The following
menus provide a procedure for the AWS Management Console and code examples for the AWS CLI and AWS SDKs.
For more information, see UntagResource in the AWS HealthLake API
Reference.
To untag a HealthLake data store
Choose a menu based on your access preference to AWS HealthLake.
- CLI
-
- AWS CLI
-
To remove tags from a data store.
The following untag-resource example shows how to remove tags from a data store.
aws healthlake untag-resource \
--resource-arn "arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/b91723d65c6fdeb1d26543a49d2ed1fa" \
--tag-keys '["key1"]'
This command produces no output.
- Python
-
- SDK for Python (Boto3)
-
@classmethod
def from_client(cls) -> "HealthLakeWrapper":
"""
Creates a HealthLakeWrapper instance with a default AWS HealthLake client.
:return: An instance of HealthLakeWrapper initialized with the default HealthLake client.
"""
health_lake_client = boto3.client("healthlake")
return cls(health_lake_client)
def untag_resource(self, resource_arn: str, tag_keys: list[str]) -> None:
"""
Untags a HealthLake resource.
:param resource_arn: The resource ARN.
:param tag_keys: The tag keys to remove from the resource.
"""
try:
self.health_lake_client.untag_resource(
ResourceARN=resource_arn, TagKeys=tag_keys
)
except ClientError as err:
logger.exception(
"Couldn't untag resource %s. Here's why %s",
resource_arn,
err.response["Error"]["Message"],
)
raise
- SAP ABAP
-
- SDK for SAP ABAP
-
TRY.
" iv_resource_arn = 'arn:aws:healthlake:us-east-1:123456789012:datastore/fhir/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
lo_hll->untagresource(
iv_resourcearn = iv_resource_arn
it_tagkeys = it_tag_keys
).
MESSAGE 'Resource untagged successfully.' TYPE 'I'.
CATCH /aws1/cx_hllvalidationex INTO DATA(lo_validation_ex).
DATA(lv_error) = |Validation error: { lo_validation_ex->av_err_code }-{ lo_validation_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_validation_ex.
CATCH /aws1/cx_hllresourcenotfoundex INTO DATA(lo_notfound_ex).
lv_error = |Resource not found: { lo_notfound_ex->av_err_code }-{ lo_notfound_ex->av_err_msg }|.
MESSAGE lv_error TYPE 'I'.
RAISE EXCEPTION lo_notfound_ex.
ENDTRY.
Can't find what you need? Request a code example using the Provide
feedback link on the right sidebar of this page.
-
Sign in to the Data stores page on the HealthLake Console.
-
Choose a data store.
The Data store details page opens.
-
Under the Tags section, choose Manage tags.
The Manage tags page opens.
-
Choose Remove next to the tag you want to remove.
-
Choose Save.