

# S3 Access Grants のタグの管理
<a name="access-grants-tagging"></a>

Amazon S3 Access Grants のタグは、Amazon S3 の [オブジェクトタグ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html) と類似の特性を持ちます。各タグはキーバリューのペアです。タグ付けできる S3 Access Grants のリソースは、S3 Access Grants [インスタンス](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-instance.html)、[ロケーション](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-location.html)、[権限](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-grant.html) です。

**注記**  
S3 アクセス権限でのタグ付けは、オブジェクトのタグ付けとは異なる API オペレーションを使用します。S3 Access Grants では、[https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_TagResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_TagResource.html)、[https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UntagResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UntagResource.html)、[https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListTagsForResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListTagsForResource.html) API オペレーションを使用します。リソースは、S3 Access Grants インスタンス、登録済みロケーション、またはアクセス権限です。

[オブジェクトタグ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html) 同様、次の制限が適用されます。
+ 新しい S3 Access Grants リソースにタグを追加したり、既存のリソースにタグを追加したりできます。
+ 単一のリソースに関連付けることができるのは、最大 10 タグまでです。複数のタグを同じリソースに関連付ける場合は、一意のタグキーが必要となります。
+ タグキーには最大 128 個の Unicode 文字、タグ値には最大 256 個の Unicode 文字を使用できます。Amazon S3 オブジェクトタグは、内部的に UTF-16 で表現されます。UTF-16 では、文字は 1 文字または 2 文字分を使用することに注意が必要です。
+ キーバリューでは大文字と小文字が区別されます。

タグの制限については、「**AWS Billing ユーザーガイド」の「[ユーザー定義のタグの制限](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/allocation-tag-restrictions.html)」を参照してください。

AWS Command Line Interface (AWS CLI)、Amazon S3 REST API、または AWS SDK を使用して S3 Access Grants のリソースにタグ付けできます。

## の使用AWS CLI
<a name="access-grants-tagging-cli"></a>

AWS CLI をインストールするには、**「AWS Command Line Interface ユーザーガイド」の「[AWS CLI をインストールする](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)」を参照してください。

S3 Access Grants リソースは、作成時または作成後にタグ付けできます。S3 Access Grants のタグ付けまたはタグの削除方法の説明は、次の例のとおりです。登録済みのロケーションとアクセスグラントに対しても同様のオペレーションを実行できます。

次のコマンド例を使用する際は、`user input placeholders` をユーザー自身の情報に置き換えます。

**Example – タグ付けされた S3 Access Grants インスタンスを作成する**  

```
aws s3control create-access-grants-instance \
 --account-id 111122223333 \
 --profile access-grants-profile \
 --region us-east-2 \
 --tags Key=tagKey1,Value=tagValue1
```
レスポンス:  

```
 {
    "CreatedAt": "2023-10-25T01:09:46.719000+00:00",
    "AccessGrantsInstanceId": "default",
    "AccessGrantsInstanceArn": "arn:aws:s3:us-east-2:111122223333:access-grants/default"
}
```

**Example – 既に作成済みの S3 Access Grants インスタンスにタグ付けする**  

```
aws s3control tag-resource \
--account-id 111122223333 \
--resource-arn "arn:aws:s3:us-east-2:111122223333:access-grants/default" \
--profile access-grants-profile \
--region us-east-2 \
--tags Key=tagKey2,Value=tagValue2
```

**Example – S3 Access Grants インスタンスのタグを一覧表示する**  

```
aws s3control list-tags-for-resource \
--account-id 111122223333 \
--resource-arn "arn:aws:s3:us-east-2:111122223333:access-grants/default" \
--profile access-grants-profile \
--region us-east-2
```
レスポンス:  

```
{
    "Tags": [
        {
            "Key": "tagKey1",
            "Value": "tagValue1"
        },
        {
            "Key": "tagKey2",
            "Value": "tagValue2"
        }
    ]
}
```

**Example – S3 Access Grants インスタンスのタグ付けを解除する**  

```
aws s3control untag-resource \
 --account-id 111122223333 \
 --resource-arn "arn:aws:s3:us-east-2:111122223333:access-grants/default" \
 --profile access-grants-profile \
 --region us-east-2 \
 --tag-keys "tagKey2"
```

## REST API の使用
<a name="access-grants-tagging-rest-api"></a>

Amazon S3 API を使用して、S3 Access Grants インスタンス、登録済みのロケーション、またはアクセス権限のタグを付けたり、タグを解除したり、タグを一覧表示したりできます。REST API での S3 Access Grants タグ管理のサポートの詳細については、「**Amazon Simple Storage Service API リファレンス」の次のセクションを参照してください。
+  [https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_TagResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_TagResource.html) 
+  [https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UntagResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UntagResource.html) 
+  [https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListTagsForResource.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListTagsForResource.html)