rackerlabs / lambda-uploader

Helps package and upload Python lambda functions to AWS
Apache License 2.0
270 stars 56 forks source link

SubnetIds and SecurityIds must coexist or be both empty list. #130

Closed CosmicAnalogue465 closed 7 years ago

CosmicAnalogue465 commented 7 years ago

Hi,

We have been using lambda uploader for quite some time but we are now getting this errors:

ClientError: An error occurred (InvalidParameterValueException) when calling the UpdateFunctionConfiguration operation: SubnetIds and SecurityIds must coexist or be both empty list.

this happens after "Uploading Package" Can you help ?

martinb3 commented 7 years ago

Hi there -- can you confirm what version of lambda-uploader you are using?

runtakun commented 7 years ago

I got the same error. I confirmed version was 1.0.1. I update to 1.1.0, then It was fixed.

martinb3 commented 7 years ago

Great! I'll assume we can close this, if it's resolved in the latest version. Cheers!

runtakun commented 7 years ago

@martinb3 Sorry, but I ran lambda-uploader command twice, then I've the error.

⁉️ Unexpected error. Please report this traceback. Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/lambda_uploader/shell.py", line 182, in main _execute(args) File "/usr/local/lib/python2.7/site-packages/lambda_uploader/shell.py", line 95, in _execute upldr.upload(pkg) File "/usr/local/lib/python2.7/site-packages/lambda_uploader/uploader.py", line 140, in upload self.version = self.upload_existing(pkg) File "/usr/local/lib/python2.7/site-packages/lambda_uploader/uploader.py", line 73, in upload_existing Environment=environment, File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 537, in _make_api_call raise ClientError(parsed_response, operation_name) ClientError: An error occurred (InvalidParameterValueException) when calling the UpdateFunctionConfiguration operation: SubnetIds and SecurityIds must coexist or be both empty list.

martinb3 commented 7 years ago

@runtakun can you show us the version you're using, as well as the config file you're using?

runtakun commented 7 years ago

I confirmed its version is 1.1.0.

% lambda-uploader --version 1.1.0

configuration is:

{ "name": "xxxxxxxxxxxxx", "description": "xxxxxxxxxxxxx", "region": "ap-northeast-1", "handler": "main.xxxxxxxxxxxxx", "role": "arn:aws:iam:: xxxxxxxxxxxxx:role/lambda_basic_execution", "timeout": 300, "memory": 512 }

runtakun commented 7 years ago

I did not get the message just after I change environmental variables at AWS console page, but got it when I tried to run lambda-uploader twice.

CosmicAnalogue465 commented 7 years ago

Here is the version I am running,

lambda-uploader --version 1.1.0

The error seems to be related to the format of the "vpcConfig" attribute when it is not set. lambda-uploader sends it as {} but AWS now wants {'SubnetIds': [], 'SecurityGroupIds': []} (uploader.py line 211)

Might be a AWS bug? doc say the attribute is not required for the UpdateFunctionConfiguration function http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionConfiguration.html

CosmicAnalogue465 commented 7 years ago

{ "name": "xxxxxxxxxxxxx", "description": "xxxxxxxxxxxxxxxx", "region": "eu-west-1", "handler": "run.lambda_handler", "role": "arn:aws:iam::xxxxxxx:role/lambda_basic_execution", "ignore": [ ".git", "/*.pyc" ], "timeout": 300, "memory": 128 }

martinb3 commented 7 years ago

Hmmm. I suppose it's possible AWS is requiring these now. You're definitely not updating functions that are already assigned to a VPC, right?

CosmicAnalogue465 commented 7 years ago

No, my function never had a VPC assigned

jarosser06 commented 7 years ago

I'm unable to reproduce that issue on my end. I'm using 1.1.0, I created a new function and then updated that same function and the upload is working correctly. I also tried setting the VPC information in the console and then updating the function again and I'm still not receiving an error. I am doing this in the eu-west-1 region as well just in case there might be some discrepancies between the regions.

Can you run this in debug "-VV" and provide the output. I am specifically looking for the request body for the update_function_configuration which should look like the following.

DEBUG:botocore.endpoint:Making request for OperationModel(name=UpdateFunctionConfiguration) (verify_ssl=True) with params: {'body': '{"Description": "myfunc", "Vp
cConfig": {}, "MemorySize": 512, "Environment": {"Variables": {}}, "Handler": "function.lambda_handler", "Role": "arn:aws:iam::REDACTED:role/lambda_basic_exec
ution", "Timeout": 30}', 'url': u'https://lambda.eu-west-1.amazonaws.com/2015-03-31/functions/myFunc/configuration', 'headers': {'User-Agent': 'Boto3/1.4.2 Python
/2.7.12 Darwin/16.3.0 Botocore/1.4.93'}, 'context': {'client_region': u'eu-west-1', 'has_streaming_input': False, 'client_config': <botocore.config.Config object
at 0x10f3bb910>}, 'query_string': {}, 'url_path': u'/2015-03-31/functions/myFunc/configuration', 'method': u'PUT'}
CosmicAnalogue465 commented 7 years ago

Running it today doesn't yield the error anymore...

DEBUG:botocore.endpoint:Making request for OperationModel(name=UpdateFunctionConfiguration) (verify_ssl=True) with params: {'body': '{"Description": "xxxx", "VpcConfig": {}, "MemorySize": 128, "Environment": {"Variables": {}}, "Handler": "run.lambda_handler", "Role": "arn:aws:iam::xxx:role/lambda_basic_execution", "Timeout": 300}', 'url': u'https://lambda.eu-west-1.amazonaws.com/2015-03-31/functions/xxxx/configuration', 'headers': {'User-Agent': 'Boto3/1.4.3 Python/2.7.10 Darwin/15.6.0 Botocore/1.4.93'}, 'context': {'client_region': u'eu-west-1', 'has_streaming_input': False, 'client_config': <botocore.config.Config object at 0x106133dd0>}, 'query_string': {}, 'url_path': u'/2015-03-31/functions/xxxx/configuration', 'method': u'PUT'}

As you can see the VpcConfig is set to {} but yesterday had to be set to {'SubnetIds': [], 'SecurityGroupIds': []}

ryandub commented 7 years ago

It appears that the API issue is off and on - we have seen it come and go in us-east-1 today, but other regions are fine. I submitted a patch in #132 which should fix the issue across the board along with a link to the AWS dev forum where the issue is being discussed.