• n' AWS Systems ManagerChange Managerest plus ouvert aux nouveaux clients. Les clients existants peuvent continuer à utiliser le service normalement. Pour plus d'informations, consultez AWS Systems ManagerChange Managerla section Modification de la disponibilité.
• Le AWS Systems Manager CloudWatch tableau de bord ne sera plus disponible après le 30 avril 2026. Les clients peuvent continuer à utiliser CloudWatch la console Amazon pour consulter, créer et gérer leurs CloudWatch tableaux de bord Amazon, comme ils le font aujourd'hui. Pour plus d'informations, consultez la documentation Amazon CloudWatch Dashboard.
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation de GetDocument avec une CLI
Les exemples de code suivants illustrent comment utiliser GetDocument.
- CLI
-
- AWS CLI
-
Pour obtenir le contenu d’un document
L’exemple get-document suivant affiche le contenu d’un document Systems Manager.
aws ssm get-document \
--name "AWS-RunShellScript"
Sortie :
{
"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"
}
Pour plus d’informations, consultez Documents AWS Systems Manager dans le Guide de l’utilisateur AWS Systems Manager.
- PowerShell
-
- Outils pour PowerShell V4
-
Exemple 1 : cet exemple renvoie le contenu d’un document.
Get-SSMDocument -Name "RunShellScript"
Sortie :
Content
-------
{...
Exemple 2 : cet exemple affiche le contenu complet d’un document.
(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 }}"
}
}
]
}
- Outils pour PowerShell V5
-
Exemple 1 : cet exemple renvoie le contenu d’un document.
Get-SSMDocument -Name "RunShellScript"
Sortie :
Content
-------
{...
Exemple 2 : cet exemple affiche le contenu complet d’un document.
(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 }}"
}
}
]
}
Pour obtenir la liste complète des guides de développement du AWS SDK et des exemples de code, consultezUtilisation de ce service avec un AWS SDK. Cette rubrique comprend également des informations sur le démarrage et sur les versions précédentes du kit SDK.