搭ListDocuments配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ListDocuments配 AWS SDK或使用 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 文件

範例 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 文件

  • 如需詳API細資訊,請參閱AWS CLI 指令參考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:此範例會擷取名稱相符為「平台」的所有自動化文件

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 指令程ListDocuments式參考中的。