使用 AWS CLI 的資源總管範例
下列程式碼範例示範如何使用 AWS Command Line Interface 搭配資源總管來執行動作,並實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。
每個範例均包含完整原始程式碼的連結,您可在連結中找到如何在內容中設定和執行程式碼的相關指示。
主題
動作
以下程式碼範例顯示如何使用 associate-default-view。
- AWS CLI
-
將資源總管檢視設定為其 AWS 區域的預設值
下列
associate-default-view範例會將 ARN 指定的檢視設定為您呼叫操作之 AWS 區域的預設檢視。aws resource-explorer-2 associate-default-view \ --view-arnarn: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" }如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的在 AWS 區域中設定預設檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 AssociateDefaultView
。
-
以下程式碼範例顯示如何使用 batch-get-view。
- AWS CLI
-
擷取多個資源總管檢視的詳細資訊
下列
batch-get-view範例顯示其 ARN 所指定之兩個檢視的詳細資訊。使用空格分隔 --view-arn 參數中的多個 ARN。aws resource-explorer-2 batch-get-view \ --view-arnsarn: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": [] }如需檢視的詳細資訊,請參閱《AWS 資源總管使用者指南》中的關於資源總管檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 BatchGetView
。
-
以下程式碼範例顯示如何使用 create-index。
- AWS CLI
-
透過建立索引開啟 AWS 區域中的資源總管
下列
create-index範例會在呼叫操作的 AWS 區域中建立本機索引。AWS CLI 會自動產生隨機client-token參數值,如果您未指定值,則將其包含在對 AWS 的呼叫中。aws resource-explorer-2 create-index \ --regionus-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 命令,將其轉換為帳戶的彙總工具索引。
如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的在 AWS 區域中開啟資源總管以編製資源索引。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreateIndex
。
-
以下程式碼範例顯示如何使用 create-view。
- AWS CLI
-
範例 1:為 AWS 區域中的索引建立未篩選的檢視
下列
create-view範例會在指定的 AWS 區域中建立檢視,傳回區域中的所有結果,而不需要任何篩選。檢視包含傳回結果的選用 Tags 欄位。由於此檢視是在包含彙總工具索引的區域中建立,因此可以包含帳戶中包含資源總管索引之所有區域的結果。aws resource-explorer-2 create-view \ --view-nameMy-Main-View\ --included-propertiesName=tags\ --regionus-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 相關聯資源的檢視
下列
create-view會在 AWS 區域us-east-1中建立檢視,僅傳回區域中與 Amazon EC2 服務相關聯的資源。檢視包含傳回結果的選用Tags欄位。由於此檢視是在包含彙總工具索引的區域中建立,因此可以包含帳戶中包含資源總管索引之所有區域的結果。aws resource-explorer-2 create-view \ --view-nameMy-EC2-Only-View\ --included-propertiesName=tags\ --filters FilterString="service:ec2" \ --regionus-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" } }如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的建立要搜尋的檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreateView
。
-
以下程式碼範例顯示如何使用 delete-index。
- AWS CLI
-
透過刪除該區域的索引以關閉 AWS 中的資源總管
下列
delete-index範例會在您提出請求的 AWS 區域中刪除指定的資源總管索引。aws resource-explorer-2 delete-index \ --arnarn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222\ --regionus-west-2輸出:
{ "Arn": "arn:aws:resource-explorer-2:us-west-2:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE22222", "State": "DELETING" }如需刪除索引的詳細資訊,請參閱《AWS 資源總管使用者指南》中的關閉 AWS 區域中的 AWS 資源總管。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeleteIndex
。
-
以下程式碼範例顯示如何使用 delete-view。
- AWS CLI
-
刪除資源總管檢視
下列
delete-view範例會刪除其 ARN 指定的檢視。aws resource-explorer-2 delete-view \ --view-arnarn: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" }如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的刪除檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeleteView
。
-
以下程式碼範例顯示如何使用 disassociate-default-view。
- AWS CLI
-
移除 AWS 區域的預設資源總管檢視
下列
disassociate-default-view會移除您呼叫操作之 AWS 區域的預設資源總管檢視。執行此操作後,區域中的所有搜尋操作都必須明確指定檢視,否則操作會失敗。aws resource-explorer-2 disassociate-default-view此命令不會產生輸出。
如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的在 AWS 區域中設定預設檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DisassociateDefaultView
。
-
以下程式碼範例顯示如何使用 get-default-view。
- AWS CLI
-
擷取其 AWS 區域預設檢視的資源總管檢視
下列
get-default-view範例會擷取檢視的 ARN,該檢視是您呼叫操作之 AWS 區域的預設值。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" }如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的在 AWS 區域中設定預設檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetDefaultView
。
-
以下程式碼範例顯示如何使用 get-index。
- AWS CLI
-
範例 1:擷取資源總管彙總工具索引的詳細資訊
下列
get-index範例顯示指定 AWS 區域中資源總管索引的詳細資訊。由於指定的區域包含帳戶的彙總工具索引,因此輸出會列出將資料複寫至此區域索引的區域。aws resource-explorer-2 get-index \ --regionus-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範例顯示指定 AWS 區域中資源總管索引的詳細資訊。由於指定的區域包含本機索引,輸出會列出從此區域索引複寫資料的區域。aws resource-explorer-2 get-index \ --regionus-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" }如需索引的詳細資訊,請參閱《AWS 資源總管使用者指南》中的檢查已開啟資源總管的 AWS 區域。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetIndex
。
-
以下程式碼範例顯示如何使用 get-view。
- AWS CLI
-
擷取資源總管檢視的詳細資訊
下列
get-view範例顯示其 ARN 所指定檢視的詳細資訊。aws resource-explorer-2 get-view \ --view-arnarn: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" } }如需檢視的詳細資訊,請參閱《AWS 資源總管使用者指南》中的關於資源總管檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetView
。
-
以下程式碼範例顯示如何使用 list-indexes。
- AWS CLI
-
列出資源總管具有索引的 AWS 區域
下列
list-indexes範例列出資源總管具有索引之所有區域的索引。回應會指定每個索引的類型、其 AWS 區域及其 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" } ] }如需索引的詳細資訊,請參閱《AWS 資源總管使用者指南》中的檢查已開啟資源總管的 AWS 區域。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListIndexes
。
-
以下程式碼範例顯示如何使用 list-supported-resource-types。
- AWS CLI
-
列出資源總管具有索引的 AWS 區域
下列
list-supported-resource-types範例會列出 &AREXlong; 目前支援的所有資源類型。範例回應包含一個NextToken值,表示有更多輸出可供其他呼叫擷取。aws resource-explorer-2 list-supported-resource-types \ --max-items10輸出:
{ "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-items10\ --starting-tokeneyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxMH0=輸出:
{ "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=" }如需索引的詳細資訊,請參閱《AWS 資源總管使用者指南》中的檢查已開啟資源總管的 AWS 區域。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListSupportedResourceTypes
。
-
以下程式碼範例顯示如何使用 list-tags-for-resource。
- AWS CLI
-
列出連接至資源總管檢視或索引的標籤
下列
list-tags-for-resource範例會列出連接至具有指定 ARN 之檢視的標籤索引鍵和值對。您必須從包含資源的 AWS 區域呼叫操作。aws resource-explorer-2 list-tags-for-resource \ --resource-arnarn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111輸出:
{ "Tags": { "application": "MainCorpApp", "department": "1234" } }如需標記檢視的詳細資訊,請參閱《AWS 資源總管使用者指南》中的標記存取控制的檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListTagsForResource
。
-
以下程式碼範例顯示如何使用 list-views。
- AWS CLI
-
列出 AWS 區域中可用的資源總管檢視
下列
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" ] }如需檢視的詳細資訊,請參閱《AWS 資源總管使用者指南》中的關於資源總管檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListViews
。
-
以下程式碼範例顯示如何使用 search。
- AWS 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範例搜尋會顯示指定 AWS 區域中透過指定檢視可見的所有資源 ("*")。結果僅包含與 Amazon EC2 相關聯的資源,因為篩選條件連接到檢視。aws resource-explorer-2 search \ --query-string"*"\ --view-arnarn: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" }如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的使用 AWS 資源總管搜尋資源。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 Search
。
-
以下程式碼範例顯示如何使用 tag-resource。
- AWS CLI
-
標記資源總管檢視
下列
tag-resource範例會將值為 "production" 的標籤索引鍵 "environment" 新增至具有指定 ARN 的檢視。aws resource-explorer-2 tag-resource \ --resource-arnarn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View//EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111\ --tagsenvironment=production此命令不會產生輸出。
如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的標記存取控制的檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 TagResource
。
-
以下程式碼範例顯示如何使用 untag-resource。
- AWS CLI
-
從資源總管檢視中移除標籤
下列
untag-resource範例會從具有指定 ARN 的檢視中移除索引鍵名稱 "environment" 的標籤:aws resource-explorer-2 untag-resource \ --resource-arnarn:aws:resource-explorer-2:us-east-1:123456789012:view/My-View//EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111\ --tag-keysenvironment此命令不會產生輸出。
如需詳細資訊,請參閱《AWS 資源總管使用者指南》中的標記存取控制的檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UntagResource
。
-
以下程式碼範例顯示如何使用 update-index-type。
- AWS CLI
-
變更資源總管索引的類型
下列
update-index-type範例會將指定的索引從local類型轉換為類型aggregator,以開啟搜尋帳戶中所有 AWS 區域之資源的功能。您必須將請求傳送至包含您要更新之索引的 AWS 區域。aws resource-explorer-2 update-index-type \ --arnarn:aws:resource-explorer-2:us-east-1:123456789012:index/EXAMPLE8-90ab-cdef-fedc-EXAMPLE11111\ --typeaggregator\ --regionus-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" }如需關於變更索引類型的詳細資訊,請參閱《AWS 資源總管使用者指南》中的建立彙整工具索引以開啟跨區域搜尋。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UpdateIndexType
。
-
以下程式碼範例顯示如何使用 update-view。
- AWS CLI
-
範例 1:更新資源總管檢視的 IncludedProperties 欄位
下列
update-view範例會將`tags`新增至選用的`IncludedProperties`,以更新指定的檢視。執行此操作後,使用此檢視的搜尋操作包含連接到結果中所顯示資源之標籤的相關資訊。aws resource-explorer-2 update-view \ --included-propertiesName=tags\ --view-arnarn: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-arnarn: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" } }如需檢視的詳細資訊,請參閱《AWS 資源總管使用者指南》中的關於資源總管檢視。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UpdateView
。
-