A Spot Instance is an unused EC2 instance that is available for less than the On-Demand price. To use Spot Instances, you create a Spot Instance request that includes the number of instances, the instance type, the Availability Zone, and the maximum price per instance hour. The hourly price for a Spot Instance is called a Spot price.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. and navigate to services then EC2 or you can select EC2 from your recent services.
In EC2 dashboard, under instances select Spot requests.
Click Request Spot Instance.
Select the task you need , here we are selecting load balancing.
Scroll down and configure your instances:
- Select Launch template you can either choose default template or create your own.
- Select AMI, choose one of the basic AMIs provided by AWS or choose Search AMI to specify your own AMI.
- Select Network, you can select an existing VPC or create a new one.
- Select Availability Zone, the default is (no preference) to let AWS choose the Availability Zones for your Spot Instances but If you can specify specific Availability Zones.
- Add Key pair name, you can select existing key pair or create a new key pair.
Now come to Additional configurations :
- Select EBS volume, To add storage, specify additional instance store volumes or EBS volumes, depending on the instance type. You can also enable Amazon EBS optimization.
- You can select Instance store, it provides temporary block-level storages for instances. The data on an instance store volume persists only during the life of the associated instance.
- Select monitoring, by default the basic monitoring is enabled for your instances. To enable detailed monitoring you can choose Enable CloudWatch detailed monitoring.
- Select Tenancy, it enables you to choose to run your instances on physical servers fully dedicated for your use (dedicated) or on (default) a shared hardware.
- Select Security groups, it is a set of firewall rules that control the traffic for your instance. You can select default, existing security groups or you can create a new security group.
- To connect to your instances, enable Auto-assign IPv4 Public IP.
IAM instance profile, to launch your Spot Instances with an IAM role you can specify the role or select default.
- User-Data, it enables you to configure an instance or run a configuration script during launch.
- Select instance tag, to add a tag, choose Add new tag and type the key and value for the tag or you can skip this.
Now select Target capacity, the number of instances you would like to launch.
Maintain target behavior, set behavior of your spot instance when your maximum price has been exceeded. Default is to terminate the instance. You can also select to stop your instance, that would costs you additional charges for storing your instance state, but will allow it to continue once your request can be satisfied again. You need an EBS backed AMI to be able to stop spot request.
Fleet request settings, you can either go with the recommendations or you can select instance types by your own.
Fleet Allocation Strategy, you can select diversified it fulfills your capacity request using a diverse set of instance pools from your fleet or Lowest price, the Spot Instances come from the pool with the lowest price. This is the default strategy.
Additional request details, here we can select IAM fleet role, you can set maximum price for spot instance per hour, create a terminating request and configure load balancing. Here we are leaving it as default.
To download a copy of the launch configuration for use with the AWS CLI, choose JSON config. and finally launch your instance.
You will get a confirmation message that your Spot instance request successfully created click OK and you will be redirected to your Spot instance request page