[lambda] Do not duplicate defaults for LambdaFunction objects.
The duplication caused a bug before and this commit is a bugfix and will prevent similar bugs in the future.
This commit is contained in:
parent
45d91bf963
commit
2d744c6626
@ -96,22 +96,22 @@ class LambdaFunction(object):
|
|||||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||||
properties = cloudformation_json['Properties']
|
properties = cloudformation_json['Properties']
|
||||||
|
|
||||||
backend = lambda_backends[region_name]
|
# required
|
||||||
fn = backend.create_function({
|
spec = {
|
||||||
# required
|
|
||||||
'Code': properties['Code'],
|
'Code': properties['Code'],
|
||||||
'FunctionName': resource_name,
|
'FunctionName': resource_name,
|
||||||
'Handler': properties['Handler'],
|
'Handler': properties['Handler'],
|
||||||
'Role': properties['Role'],
|
'Role': properties['Role'],
|
||||||
'Runtime': properties['Runtime'],
|
'Runtime': properties['Runtime'],
|
||||||
|
}
|
||||||
|
optional_properties = 'Description MemorySize Publish Timeout VpcConfig'.split()
|
||||||
|
# NOTE: Not doing `properties.get(k, DEFAULT)` to avoid duplicating the default logic
|
||||||
|
for prop in optional_properties:
|
||||||
|
if prop in properties:
|
||||||
|
spec[prop] = properties[prop]
|
||||||
|
|
||||||
# optional
|
backend = lambda_backends[region_name]
|
||||||
'Description': properties.get('Description', ''),
|
fn = backend.create_function(spec)
|
||||||
'MemorySize': properties.get('MemorySize', 128),
|
|
||||||
'Publish': properties.get('Publish', False),
|
|
||||||
'Timeout': properties.get('Timeout', 3),
|
|
||||||
'VpcConfig': properties.get('VpcConfig', {}),
|
|
||||||
})
|
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user