将 Amazon 资源标签添加到 Storage Lens 存储统计管理工具控制面板 - Amazon Simple Storage Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

将 Amazon 资源标签添加到 Storage Lens 存储统计管理工具控制面板

以下示例演示如何将 Amazon 资源标签添加到 S3 Storage Lens 存储统计管理工具控制面板。您可以使用 Amazon S3 控制台、Amazon Command Line Interface (Amazon CLI) 和 适用于 Java 的 Amazon SDK 添加资源标签。

将 Amazon 资源标签添加到 Storage Lens 存储统计管理工具控制面板
  1. 登录到 Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/

  2. 在左侧导航窗格中,导航到 Storage Lens 存储统计管理工具

  3. 选择控制面板

  4. 选择您要更新的 Storage Lens 存储统计管理工具控制面板的单选按钮。然后选择 Edit(编辑)。

  5. 常规下,选择添加标签

  6. 添加标签页面上,添加新的键值对。

    注意

    如果添加的新标签与现有标签具有相同的键,则将覆盖之前的标签值。

  7. (可选)要添加多个新标签,请再次选择添加标签以继续添加新条目。最多可以将 50 个 Amazon 资源标签添加到 Storage Lens 存储统计管理工具控制面板。

  8. (可选)如果要移除新添加的条目,请选择要移除的标签旁的移除

  9. 选择保存更改

以下示例命令将标签添加到 S3 Storage Lens 存储统计管理工具控制面板配置。要使用这些示例,请将 user input placeholders 替换为您自己的信息。

aws s3control put-storage-lens-configuration-tagging --account-id=222222222222 --region=us-east-1 --config-id=your-configuration-id --tags=file://./tags.json

以下示例命令在适用于 Java 的 SDK 中将标签添加到 Amazon S3 Storage Lens 存储统计管理工具配置。要使用此示例,请将 user input placeholders 替换为您自己的信息。

例 – 将标签添加到 S3 Storage Lens 存储统计管理工具配置
package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.services.s3control.AWSS3Control; import com.amazonaws.services.s3control.AWSS3ControlClient; import com.amazonaws.services.s3control.model.PutStorageLensConfigurationTaggingRequest; import com.amazonaws.services.s3control.model.StorageLensTag; import java.util.Arrays; import java.util.List; import static com.amazonaws.regions.Regions.US_WEST_2; public class PutDashboardTagging { public static void main(String[] args) { String configurationId = "ConfigurationId"; String sourceAccountId = "111122223333"; try { List<StorageLensTag> tags = Arrays.asList( new StorageLensTag().withKey("key-1").withValue("value-1"), new StorageLensTag().withKey("key-2").withValue("value-2") ); AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2) .build(); s3ControlClient.putStorageLensConfigurationTagging(new PutStorageLensConfigurationTaggingRequest() .withAccountId(sourceAccountId) .withConfigId(configurationId) .withTags(tags) ); } 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(); } } }