文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭配使用 ListDocuments
與 CLI
下列程式碼範例示範如何使用 ListDocuments
。
- CLI
-
- AWS CLI
-
範例 1:列出文件
下列
list-documents
範例列出了由請求帳戶擁有、以自訂標籤標記的文件。aws ssm list-documents \ --filters
Key=Owner,Values=Self
Key=tag:DocUse,Values=Testing
輸出:
{ "DocumentIdentifiers": [ { "Name": "Example", "Owner": "29884EXAMPLE", "PlatformTypes": [ "Windows", "Linux" ], "DocumentVersion": "1", "DocumentType": "Automation", "SchemaVersion": "0.3", "DocumentFormat": "YAML", "Tags": [ { "Key": "DocUse", "Value": "Testing" } ] } ] }
如需詳細資訊,請參閱《AWS Systems Manager 使用者指南》中的 AWS Systems Manager Documents。
範例 2:列出共用文件
下列
list-documents
範例列出共用文件,包括非 擁有的私有共用文件 AWS。aws ssm list-documents \ --filters
Key=Name,Values=sharedDocNamePrefix
Key=Owner,Values=Private
輸出:
{ "DocumentIdentifiers": [ { "Name": "Example", "Owner": "12345EXAMPLE", "PlatformTypes": [ "Windows", "Linux" ], "DocumentVersion": "1", "DocumentType": "Command", "SchemaVersion": "0.3", "DocumentFormat": "YAML", "Tags": [] } ] }
如需詳細資訊,請參閱《AWS Systems Manager 使用者指南》中的 AWS Systems Manager Documents。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListDocuments
。
-
- PowerShell
-
- Tools for PowerShell
-
範例 1:列出帳戶中的所有組態文件。
Get-SSMDocumentList
輸出:
DocumentType : Command DocumentVersion : 1 Name : AWS-ApplyPatchBaseline Owner : Amazon PlatformTypes : {Windows} SchemaVersion : 1.2 DocumentType : Command DocumentVersion : 1 Name : AWS-ConfigureAWSPackage Owner : Amazon PlatformTypes : {Windows, Linux} SchemaVersion : 2.0 DocumentType : Command DocumentVersion : 1 Name : AWS-ConfigureCloudWatch Owner : Amazon PlatformTypes : {Windows} SchemaVersion : 1.2 ...
範例 2:此範例示範擷取名稱符合 "Platform" 的所有自動化文件
Get-SSMDocumentList -DocumentFilterList @{Key="DocumentType";Value="Automation"} | Where-Object Name -Match "Platform"
輸出:
DocumentFormat : JSON DocumentType : Automation DocumentVersion : 7 Name : KT-Get-Platform Owner : 987654123456 PlatformTypes : {Windows, Linux} SchemaVersion : 0.3 Tags : {} TargetType : VersionName :
-
如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考》中的 ListDocuments。
-
ListDocumentVersions
ListInventoryEntries