EC2


What?
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.

How?
To start using EC2 you need to do the following step
1..Sign Up for AWS
2..Create an IAM User
3..Create a Key Pair
4..Create a Virtual Private Cloud (VPC
5..Create a Security Group


When?
If you need server in few minute .without investing too much in infra.. you will get monthly bill what you used .. so you can easily plan for your future need ..

Below is example of create EC2 by Cloudformation
Create EC2 instance (use https://onlineyamltools.com/prettify-yaml for formating the below yml )
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
  Properties:
    AvailabilityZone: us-east-1a
    ImageId: ami-a4c7edb2
    InstanceType: t2.micro