Spot Instance 요청 예시 시작 사양

Spot Instance 요청 예시 시작 사양

다음 예시들은 request-spot-instances 명령과 함께 사용할 수 있는 시작 구성(configuration)을 보여줘요. 자세한 내용은 Manage your Spot Instances를 참고하세요. 이 절에서는 Spot Instance 요청을 위한 다양한 시작 사양 예시를 소개할게요.

출처: 문서

본문

다음 예시들은 request-spot-instances 명령으로 Spot Instance 요청을 만들 때 사용할 수 있는 시작 구성(configuration)이에요. 자세한 내용은 Manage your Spot Instances을 참고하세요.

중요

request-spot-instances 명령은 투자 계획이 없는 레거시 API이므로, 이 명령으로 Spot Instance를 요청하는 것은 강력히 권장하지 않아요. 자세한 내용은 Which is the best Spot request method to use?를 참고하세요.

예시 1: Spot Instance 시작하기

다음 예시는 가용 영역이나 서브넷을 포함하지 않아요. Amazon EC2가 가용 영역을 선택해 줘요. Amazon EC2는 선택된 가용 영역의 기본 서브넷에서 인스턴스를 시작해요.

{
  "ImageId": "ami-0abcdef1234567890",
  "KeyName": "my-key-pair",
  "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ],
  "InstanceType": "m5.medium",
  "IamInstanceProfile": {
    "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role"
  }
}

예시 2: 지정된 가용 영역에서 Spot Instance 시작하기

다음 예시는 가용 영역을 포함해요. Amazon EC2는 지정된 가용 영역의 기본 서브넷에서 인스턴스를 시작해요.

{
  "ImageId": "ami-0abcdef1234567890",
  "KeyName": "my-key-pair",
  "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ],
  "InstanceType": "m5.medium",
  "Placement": {
    "AvailabilityZone": "us-west-2a"
  },
  "IamInstanceProfile": {
    "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role"
  }
}

예시 3: 지정된 서브넷에서 Spot Instance 시작하기

다음 예시는 서브넷을 포함해요. Amazon EC2는 지정된 서브넷에서 인스턴스를 시작해요. VPC가 기본이 아닌 VPC(nondefault)라면 인스턴스는 기본적으로 공용 IPv4 주소를 받지 못해요.

{
  "ImageId": "ami-0abcdef1234567890",
  "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ],
  "InstanceType": "m5.medium",
  "SubnetId": "subnet-1a2b3c4d",
  "IamInstanceProfile": {
    "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role"
  }
}

기본이 아닌 VPC의 인스턴스에 공용 IPv4 주소를 할당하려면 다음 예시처럼 AssociatePublicIpAddress 필드를 지정하세요. 네트워크 인터페이스를 지정할 때는 이전 코드 블록에서 본 SubnetId와 SecurityGroupIds 필드 대신, 네트워크 인터페이스를 사용해 서브넷 ID와 보안 그룹 ID를 포함해야 해요.

{
  "ImageId": "ami-0abcdef1234567890",
  "KeyName": "my-key-pair",
  "InstanceType": "m5.medium",
  "NetworkInterfaces": [
    {
      "DeviceIndex": 0,
      "SubnetId": "subnet-1a2b3c4d5e6f7g8h9",
      "Groups": [ "sg-1a2b3c4d5e6f7g8h9" ],
      "AssociatePublicIpAddress": true
    }
  ],
  "IamInstanceProfile": {
    "Arn": "arn:aws:iam::123456789012:instance-profile/my-iam-role"
  }
}

예시 4: Dedicated Spot Instance 시작하기

다음 예시는 테넌시가 dedicated인 Spot Instance를 요청해요. Dedicated Spot Instance는 VPC에서 시작해야 해요.

{
  "ImageId": "ami-0abcdef1234567890",
  "KeyName": "my-key-pair",
  "SecurityGroupIds": [ "sg-1a2b3c4d5e6f7g8h9" ],
  "InstanceType": "c5.8xlarge",
  "SubnetId": "subnet-1a2b3c4d5e6f7g8h9",
  "Placement": {
    "Tenancy": "dedicated"
  }
}

더 알아보기