使用资源管理器示例 Amazon CLI - Amazon Command Line Interface
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用资源管理器示例 Amazon CLI

以下代码示例向您展示了如何使用 with Resource Explorer 来执行操作和实现常见场景。 Amazon Command Line Interface

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景和跨服务示例的上下文查看操作。

场景是展示如何通过在同一服务中调用多个函数来完成特定任务任务的代码示例。

每个示例都包含一个指向的链接 GitHub,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示如何使用 associate-default-view

Amazon CLI

将资源浏览器视图设置为其 Amazon 区域的默认视图

以下associate-default-view示例将由其 ARN 指定的视图设置为调用该操作的 Amazon 区域的默认视图。

aws resource-explorer-2 associate-default-view \ --view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-Main-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111

输出:

{ "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-Main-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" }

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的在 Amazon 区域中设置默认视图

以下代码示例演示如何使用 batch-get-view

Amazon CLI

检索有关多个资源浏览器视图的详细信息

以下batch-get-view示例显示了由其 ARN 指定的两个视图的详细信息。使用空格分隔--view-arn 参数中的多个 ARN。

aws resource-explorer-2 batch-get-view \ --view-arns arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222, \ arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-Main-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111

输出:

{ "Views": [ { "Filters": { "FilterString": "service:ec2" }, "IncludedProperties": [ { "Name": "tags" } ], "LastUpdatedAt": "2022-07-13T21:33:45.249000+00:00", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222" }, { "Filters": { "FilterString": "" }, "IncludedProperties": [ { "Name": "tags" } ], "LastUpdatedAt": "2022-07-13T20:34:11.314000+00:00", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-Main-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" } ] "Errors": [] }

有关视图的更多信息,请参阅《资源浏览器用户指南》中的关于Amazon 资源浏览器图。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考BatchGetView中的。

以下代码示例演示如何使用 create-index

Amazon CLI

通过创建索引在 Amazon 区域中打开资源浏览器

以下create-index示例在调用该操作的 Amazon 区域中创建本地索引。 Amazon 如果您未指定值, Amazon CLI 会自动生成一个随机client-token参数值,并将其包含在对的调用中。

aws resource-explorer-2 create-index \ --region us-east-1

输出:

{ "Arn": "arn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222c", "CreatedAt": "2022-11-01T20:00:59.149Z", "State": "CREATING" }

创建本地索引后,您可以通过运行update-index-type命令将其转换为账户的聚合索引。

有关更多信息,请参阅《资源浏览器用户指南》中的在 Amazon 区域中打开Amazon 资源浏览器以索引您的资源

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateIndex中的。

以下代码示例演示如何使用 create-view

Amazon CLI

示例 1:为区域中的索引创建未经过滤的视图 Amazon

以下create-view示例在指定 Amazon 区域中创建了一个视图,该视图不经过任何筛选即可返回该区域中的所有结果。该视图在返回的结果中包含可选的 “标签” 字段。由于此视图是在包含聚合器索引的区域中创建的,因此它可以包含账户中包含资源浏览器索引的所有区域的结果。

aws resource-explorer-2 create-view \ --view-name My-Main-View \ --included-properties Name=tags \ --region us-east-1

输出:

