본문 바로가기

AWS/파워쉘로 배우는 AWS

#17 [EC2] Windows Instance를 만들어 보자.

AWS Xen 기반의 가상화 솔루션을 제공하기 때문에, 처음부터 Linux 친숙했던 것은 사실입니다. 하지만, 2014년부터 마이크로소프트의 새로운 최고경영자인 사티아 나델라가 취임하면서 마이크로소프트는 Linux 품고, Open Source 품어 Cloud, Mobile 사업을 집중 시키면서 많은 플랫폼들과 친숙해졌습니다.

그리고 우리는 Powershell AWS 배우고 있으니, Instance정도는 Windows 써야 cmdlet으로 AWS 관리할 있지 않나 싶습니다. 안타까운 사실은, 아직까지 Powershell 인지도와 SSH 지원하지 않으며, "Windows = GUI"라는 개념들이 너무 당연한 받아들여지기 때문에, AWS에서도 Powershell 지원하지만, Windows Server core버전은 지원하지 않습니다. (AMI 검색해보면 Windows Server Core버전이 있습니다만, 해당 AMI Beanstalk이라는 AWS 서비스에 의해 관리하는 Iknstance 만들 사용됩니다.)

굉장히 부정적으로 써놨지만, 사실 Azure에서도 Windows Server Core버전을 지원하지 않으니 상관 없다 생각한다.

(Windows Server 2016 에는 SSH기능이 내장되어 Core버전을 지원할 것으로 보여집니다. 이미 Azure에는 Windows Server 2016 Core TP4 게시되어있습니다.)

 

그럼 바로 Windows Instance 만들어 보시죠.


PS> $AMIImage = "ami-83a5bce2"

PS> $AccessPublicIp = $true

PS> $InstanceType = "t2.micro"

PS> $SubnetId = "subnet-d98c8abc"

PS> $SecurityGroupID = "sg-3dc0de59"

PS> $KeyPair = "kimsejun-oregon"

PS> New-EC2Instance -ImageId $AMIImage -InstanceType $InstanceType -AssociatePublicIp $AccessPublicIp `
-SubnetId $SubnetId -SecurityGroupId $SecurityGroupID -KeyName $KeyPair -MinCount 1 -MaxCount 1



 

정상적으로 생성 되었는지 확인해 보겠습니다.


PS> (Get-EC2Instance -Instance i-7120c9b6).Instances.state

PS> (Get-EC2Instance -Instance i-7120c9b6).Instances | `
select ImageId, PublicIpAddress, InstanceType, SubnetId, SecurityGroups, KeyName, PrivateIpAddress


 

 


지정한대로 생성이 완료되었습니다. 그럼 Instance 접속해 보도록 하겠습니다.

Windows 접속은 RDP 접속하시는 것은 다들 아실 것입니다. 하지만, RDP .pem 파일로 접속하는 방법이 없고 ID/PW방식으로 접속하기 때문에 .pem 파일을 가지고 Password 얻어내야 합니다.

이렇게 얻어진 Password 변경하여 관리하는 것이 AWS 권장사항이니 참고하시기 바랍니다.

(EC2 Instance 상태가 running인데 Password 얻지 못하시는 분들은 잠시 후에 다시 시도해 보시기 바랍니다. EC2 Instance running Machine 켜진 상태이지 OS 부팅(초기화) 완료된 상태가 아닙니다.)


PS> Get-EC2PasswordData -InstanceId i-7120c9b6 -PemFile D:\kimsejun-oregon.pem


 

 


Password 출력되었습니다. 해당 Password 사용하여 RDP 접속해 보도록 하겠습니다.



 

 

접속된 모습을 확인해 보실 있습니다.

다음 화면을 보시면 아시겠지만, Windows Server Instance에는 AWS Powershell Module 기본적으로 설치되어 있습니다.

 


 


Windows Instance까지 만들어 보았습니다.

 

참고자료 : http://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/concepts.html