Does anyone know how to set VirtualizationType when launching aws ec2 instance using boto3? I've tried with
session = boto3.session.Session(
aws_access_key_id=self.access_key_id,
aws_secret_access_key=self.secret_access_key,
region_name=self.region)
ec2resource = session.resource('ec2')
ec2resource.create_instances(
ImageId=ami_id, MinCount=1, MaxCount=count, KeyName=key_name,
InstanceType=type, SecurityGroups=security_groups,
VirtualizationType='paravirtual')
but got
[2016-01-15 10:54:18 CST] INFO Calling ec2:run_instances with {'VirtualizationType': 'paravirtual', 'KeyName': 'common', 'SecurityGroups': ['default'], 'MaxCount': 2, 'MinCount': 1, 'InstanceType': 'm1.small', 'ImageId': 'ami-d05e75b8'}
Traceback (most recent call last):
File "suites/ec2.py", line 21, in <module>
print ec2.launch(count=2, VirtualizationType='paravirtual')
File "/Users/bchung/Dropbox/PycharmProjects/perf/lib/aws/ec2.py", line 183, in launch
InstanceType=type, SecurityGroups=security_groups, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
response = action(self, *args, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/action.py", line 79, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 383, in _make_api_call
api_params, operation_model, context=request_context)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 425, in _convert_to_request_dict
api_params, operation_model)
File "/Library/Python/2.7/site-packages/botocore/validate.py", line 273, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError:
Parameter validation failed:
Unknown parameter in input: "VirtualizationType", must be one of:
DryRun, ImageId, MinCount, MaxCount, KeyName, SecurityGroups,
SecurityGroupIds, UserData, InstanceType, Placement, KernelId,
RamdiskId, BlockDeviceMappings, Monitoring, SubnetId,
DisableApiTermination, InstanceInitiatedShutdownBehavior,
PrivateIpAddress, ClientToken, AdditionalInfo, NetworkInterfaces,
IamInstanceProfile, EbsOptimized
I need to set VirtualizationType because I'll need some old instance types (m1.small) that only allows paravirtual instead of hvm, and it seems boto3 uses hvm by default :
Traceback (most recent call last):
File "suites/ec2.py", line 21, in <module>
print ec2.launch(count=2)
File "/Users/bchung/Dropbox/PycharmProjects/perf/lib/aws/ec2.py", line 183, in launch
InstanceType=type, SecurityGroups=security_groups, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
response = action(self, *args, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/action.py", line 79, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 396, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred
(InvalidParameterCombination) when calling the RunInstances operation:
Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type.
I checked: http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.ServiceResource.create_instances and http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.Client.run_instances
and there's no VirtualizationType in params, so I'm wondering if there's way to set or since it's going to be deprecated so boto3 just not allowing to specify this?
Any hint or suggestions are welcome, and thanks in advance!