{ "View": { "Filters": { "FilterString": "" }, "IncludedProperties": [ { "Name": "tags" } ], "LastUpdatedAt": "2022-07-13T20:34:11.314000+00:00", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-Main-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" } }

示例 2:创建仅返回与 Amazon EC2 关联的资源的视图

以下内容在 Amazon 区域中create-view创建了一个视图us-east-1,该视图仅返回该区域中与 Amazon EC2 服务关联的资源。该视图包括返回结果中的可选Tags字段。由于此视图是在包含聚合器索引的区域中创建的,因此它可以包含账户中包含资源浏览器索引的所有区域的结果。

aws resource-explorer-2 create-view \ --view-name My-EC2-Only-View \ --included-properties Name=tags \ --filters FilterString="service:ec2" \ --region us-east-1

输出:

{ "View": { "Filters": { "FilterString": "service:ec2" }, "IncludedProperties": [ { "Name":"tags" } ], "LastUpdatedAt": "2022-07-13T21:35:09.059Z", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222" } }

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的 “创建用于搜索的视图”。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考CreateView中的。

以下代码示例演示如何使用 delete-index

Amazon CLI

通过删除某个 Amazon 区域的索引来关闭该区域中的资源浏览器

以下delete-index示例删除您发出请求的 Amazon 区域中指定的资源浏览器索引。

aws resource-explorer-2 delete-index \ --arn arn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222 \ --region us-west-2

输出:

{ "Arn": "arn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222", "State": "DELETING" }

有关删除索引的更多信息,请参阅《Amazon 资源浏览器用户指南》中的在 Amazon 区域中关闭Amazon资源浏览器

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteIndex中的。

以下代码示例演示如何使用 delete-view

Amazon CLI

删除资源浏览器视图

以下delete-view示例删除由其 ARN 指定的视图。

aws resource-explorer-2 delete-view \ --view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111

输出:

{ "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" }

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的删除视图

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteView中的。

以下代码示例演示如何使用 disassociate-default-view

Amazon CLI

移除某个 Amazon 区域的默认资源浏览器视图

以下内容disassociate-default-view删除了您调用操作的 Amazon 区域的默认资源浏览器视图。执行此操作后,区域中的所有搜索操作都必须明确指定视图,否则操作将失败。

aws resource-explorer-2 disassociate-default-view

此命令不生成任何输出。

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的在 Amazon 区域中设置默认视图

以下代码示例演示如何使用 get-default-view

Amazon CLI

检索资源浏览器视图,该视图是其 Amazon 区域的默认视图

以下get-default-view示例检索视图的 ARN,该视图是您调用操作所在区域 Amazon 的默认视图。

aws resource-explorer-2 get-default-view

输出:

{ "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/default-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" }

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的在 Amazon 区域中设置默认视图

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考GetDefaultView中的。

以下代码示例演示如何使用 get-index

Amazon CLI

示例 1:检索资源浏览器聚合器索引的详细信息

以下get-index示例显示了指定 Amazon 区域中资源浏览器索引的详细信息。由于指定的区域包含该账户的聚合器索引,因此输出会列出将数据复制到该区域索引中的区域。

aws resource-explorer-2 get-index \ --region us-east-1

输出:

{ "Arn": "arn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111", "CreatedAt": "2022-07-12T18:59:10.503000+00:00", "LastUpdatedAt": "2022-07-13T18:41:58.799000+00:00", "ReplicatingFrom": [ "ap-south-1", "us-west-2" ], "State": "ACTIVE", "Tags": {}, "Type": "AGGREGATOR" }

示例 2:检索资源浏览器本地索引的详细信息

以下get-index示例显示了指定 Amazon 区域中资源浏览器索引的详细信息。由于指定的 Region 包含本地索引,因此输出会列出将该区域索引中的数据复制到的区域。

aws resource-explorer-2 get-index \ --region us-west-2

输出:

{ "Arn": "arn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222", "CreatedAt": "2022-07-12T18:59:10.503000+00:00", "LastUpdatedAt": "2022-07-13T18:41:58.799000+00:00", "ReplicatingTo": [ "us-west-2" ], "State": "ACTIVE", "Tags": {}, "Type": "LOCAL" }

有关索引的更多信息,请参阅《资源浏览器用户指南》中的检查哪些 Amazon 区域已开启Amazon资源浏览器

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考GetIndex中的。

以下代码示例演示如何使用 get-view

Amazon CLI

检索有关资源浏览器视图的详细信息

以下get-view示例显示有关由其 ARN 指定的视图的详细信息。

aws resource-explorer-2 get-view \ --view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111

输出:

{ "Tags" : {}, "View" : { "Filters" : { "FilterString" : "service:ec2" }, "IncludedProperties" : [ { "Name" : "tags" } ], "LastUpdatedAt" : "2022-07-13T21:33:45.249Z", "Owner" : "123456789012", "Scope" : "arn:aws:iam::123456789012:root", "ViewArn" : "arn:aws:resource-explorer-2:us-east-1:123456789012:view/EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" } }

有关视图的更多信息,请参阅《资源浏览器用户指南》中的关于Amazon 资源浏览器图。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考GetView中的。

以下代码示例演示如何使用 list-indexes

Amazon CLI

列出资源浏览器中包含索引的 Amazon 区域

以下list-indexes示例列出了资源浏览器具有索引的所有区域的索引。响应指定每个索引的类型、其 Amazon 区域及其 ARN。

aws resource-explorer-2 list-indexes

输出:

{ "Indexes": [ { "Arn": "arn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111", "Region": "us-west-2", "Type": "AGGREGATOR" }, { "Arn": "arn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222", "Region": "us-east-1", "Type": "LOCAL" }, { "Arn": "arn:aws:resource-explorer-2:us-east-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE33333", "Region": "us-east-2", "Type": "LOCAL" }, { "Arn": "arn:aws:resource-explorer-2:us-west-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE44444", "Region": "us-west-1", "Type": "LOCAL" } ] }

有关索引的更多信息,请参阅《资源浏览器用户指南》中的检查哪些 Amazon 区域已开启Amazon资源浏览器

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考ListIndexes中的。

以下代码示例演示如何使用 list-supported-resource-types

Amazon CLI

列出资源浏览器中包含索引的 Amazon 区域

以下list-supported-resource-types示例列出了 &arexLong; 当前支持的所有资源类型。示例响应包含一个NextToken值,该值表示有更多输出可供通过其他调用进行检索。

aws resource-explorer-2 list-supported-resource-types \ --max-items 10

输出:

{ "ResourceTypes": [ { "ResourceType": "cloudfront:cache-policy", "Service": "cloudfront" }, { "ResourceType": "cloudfront:distribution", "Service": "cloudfront" }, { "ResourceType": "cloudfront:function", "Service": "cloudfront" }, { "ResourceType": "cloudfront:origin-access-identity", "Service": "cloudfront" }, { "ResourceType": "cloudfront:origin-request-policy", "Service": "cloudfront" }, { "ResourceType": "cloudfront:realtime-log-config", "Service": "cloudfront" }, { "ResourceType": "cloudfront:response-headers-policy", "Service": "cloudfront" }, { "ResourceType": "cloudwatch:alarm", "Service": "cloudwatch" }, { "ResourceType": "cloudwatch:dashboard", "Service": "cloudwatch" }, { "ResourceType": "cloudwatch:insight-rule", "Service": "cloudwatch" } ], "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxMH0=" }

要获取输出的下一部分,请再次调用该操作,并将上一个调用的NextToken响应值作为的值传递--starting-token。重复此操作NextToken,直到响应中不存在。

aws resource-explorer-2 list-supported-resource-types \ --max-items 10 \ --starting-token eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxMH0=

输出:

{ "ResourceTypes": [ { "ResourceType": "cloudwatch:metric-stream", "Service": "cloudwatch" }, { "ResourceType": "dynamodb:table", "Service": "dynamodb" }, { "ResourceType": "ec2:capacity-reservation", "Service": "ec2" }, { "ResourceType": "ec2:capacity-reservation-fleet", "Service": "ec2" }, { "ResourceType": "ec2:client-vpn-endpoint", "Service": "ec2" }, { "ResourceType": "ec2:customer-gateway", "Service": "ec2" }, { "ResourceType": "ec2:dedicated-host", "Service": "ec2" }, { "ResourceType": "ec2:dhcp-options", "Service": "ec2" }, { "ResourceType": "ec2:egress-only-internet-gateway", "Service": "ec2" }, { "ResourceType": "ec2:elastic-gpu", "Service": "ec2" } ], "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyMH0=" }

有关索引的更多信息,请参阅《资源浏览器用户指南》中的检查哪些 Amazon 区域已开启Amazon资源浏览器

以下代码示例演示如何使用 list-tags-for-resource

Amazon CLI

列出附加到资源管理器视图或索引的标签

以下list-tags-for-resource示例列出了附加到具有指定 ARN 的 view 的标签键和值对。您必须从包含资源的 Amazon 区域调用该操作。

aws resource-explorer-2 list-tags-for-resource \ --resource-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111

输出:

{ "Tags": { "application": "MainCorpApp", "department": "1234" } }

有关为视图添加标签的更多信息,请参阅《Amazon 资源管理器用户指南》中的 “为视图添加标签以实现访问控制”。

以下代码示例演示如何使用 list-views

Amazon CLI

列出某个 Amazon 区域中可用的资源浏览器视图

以下list-views示例列出了您在其中调用操作的区域中可用的所有视图。

aws resource-explorer-2 list-views

输出:

{ "Views": [ "arn:aws:resource-explorer-2:us-east-1:123456789012:view/EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111", "arn:aws:resource-explorer-2:us-east-1:123456789012:view/Default-All-Resources-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222", "arn:aws:resource-explorer-2:us-east-1:123456789012:view/Production-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE33333" ] }

有关视图的更多信息,请参阅《资源浏览器用户指南》中的关于Amazon 资源浏览器图。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考ListViews中的。

以下代码示例演示如何使用 search

Amazon CLI

示例 1:使用默认视图进行搜索

以下search示例显示了指定中与该服务关联的所有资源。搜索使用该地区的默认视图。示例响应包含一个NextToken值,该值表示有更多输出可供通过其他调用进行检索。

aws resource-explorer-2 search \ --query-string "service:iam"

输出:

{ "Count": { "Complete": true, "TotalResources": 55 }, "NextToken": "AG9VOEF1KLEXAMPLEOhJHVwo5chEXAMPLER5XiEpNrgsEXAMPLE...b0CmOFOryHEXAMPLE", "Resources": [{ "Arn": "arn:aws:iam::123456789012:policy/service-role/Some-Policy-For-A-Service-Role", "LastReportedAt": "2022-07-21T12:34:42Z", "OwningAccountId": "123456789012", "Properties": [], "Region": "global", "ResourceType": "iam:policy", "Service": "iam" }, { "Arn": "arn:aws:iam::123456789012:policy/service-role/Another-Policy-For-A-Service-Role", "LastReportedAt": "2022-07-21T12:34:42Z", "OwningAccountId": "123456789012", "Properties": [], "Region": "global", "ResourceType": "iam:policy", "Service": "iam" }, { ... TRUNCATED FOR BREVITY ... }], "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/my-default-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" }

示例 2:使用指定视图进行搜索

以下search示例搜索显示了指定 Amazon 区域中通过指定视图可见的所有资源(“*”)。由于视图附带筛选条件,结果仅包含与 Amazon EC2 关联的资源。

aws resource-explorer-2 search \ -- query-string "*" \ -- view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222

输出:

HTTP/1.1 200 OK Date: Tue, 01 Nov 2022 20:00:59 GMT Content-Type: application/json Content-Length: <PayloadSizeBytes> { "Count": { "Complete": true, "TotalResources": 67 }, "Resources": [{ "Arn": "arn:aws:ec2:us-east-1:123456789012:network-acl/acl-1a2b3c4d", "LastReportedAt": "2022-07-21T18:52:02Z", "OwningAccountId": "123456789012", "Properties": [{ "Data": [{ "Key": "Department", "Value": "AppDevelopment" }, { "Key": "Environment", "Value": "Production" }], "LastReportedAt": "2021-11-15T14:48:29Z", "Name": "tags" }], "Region": "us-east-1", "ResourceType": "ec2:network-acl", "Service": "ec2" }, { "Arn": "arn:aws:ec2:us-east-1:123456789012:subnet/subnet-1a2b3c4d", "LastReportedAt": "2022-07-21T21:22:23Z", "OwningAccountId": "123456789012", "Properties": [{ "Data": [{ "Key": "Department", "Value": "AppDevelopment" }, { "Key": "Environment", "Value": "Production" }], "LastReportedAt": "2021-07-29T19:02:39Z", "Name": "tags" }], "Region": "us-east-1", "ResourceType": "ec2:subnet", "Service": "ec2" }, { "Arn": "arn:aws:ec2:us-east-1:123456789012:dhcp-options/dopt-1a2b3c4d", "LastReportedAt": "2022-07-21T06:08:53Z", "OwningAccountId": "123456789012", "Properties": [{ "Data": [{ "Key": "Department", "Value": "AppDevelopment" }, { "Key": "Environment", "Value": "Production" }], "LastReportedAt": "2021-11-15T15:11:05Z", "Name": "tags" }], "Region": "us-east-1", "ResourceType": "ec2:dhcpoptions", "Service": "ec2" }, { ... TRUNCATED FOR BREVITY ... }], "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-view/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222" }

有关更多信息,请参阅《Amazon 资源浏览器用户指南》中的使用Amazon 资源浏览器搜索资源

  • 有关 API 的详细信息,请参阅在Amazon CLI 命令参考搜索

以下代码示例演示如何使用 tag-resource

Amazon CLI

为资源浏览器视图添加标签

以下tag-resource示例将值为 “生产” 的标签键 “环境” 添加到具有指定 ARN 的视图中。

aws resource-explorer-2 tag-resource \ --resource-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View//EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111 \ --tags environment=production

此命令不生成任何输出。

有关更多信息,请参阅《Amazon 资源管理器用户指南》中的 “为视图添加标签以实现访问控制”。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考TagResource中的。

以下代码示例演示如何使用 untag-resource

Amazon CLI

从资源管理器视图中移除标签

以下untag-resource示例从具有指定 ARN 的视图中删除所有键名为 “environment” 的标签。

aws resource-explorer-2 untag-resource \ --resource-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View//EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111 \ --tag-keys environment

此命令不生成任何输出。

有关更多信息,请参阅《Amazon 资源管理器用户指南》中的 “为视图添加标签以实现访问控制”。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考UntagResource中的。

以下代码示例演示如何使用 update-index-type

Amazon CLI

更改资源浏览器索引的类型

以下update-index-type示例将指定的索引从类型localaggregator转换为类型,以开启在账户中所有 Amazon 区域搜索资源的功能。您必须将请求发送到包含要更新的索引的 Amazon 区域。

aws resource-explorer-2 update-index-type \ --arn arn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111 \ --type aggregator \ --region us-east-1

输出:

{ "Arn":"arn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111", "LastUpdatedAt":"2022-07-13T18:41:58.799Z", "State":"updating", "Type":"aggregator" }

有关更改索引类型的更多信息,请参阅《Amazon 资源浏览器用户指南》中的通过创建聚合器索引来启用跨区域搜索

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateIndexType中的。

以下代码示例演示如何使用 update-view

Amazon CLI

示例 1:更新资源浏览器视图的 IncludedProperties 字段

以下update-view示例通过添加`tags`可选视图来更新指定的视图`IncludedProperties`。运行此操作后,使用此视图的搜索操作将包含有关结果中显示的资源所附标签的信息。

aws resource-explorer-2 update-view \ --included-properties Name=tags \ --view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222

输出:

{ "View": { "Filters": { "FilterString": "" }, "IncludedProperties": [ { "Name": "tags" } ], "LastUpdatedAt": "2022-07-19T17:41:21.710000+00:00", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-EC2-Only-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111" } }

示例 2:更新附加到视图的筛选器

以下update-view示例将指定视图更新为使用筛选条件,该筛选条件将结果仅限于与 Amazon EC2 服务关联的资源类型。

aws resource-explorer-2 update-view \ --filters FilterString="service:ec2" \ --view-arn arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222

输出:

{ "View": { "Filters": { "FilterString": "service:ec2" }, "IncludedProperties": [], "LastUpdatedAt": "2022-07-19T17:41:21.710000+00:00", "Owner": "123456789012", "Scope": "arn:aws:iam::123456789012:root", "ViewArn": "arn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222" } }

有关视图的更多信息,请参阅《资源浏览器用户指南》中的关于Amazon 资源浏览器图。

  • 有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateView中的。