Complete the code to specify the EC2 pricing model for an on-demand instance.
ec2_client.run_instances(InstanceType='t2.micro', MinCount=1, MaxCount=1, [1]={'MarketType':'on-demand'})
The InstanceMarketOptions parameter is used to specify the pricing model such as {'MarketType':'on-demand'} or {'MarketType':'spot'} when launching an EC2 instance.
Complete the code to request a spot instance using the correct market option.
ec2_client.run_instances(InstanceType='t3.medium', MinCount=1, MaxCount=1, InstanceMarketOptions={'MarketType': [1])
To request a spot instance, the MarketType must be set to 'spot' in the InstanceMarketOptions.
Fix the error in the code to correctly specify a reserved instance purchase option.
ec2_client.purchase_reserved_instances_offering(ReservedInstancesOfferingId='abc123', [1]=1)
The correct parameter to specify the number of reserved instances to purchase is Quantity.
Fill both blanks to configure a spot instance with a maximum price and interruption behavior.
ec2_client.run_instances(InstanceType='t3.large', MinCount=1, MaxCount=1, InstanceMarketOptions={'MarketType':'spot', 'SpotOptions':{'MaxPrice': [1], '[2]':'terminate'}})
The MaxPrice in SpotOptions sets the max price you are willing to pay, and InstanceInterruptionBehavior defines what happens when the spot instance is interrupted.
Fill all three blanks to create a dictionary that maps instance types to their pricing models.
pricing_map = [1](instance_type: [2] for instance_type, [3] in instances.items())
This dictionary comprehension creates a dict mapping each instance type to the string 'on-demand' using the variable pricing_model for the value.