Storage Lens グループのタグ値の更新
以下の例は、Amazon S3 コンソール、AWS Command Line Interface (AWS CLI)、および AWS SDK for Java を使用して Storage Lens グループを更新する方法を示しています。
Storage Lens グループの AWS リソースタグを更新するには
AWS マネジメントコンソール にサインインし、Amazon S3 コンソール https://console.aws.amazon.com/s3/
を開きます。 -
ナビゲーションペインで、[Storage Lens グループ]を選択します。
-
[Storage Lens グループ] で、更新する Storage Lens グループを選択します。
-
[AWSリソースタグ] で、更新するタグを選択します。
-
更新するキーと値のペアの同じキーを使用して、新しいタグ値を追加します。チェックマークアイコンを選択してタグの値を更新します。
注記
既存のタグと同じ新しいタグを追加すると、以前のタグ値は上書きされます。
-
(オプション) 新しいタグを追加する場合は、[タグの追加] を選択して新しいエントリを追加します。タグの追加 ページが表示されます。
Storage Lens グループには、最大 50 個の AWS リソースタグを追加できます。新しいタグの追加を完了したら、[変更の保存] を選択します。
-
(オプション) 新規追加されたエントリを削除する場合は、削除するタグの横にある[削除] を選びます。タグの削除を完了したら、[タグの保存] を選択します。
次の AWS CLI コマンド例は、 という名前の Storage Lens グループの 2 つのタグ値を更新します。このコマンドの例を実行するには、marketing-department をユーザー自身の情報に置き換えます。user input
placeholders
aws s3control tag-resource --account-id111122223333\ --resource-arn arn:aws:s3:us-east-1:111122223333:storage-lens-group/marketing-department\ --regionus-east-1--tags Key=k1,Value=v3Key=k2,Value=v4
次の AWS SDK for Java 例では、2 つの Storage Lens グループのタグ値を更新します。この例を実行するには、 をユーザー自身の情報に置き換えます。user input
placeholders
package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3control.S3ControlClient; import software.amazon.awssdk.services.s3control.model.Tag; import software.amazon.awssdk.services.s3control.model.TagResourceRequest; public class UpdateTagsForResource { public static void main(String[] args) { String resourceARN = "Resource_ARN"; String accountId = "111122223333"; try { Tag updatedResourceTag1 = Tag.builder() .key("resource-tag-key-1") .value("resource-tag-updated-value-1") .build(); Tag updatedResourceTag2 = Tag.builder() .key("resource-tag-key-2") .value("resource-tag-updated-value-2") .build(); TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceARN) .tags(updatedResourceTag1,updatedResourceTag2) .accountId(accountId) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); s3ControlClient.tagResource(tagResourceRequest); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it and returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }