CLI로 RunScheduledInstances 사용 - AWS SDK 코드 예제

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

CLI로 RunScheduledInstances 사용

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

CLI
AWS CLI

정기 인스턴스 시작

이 예시에서는 VPC에서 지정된 정기 인스턴스를 시작합니다.

명령:

aws ec2 run-scheduled-instances --scheduled-instance-id sci-1234-1234-1234-1234-123456789012 --instance-count 1 --launch-specification file://launch-specification.json

Launch-specification.json:

{ "ImageId": "ami-12345678", "KeyName": "my-key-pair", "InstanceType": "c4.large", "NetworkInterfaces": [ { "DeviceIndex": 0, "SubnetId": "subnet-12345678", "AssociatePublicIpAddress": true, "Groups": ["sg-12345678"] } ], "IamInstanceProfile": { "Name": "my-iam-role" } }

출력:

{ "InstanceIdSet": [ "i-1234567890abcdef0" ] }

이 예시에서는 EC2-Classic에서 지정된 정기 인스턴스를 시작합니다.

명령:

aws ec2 run-scheduled-instances --scheduled-instance-id sci-1234-1234-1234-1234-123456789012 --instance-count 1 --launch-specification file://launch-specification.json

Launch-specification.json:

{ "ImageId": "ami-12345678", "KeyName": "my-key-pair", "SecurityGroupIds": ["sg-12345678"], "InstanceType": "c4.large", "Placement": { "AvailabilityZone": "us-west-2b" } "IamInstanceProfile": { "Name": "my-iam-role" } }

출력:

{ "InstanceIdSet": [ "i-1234567890abcdef0" ] }
PowerShell
PowerShell용 도구

예제 1:이 예제에서는 지정된 예약된 인스턴스를 시작합니다.

New-EC2ScheduledInstance -ScheduledInstanceId sci-1234-1234-1234-1234-123456789012 -InstanceCount 1 ` -IamInstanceProfile_Name my-iam-role ` -LaunchSpecification_ImageId ami-12345678 ` -LaunchSpecification_InstanceType c4.large ` -LaunchSpecification_SubnetId subnet-12345678` -LaunchSpecification_SecurityGroupId sg-12345678
  • API 세부 정보는 AWS Tools for PowerShell Cmdlet 참조RunScheduledInstances를 참조하세요.