Tag Instances hosting healthcare data (HDS) using the CLI or API
When hosting healthcare data using Scaleway Instances, you are legally obligated to add the HDS tag to every Instance within your HDS scope. This page explains how to add this tag using the Scaleway CLI, the Instances API, and Terraform.
To tag Instances using the Scaleway console, see Tag Instances hosting healthcare data.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged in to the console (External link)
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- Signed an HDS contract with Scaleway for the guarantees outlined in the shared responsibility model to apply
- Installed and configured the Scaleway CLI to use the CLI procedures
- Created an API key to use the API procedures
- Installed jq (External link) to run the scripts on this page
Tag Instances using the Scaleway CLI
Tag a new Instance
Run the following command to create an Instance with the HDS tag. Replace <INSTANCE_TYPE> with an HDS-eligible Instance type, and <INSTANCE_NAME> with the name of your Instance.
scw instance server create \
zone=fr-par-1 \
image=ubuntu_noble \
type=<INSTANCE_TYPE> \
name=<INSTANCE_NAME> \
tags.0=HDSTag an existing Instance
-
Run the following command to list the current tags of the Instance. Replace
<instance-id>with the ID of your Instance.scw instance server get <instance-id> zone=fr-par-1 -o json | jq -r '.tags[]' -
Run the following command to apply the complete list of tags:
HDSand each existing tag.scw instance server update <INSTANCE_ID> \ zone=fr-par-1 \ tags.0=HDS \ tags.1=<EXISTING_TAG_1> \ tags.2=<EXISTING_TAG_2>
Tag all Instances of a zone
The following script adds the HDS tag to every Instance of the selected zone that does not have it yet, and keeps the existing tags.
ZONE=fr-par-1
# List the IDs of the Instances without the HDS tag
for id in $(scw instance server list zone=$ZONE -o json \
| jq -r '.[] | select((.tags | index("HDS")) | not) | .id'); do
# Read the existing tags, one per line
existing_tags=$(scw instance server get "$id" zone=$ZONE -o json | jq -r '.tags[]')
# Build the complete tag list: HDS first, then the existing tags
args=("tags.0=HDS")
if [[ -n "$existing_tags" ]]; then
i=1
while read -r tag; do
args+=("tags.$i=$tag")
i=$((i + 1))
done <<< "$existing_tags"
fi
scw instance server update "$id" "${args[@]}" zone=$ZONE
doneCheck tagged Instances
Run the following command to list the Instances with the HDS tag in a zone:
scw instance server list zone=fr-par-1 -o json | jq -r '.[] | select(.tags | index("HDS")) | .id'Run the following command to display the details of an Instance, including its tags field:
scw instance server get <INSTANCE_ID> zone=fr-par-1Tag Instances using the Instances API
-
Run the following commands to export the variables used in the API requests. Replace
<your-secret-key>with the secret key of your API key, and<instance-id>with the ID of your Instance.export SCW_SECRET_KEY="<YOUR_SECRET_KEY>" export SCW_ZONE="fr-par-1" export SERVER_ID="<INSTANCE_ID>" -
Run the following command to retrieve the current tags of the Instance.
curl -s \
-H "X-Auth-Token: $SCW_SECRET_KEY"
"https://api.scaleway.com/instance/v2alpha1/zones/$SCW_ZONE/servers/$SERVER_ID (External link)"
| jq '.tags'
2. Run the following command to apply the complete list of tags: `HDS` and each existing tag.
```bash
curl -X PATCH \
-H "X-Auth-Token: $SCW_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"tags": ["HDS", "<existing-tag-1>", "<existing-tag-2>"]}' \
"https://api.scaleway.com/instance/v2alpha1/zones/$SCW_ZONE/servers/$SERVER_ID"To tag a new Instance, add "tags": ["HDS"] to the body of the POST /instance/v2alpha1/zones/{zone}/servers request.
See the Instances API documentation (External link) for more information.
Tag Instances using Terraform
Add the HDS tag to the tags argument of the scaleway_instance_server resource:
resource "scaleway_instance_server" "hds_server" {
zone = "fr-par-1"
type = "<instance-type>"
image = "ubuntu_noble"
tags = ["HDS"]
}