aws:runCommand - 관리형 인스턴스에서 명령 실행 - AWS Systems Manager

aws:runCommand - 관리형 인스턴스에서 명령 실행

지정된 명령을 실행합니다.

참고

Automation은 하나의 AWS Systems Manager Run Command 작업의 출력만 지원합니다. 런북에는 Run Command 작업이 여러 개 포함될 수 있지만 출력은 한 번에 한 작업에서만 지원됩니다.

Input

이 작업은 대부분의 send-command 파라미터를 지원합니다. 자세한 내용은 SendCommand를 참조하십시오.

YAML
- name: checkMembership action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript InstanceIds: - '{{InstanceIds}}' Parameters: commands: - (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
JSON
{ "name": "checkMembership", "action": "aws:runCommand", "inputs": { "DocumentName": "AWS-RunPowerShellScript", "InstanceIds": [ "{{InstanceIds}}" ], "Parameters": { "commands": [ "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain" ] } } }
DocumentName

명령 유형 문서가 사용자 또는 AWS의 소유인 경우 문서의 이름을 지정합니다. 다른 AWS 계정이 공유한 문서를 사용하는 경우 문서의 Amazon 리소스 이름(ARN)을 지정합니다. 공유 문서 사용에 대한 자세한 내용은 공유 SSM 문서 사용 섹션을 참조하세요.

타입: 문자열

필수 항목 여부: 예

InstanceIds

명령을 실행할 인스턴스 ID입니다. 최대 50개 ID를 지정할 수 있습니다.

또한 인스턴스 ID 대신 의사 파라미터 {{RESOURCE_ID}}를 사용하여 대상 그룹의 모든 인스턴스에서 명령을 실행할 수 있습니다. 가상 파라미터에 대한 자세한 내용은 유지 관리 기간 작업 등록 시 의사 파라미터 사용 단원을 참조하십시오.

또 다른 대안은 Targets 파라미터를 사용하여 인스턴스 플릿에 명령을 보내는 것입니다. Targets 파라미터는 Amazon Elastic Compute Cloud(Amazon EC2) 태그를 허용합니다. Targets 파라미터 사용 방법에 대한 자세한 내용은 대규모로 명령 실행 섹션을 참조하세요.

유형: StringList

필수 여부: 아니요(InstanceId를 지정하지 않거나 {{RESOURCE_ID}} 의사 파라미터를 사용하지 않는 경우 Targets 파라미터를 지정해야 함)

대상

지정한 키, 값 조합을 사용하여 인스턴스를 대상으로 하는 검색 기준의 배열입니다. Targets는 호출에 하나 이상의 인스턴스 ID를 제공하지 않는 경우 필요합니다. Targets 파라미터 사용 방법에 대한 자세한 내용은 대규모로 명령 실행 섹션을 참조하세요.

형식: MapList(목록의 맵 스키마가 객체와 일치해야 합니다.) 자세한 내용은 AWS Systems Manager API ReferenceTarget을 참조하세요.

필수 여부: 아니요(Targets를 지정하지 않는 경우 InstanceId를 지정하거나 {{RESOURCE_ID}} 의사 파라미터를 사용해야 함)

다음은 한 예입니다.

YAML
- name: checkMembership action: aws:runCommand inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: tag:Stage Values: - Gamma - Beta - Key: tag-key Values: - Suite Parameters: commands: - (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
JSON
{ "name": "checkMembership", "action": "aws:runCommand", "inputs": { "DocumentName": "AWS-RunPowerShellScript", "Targets": [ { "Key": "tag:Stage", "Values": [ "Gamma", "Beta" ] }, { "Key": "tag:Application", "Values": [ "Suite" ] } ], "Parameters": { "commands": [ "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain" ] } } }
파라미터

문서에서 지정된 필수 및 선택 파라미터.

유형: 맵

필수 항목 여부: 아니요

CloudWatchOutputConfig

명령 출력을 Amazon CloudWatch Logs로 전송하기 위한 구성 옵션입니다. CloudWatch Logs로 명령 출력 전송에 대한 자세한 내용은 Run Command에 대한 Amazon CloudWatch Logs 구성 섹션을 참조하세요.

유형: StringMap(지도의 스키마는 객체와 일치해야 합니다. 자세한 내용은 AWS Systems Manager API ReferenceCloudWatchOutputConfig를 참조하세요.)

필수 항목 여부: 아니요

다음은 한 예입니다.

YAML
- name: checkMembership action: aws:runCommand inputs: DocumentName: AWS-RunPowerShellScript InstanceIds: - "{{InstanceIds}}" Parameters: commands: - "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain" CloudWatchOutputConfig: CloudWatchLogGroupName: CloudWatchGroupForSSMAutomationService CloudWatchOutputEnabled: true
JSON
{ "name": "checkMembership", "action": "aws:runCommand", "inputs": { "DocumentName": "AWS-RunPowerShellScript", "InstanceIds": [ "{{InstanceIds}}" ], "Parameters": { "commands": [ "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain" ] }, "CloudWatchOutputConfig" : { "CloudWatchLogGroupName": "CloudWatchGroupForSSMAutomationService", "CloudWatchOutputEnabled": true } } }
설명

명령에 관한 사용자 정의 정보.

타입: 문자열

필수 항목 여부: 아니요

DocumentHash

문서에 대한 해시.

타입: 문자열

필수 항목 여부: 아니요

DocumentHashType

해시의 유형.

타입: 문자열

유효한 값: Sha256 | Sha1

필수 항목 여부: 아니요

NotificationConfig

알림 전송에 대한 구성.

필수 항목 여부: 아니요

OutputS3BucketName

명령 출력 응답에 대한 S3 버킷의 이름.

타입: 문자열

필수 항목 여부: 아니요

OutputS3KeyPrefix

접두사입니다.

타입: 문자열

필수 항목 여부: 아니요

ServiceRoleArn

AWS Identity and Access Management(IAM) 역할의 ARN.

타입: 문자열

필수 항목 여부: 아니요

TimeoutSeconds

명령이 인스턴스의 AWS Systems Manager SSM Agent에 전송될 때까지 대기하는 시간(초)입니다. 지정된 값에 도달하기 전에 인스턴스의 SSM Agent에서 명령을 수신하지 않으면 명령 상태가 Delivery Timed Out으로 변경됩니다.

유형: 정수

필수 항목 여부: 아니요

유효한 값: 30~2592000

출력
CommandId

명령의 ID.

상태 표시기

명령의 상태.

ResponseCode

명령의 응답 코드입니다. 실행하는 문서의 단계가 두 개 이상인 경우 이 출력에는 값이 반환되지 않습니다.

출력

명령의 출력입니다. 명령으로 태그 또는 여러 인스턴스를 대상으로 지정하는 경우 출력 값이 반환되지 않습니다. GetCommandInvocationListCommandInvocations API 작업을 사용하여 개별 인스턴스의 출력을 검색할 수 있습니다.