本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
GetDocument
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 GetDocument
。
- CLI
-
- AWS CLI
-
若要取得文件內容
下列
get-document
範例顯示 Systems Manager 文件的內容。aws ssm get-document \ --name
"AWS-RunShellScript"
輸出:
{ "Name": "AWS-RunShellScript", "DocumentVersion": "1", "Status": "Active", "Content": "{\n \"schemaVersion\":\"1.2\",\n \"description\":\"Run a shell script or specify the commands to run.\",\n \"parameters\":{\n \"commands\":{\n \"type\":\"StringList\",\n \"description\":\"(Required) Specify a shell script or a command to run.\",\n \"minItems\":1,\n \"displayType\":\"textarea\"\n },\n \"workingDirectory\":{\n \"type\":\"String\",\n \"default\":\"\",\n \"description\":\"(Optional) The path to the working directory on your instance.\",\n \"maxChars\":4096\n },\n \"executionTimeout\":{\n \"type\":\"String\",\n \"default\":\"3600\",\n \"description\":\"(Optional) The time in seconds for a command to complete before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).\",\n \"allowedPattern\":\"([1-9][0-9]{0,4})|(1[0-6][0-9]{4})|(17[0-1][0-9]{3})|(172[0-7][0-9]{2})|(172800)\"\n }\n },\n \"runtimeConfig\":{\n \"aws:runShellScript\":{\n \"properties\":[\n {\n \"id\":\"0.aws:runShellScript\",\n \"runCommand\":\"{{ commands }}\",\n \"workingDirectory\":\"{{ workingDirectory }}\",\n \"timeoutSeconds\":\"{{ executionTimeout }}\"\n }\n ]\n }\n }\n}\n", "DocumentType": "Command", "DocumentFormat": "JSON" }
如需詳細資訊,請參閱 AWS Systems Manager 使用者指南中的 Systems Manager 文件AWS 。
-
如需API詳細資訊,請參閱 命令參考 GetDocument
中的 。 AWS CLI
-
- PowerShell
-
- 適用於 的工具 PowerShell
-
範例 1:此範例會傳回文件的內容。
Get-SSMDocument -Name "RunShellScript"
輸出:
Content ------- {...
範例 2:此範例顯示文件的完整內容。
(Get-SSMDocument -Name "RunShellScript").Content { "schemaVersion":"2.0", "description":"Run an updated script", "parameters":{ "commands":{ "type":"StringList", "description":"(Required) Specify a shell script or a command to run.", "minItems":1, "displayType":"textarea" } }, "mainSteps":[ { "action":"aws:runShellScript", "name":"runShellScript", "inputs":{ "commands":"{{ commands }}" } }, { "action":"aws:runPowerShellScript", "name":"runPowerShellScript", "inputs":{ "commands":"{{ commands }}" } } ] }
-
如需API詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 GetDocument中的 。
-
如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 搭配 使用 Systems Manager AWS SDK。本主題也包含入門的相關資訊,以及先前SDK版本的詳細資訊。
GetDeployablePatchSnapshotForInstance
GetInventory