CLI로 DescribeAssociationExecutionTargets 사용 - AWS Systems Manager

AWS Systems Manager Change Manager는 더 이상 신규 고객에게 공개되지 않습니다. 기존 고객은 정상적으로 서비스를 계속 이용할 수 있습니다. 자세한 내용은 AWS Systems Manager Change Manager 가용성 변경을 참조하세요.

CLI로 DescribeAssociationExecutionTargets 사용

다음 코드 예시는 DescribeAssociationExecutionTargets의 사용 방법을 보여 줍니다.

CLI
AWS CLI

연결 실행의 세부 정보를 가져오는 방법

다음 describe-association-execution-targets 예제에서는 지정된 연결 실행을 설명합니다.

aws ssm describe-association-execution-targets \ --association-id "8dfe3659-4309-493a-8755-0123456789ab" \ --execution-id "7abb6378-a4a5-4f10-8312-0123456789ab"

결과:

{ "AssociationExecutionTargets": [ { "AssociationId": "8dfe3659-4309-493a-8755-0123456789ab", "AssociationVersion": "1", "ExecutionId": "7abb6378-a4a5-4f10-8312-0123456789ab", "ResourceId": "i-1234567890abcdef0", "ResourceType": "ManagedInstance", "Status": "Success", "DetailedStatus": "Success", "LastExecutionDate": 1550505538.497, "OutputSource": { "OutputSourceId": "97fff367-fc5a-4299-aed8-0123456789ab", "OutputSourceType": "RunCommand" } } ] }

자세한 내용은 AWS Systems Manager 사용 설명서의 연결 기록 보기를 참조하세요.

PowerShell
Tools for PowerShell V4

예제 1: 이 예제에서는 연결 실행 대상의 일부인 리소스 ID와 해당 실행 상태를 표시합니다.

Get-SSMAssociationExecutionTarget -AssociationId 123a45a0-c678-9012-3456-78901234db5e -ExecutionId 123a45a0-c678-9012-3456-78901234db5e | Select-Object ResourceId, Status

출력:

ResourceId Status ---------- ------ i-0b1b2a3456f7a890b Success i-01c12a45d6fc7a89f Success i-0a1caf234f56d7dc8 Success i-012a3fd45af6dbcfe Failed i-0ddc1df23c4a5fb67 Success

예제 2: 이 명령은 어제 이후 명령 문서가 연결된 명령 자동화의 특정 실행을 확인합니다. 연결 실행이 실패했는지 추가로 확인하고, 실패한 경우 인스턴스 ID와 함께 실행에 대한 명령 간접 호출 세부 정보를 표시합니다.

$AssociationExecution= Get-SSMAssociationExecutionTarget -AssociationId 1c234567-890f-1aca-a234-5a678d901cb0 -ExecutionId 12345ca12-3456-2345-2b45-23456789012 | Where-Object {$_.LastExecutionDate -gt (Get-Date -Hour 00 -Minute 00).AddDays(-1)} foreach ($execution in $AssociationExecution) { if($execution.Status -ne 'Success'){ Write-Output "There was an issue executing the association $($execution.AssociationId) on $($execution.ResourceId)" Get-SSMCommandInvocation -CommandId $execution.OutputSource.OutputSourceId -Detail:$true | Select-Object -ExpandProperty CommandPlugins } }

출력:

There was an issue executing the association 1c234567-890f-1aca-a234-5a678d901cb0 on i-0a1caf234f56d7dc8 Name : aws:runPowerShellScript Output : ----------ERROR------- failed to run commands: exit status 1 OutputS3BucketName : OutputS3KeyPrefix : OutputS3Region : eu-west-1 ResponseCode : 1 ResponseFinishDateTime : 5/29/2019 11:04:49 AM ResponseStartDateTime : 5/29/2019 11:04:49 AM StandardErrorUrl : StandardOutputUrl : Status : Failed StatusDetails : Failed
Tools for PowerShell V5

예제 1: 이 예제에서는 연결 실행 대상의 일부인 리소스 ID와 해당 실행 상태를 표시합니다

Get-SSMAssociationExecutionTarget -AssociationId 123a45a0-c678-9012-3456-78901234db5e -ExecutionId 123a45a0-c678-9012-3456-78901234db5e | Select-Object ResourceId, Status

출력:

ResourceId Status ---------- ------ i-0b1b2a3456f7a890b Success i-01c12a45d6fc7a89f Success i-0a1caf234f56d7dc8 Success i-012a3fd45af6dbcfe Failed i-0ddc1df23c4a5fb67 Success

예제 2: 이 명령은 어제 이후 명령 문서가 연결된 명령 자동화의 특정 실행을 확인합니다. 연결 실행이 실패했는지 추가로 확인하고, 실패한 경우 인스턴스 ID와 함께 실행에 대한 명령 간접 호출 세부 정보를 표시합니다

$AssociationExecution= Get-SSMAssociationExecutionTarget -AssociationId 1c234567-890f-1aca-a234-5a678d901cb0 -ExecutionId 12345ca12-3456-2345-2b45-23456789012 | Where-Object {$_.LastExecutionDate -gt (Get-Date -Hour 00 -Minute 00).AddDays(-1)} foreach ($execution in $AssociationExecution) { if($execution.Status -ne 'Success'){ Write-Output "There was an issue executing the association $($execution.AssociationId) on $($execution.ResourceId)" Get-SSMCommandInvocation -CommandId $execution.OutputSource.OutputSourceId -Detail:$true | Select-Object -ExpandProperty CommandPlugins } }

출력:

There was an issue executing the association 1c234567-890f-1aca-a234-5a678d901cb0 on i-0a1caf234f56d7dc8 Name : aws:runPowerShellScript Output : ----------ERROR------- failed to run commands: exit status 1 OutputS3BucketName : OutputS3KeyPrefix : OutputS3Region : eu-west-1 ResponseCode : 1 ResponseFinishDateTime : 5/29/2019 11:04:49 AM ResponseStartDateTime : 5/29/2019 11:04:49 AM StandardErrorUrl : StandardOutputUrl : Status : Failed StatusDetails : Failed

AWS SDK 개발자 가이드 및 코드 예시의 전체 목록은 AWS SDK와 함께 이 서비스 사용 섹션을 참조하세요. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.