将 ListDocuments 与 Amazon SDK 或 CLI 配合使用 - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

ListDocuments 与 Amazon SDK 或 CLI 配合使用

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

CLI
Amazon 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" } ] } ] }

有关更多信息,请参阅《Amazon Systems Manager 用户指南》中的 Amazon Systems Manager 文档

示例 2:列出共享文档

以下 list-documents 示例列出共享文档,包括不属于 Amazon 的私有共享文档。

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": [] } ] }

有关更多信息,请参阅《Amazon Systems Manager 用户指南》中的 Amazon Systems Manager 文档

  • 有关 API 详细信息,请参阅《Amazon CLI Command Reference》中的 ListDocuments

PowerShell
适用于 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 详细信息,请参阅《Amazon Tools for PowerShell Cmdlet Reference》中的 ListDocuments

有关 Amazon SDK 开发人员指南和代码示例的完整列表,请参阅 将 Systems Manager 与 Amazon SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。