boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
8.97k stars 1.86k forks source link

unknown parameter InterfaceType in Network Interfaces #2138

Closed Satish615 closed 4 years ago

Satish615 commented 5 years ago

I am trying to launch a new instance with EFA support https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-working-with.html using boto3. I am getting the below error.

Unknown parameter in NetworkInterfaces[0]: "InterfaceType", must be one of: AssociatePublicIpAddress, DeleteOnTermination, Description, DeviceIndex, Groups, Ipv6AddressCount, Ipv6Addresses, NetworkInterfaceId, PrivateIpAddress, PrivateIpAddresses, SecondaryPrivateIpAddressCount, SubnetId

These are debug logs generated for the issue.


3.6.5
1.9.233
2019-09-23 05:31:24,874 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-09-23 05:31:24,878 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
2019-09-23 05:31:24,878 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-09-23 05:31:24,881 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-09-23 05:31:24,881 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-09-23 05:31:24,881 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-09-23 05:31:24,882 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-09-23 05:31:24,885 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-09-23 05:31:24,885 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-09-23 05:31:24,885 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-09-23 05:31:24,886 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-09-23 05:31:24,886 botocore.session [DEBUG] Setting config variable for region to 'us-east-1'
2019-09-23 05:31:24,903 botocore.loaders [DEBUG] Loading JSON file: /home/sgollapr/.local/lib/python3.6/site-packages/boto3/data/ec2/2016-11-15/resources-1.json
2019-09-23 05:31:24,909 botocore.credentials [DEBUG] Looking for credentials via: env
2019-09-23 05:31:24,909 botocore.credentials [DEBUG] Looking for credentials via: assume-role
2019-09-23 05:31:24,910 botocore.credentials [DEBUG] Looking for credentials via: assume-role-with-web-identity
2019-09-23 05:31:24,910 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
2019-09-23 05:31:24,910 botocore.credentials [INFO] Found credentials in shared credentials file: ~/.aws/credentials
2019-09-23 05:31:24,910 botocore.loaders [DEBUG] Loading JSON file: /home/sgollapr/.local/lib/python3.6/site-packages/botocore/data/endpoints.json
2019-09-23 05:31:24,916 botocore.hooks [DEBUG] Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f7de0112620>
2019-09-23 05:31:24,921 botocore.loaders [DEBUG] Loading JSON file: /home/sgollapr/.aws/models/ec2/2016-11-15/service-2.json
2019-09-23 05:31:24,944 botocore.hooks [DEBUG] Event creating-client-class.ec2: calling handler <function add_generate_presigned_url at 0x7f7de0bfb0d0>
2019-09-23 05:31:24,945 botocore.args [DEBUG] The s3 config key is not a dictionary type, ignoring its value of: None
2019-09-23 05:31:24,947 botocore.endpoint [DEBUG] Setting ec2 timeout as (60, 60)
2019-09-23 05:31:24,948 botocore.loaders [DEBUG] Loading JSON file: /home/sgollapr/.local/lib/python3.6/site-packages/botocore/data/_retry.json
2019-09-23 05:31:24,949 botocore.client [DEBUG] Registering retry handlers for service: ec2
2019-09-23 05:31:24,949 boto3.resources.factory [DEBUG] Loading ec2:ec2
2019-09-23 05:31:24,954 botocore.hooks [DEBUG] Event creating-resource-class.ec2.ServiceResource: calling handler <function lazy_call.<locals>._handler at 0x7f7de00306a8>
2019-09-23 05:31:24,954 boto3.resources.action [DEBUG] Calling ec2:run_instances with {'ImageId': 'ami-0da5089baf511b65f', 'InstanceType': 'p3dn.24xlarge', 'MinCount': 1, 'MaxCount': 1, 'SecurityGroupIds': [], 'KeyName': 'deeplearning-ami-beta', 'NetworkInterfaces': [{'SubnetId': 'subnet-8de3e7d6', 'DeviceIndex': 0, 'DeleteOnTermination': True, 'InterfaceType': 'efa', 'Groups': ['sg-ada32ad2', 'sg-0ccf7f66148293d8a']}]}
2019-09-23 05:31:24,954 botocore.hooks [DEBUG] Event before-parameter-build.ec2.RunInstances: calling handler <bound method ParameterAlias.alias_parameter_in_call of <botocore.handlers.ParameterAlias object at 0x7f7de012d748>>
2019-09-23 05:31:24,955 botocore.hooks [DEBUG] Event before-parameter-build.ec2.RunInstances: calling handler <function base64_encode_user_data at 0x7f7de012b840>
2019-09-23 05:31:24,955 botocore.hooks [DEBUG] Event before-parameter-build.ec2.RunInstances: calling handler <function generate_idempotent_uuid at 0x7f7de012a950>
Traceback (most recent call last):
  File "launch.py", line 30, in <module>
    instances = ec2.create_instances(**args)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/botocore/client.py", line 634, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/botocore/client.py", line 682, in _convert_to_request_dict
    api_params, operation_model)
  File "/home/sgollapr/.local/lib/python3.6/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in NetworkInterfaces[0]: "InterfaceType", must be one of: AssociatePublicIpAddress, DeleteOnTermination, Description, DeviceIndex, Groups, Ipv6AddressCount, Ipv6Addresses, NetworkInterfaceId, PrivateIpAddress, PrivateIpAddresses, SecondaryPrivateIpAddressCount, SubnetId```

The script works fine when i use without the InterfaceType parameter. I am using latest version of boto3
Satish615 commented 5 years ago

This is code snippet i am using to test the ec2-launch.


import boto3
import platform
print(platform.python_version())

print(boto3.__version__)
instance_type='c5.18xlarge'
boto3.set_stream_logger('')

subnet_id='subnet-8de3e7d6'
name='efa-programmatic'
image_id='ami-0da5089baf511b65f'
security_group_id='sg-ada32ad2'
security_id2='sg-0ccf7f66148293d8a'

args = {'ImageId': image_id,
        'InstanceType': instance_type,
        'MinCount': 1,
        'MaxCount': 1,
        'SecurityGroupIds': [],
        'KeyName': 'deeplearning-ami-beta'}

args['NetworkInterfaces'] = [{'SubnetId': subnet_id,
                               'DeviceIndex': 0,
                               'DeleteOnTermination': True,
                               'InterfaceType':'efa',
                               'Groups': [security_group_id,security_id2]}]
placement_specs = {'AvailabilityZone': 'us-east-1d'}

ec2 = boto3.Session(region_name='us-east-1').resource('ec2')
instances = ec2.create_instances(**args)```
swetashre commented 5 years ago

@Satish615 - Thank you for your post. I am not getting the same error when i run your code. Can you please verify which version of botocore you are using ? This error comes from botocore so please make sure you are not using older version of botocore.

no-response[bot] commented 4 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Satish615 commented 4 years ago

Thank you for your response!. Since the script runs fine in other instances I have debugged on my desktop and found out the AWS_DATA_PATH env variable is being set to /home//.aws/models/ec2 that has older version of service-2.json schema. The code works fine after I removed the old service-2.json. I hope this saves sometime if anyone faces this issue with latest boto3 version.