Because the documentation for the version 2 SDK has made this incredibly unclear, here you go.

ec2 = Aws::EC2::Client.new(region: 'us-west-2')
res = Aws::EC2::Resource.new(client: ec2)

#remove dry_run: true from the parameters to actually create an instance
inst = res.create_instances(image_id:'ami-123456', min_count:1, max_count:1, instance_type: 't1.micro', dry_run: true)

Some helpful methods on the instance returned:
inst.public_ip_address
inst.state
inst.data
To stop the instance:
ec2.stop_instances(instance_ids:[inst.id])

To start the instance after stopping:
ec2.start_instances(instance_ids:[inst.id])

To terminate the instance:
ec2.terminate_instances(instance_ids:[inst.id])
Advertisements