CLI로 GetConsoleOutput 사용 - Amazon Elastic Compute Cloud

CLI로 GetConsoleOutput 사용

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

CLI
AWS CLI

예시 1: 콘솔 출력을 가져오는 방법

다음 get-console-output 예시에서는 지정된 Linux 인스턴스에 대한 콘솔 출력을 가져옵니다.

aws ec2 get-console-output \ --instance-id i-1234567890abcdef0

결과:

{ "InstanceId": "i-1234567890abcdef0", "Timestamp": "2013-07-25T21:23:53.000Z", "Output": "..." }

자세한 내용은 Amazon EC2 사용 설명서인스턴스 콘솔 출력을 참조하세요.

예시 2: 최신 콘솔 출력을 가져오는 방법

다음 get-console-output 예시에서는 지정된 Linux 인스턴스에 대한 최신 콘솔 출력을 가져옵니다.

aws ec2 get-console-output \ --instance-id i-1234567890abcdef0 \ --latest \ --output text

결과:

i-1234567890abcdef0 [ 0.000000] Command line: root=LABEL=/ console=tty1 console=ttyS0 selinux=0 nvme_core.io_timeout=4294967295 [ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' [ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' ... Cloud-init v. 0.7.6 finished at Wed, 09 May 2018 19:01:13 +0000. Datasource DataSourceEc2. Up 21.50 seconds Amazon Linux AMI release 2018.03 Kernel 4.14.26-46.32.amzn1.x

자세한 내용은 Amazon EC2 사용 설명서인스턴스 콘솔 출력을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조GetConsoleOutput 섹션을 참조하세요.

PowerShell
Tools for PowerShell V4

예제 1: 이 예제에서는 지정된 Linux 인스턴스에 대한 콘솔 출력을 가져옵니다. 콘솔 출력이 인코딩됩니다.

Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456

출력:

InstanceId Output ---------- ------ i-0e194d3c47c123637 WyAgICAwLjAwMDAwMF0gQ29tbW...bGU9dHR5UzAgc2Vs

예제 2: 이 예제에서는 인코딩된 콘솔 출력을 변수에 저장한 다음 디코딩합니다.

$Output_encoded = (Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456).Output [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Output_encoded))
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조(V4)GetConsoleOutput을 참조하세요.

Tools for PowerShell V5

예제 1: 이 예제에서는 지정된 Linux 인스턴스에 대한 콘솔 출력을 가져옵니다. 콘솔 출력이 인코딩됩니다.

Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456

출력:

InstanceId Output ---------- ------ i-0e194d3c47c123637 WyAgICAwLjAwMDAwMF0gQ29tbW...bGU9dHR5UzAgc2Vs

예제 2: 이 예제에서는 인코딩된 콘솔 출력을 변수에 저장한 다음 디코딩합니다.

$Output_encoded = (Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456).Output [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Output_encoded))
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조(V5)GetConsoleOutput을 참조하세요.

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