[lambda] Add VpcConfig to the responses
This commit is contained in:
parent
5f7ea2b77f
commit
7c36fca1dd
@ -23,7 +23,9 @@ class LambdaFunction(object):
|
||||
self.memory_size = spec.get('MemorySize', 128)
|
||||
self.publish = spec.get('Publish', False) # this is ignored currently
|
||||
self.timeout = spec.get('Timeout', 3)
|
||||
self.vpc_config = spec.get('VpcConfig', {})
|
||||
|
||||
# this isn't finished yet. it needs to find out the VpcId value
|
||||
self._vpc_config = spec.get('VpcConfig', {'SubnetIds': [], 'SecurityGroupIds': []})
|
||||
|
||||
# auto-generated
|
||||
self.version = '$LATEST'
|
||||
@ -37,6 +39,13 @@ class LambdaFunction(object):
|
||||
self.code_sha_256 = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
self.function_arn = 'arn:aws:lambda:123456789012:function:{}'.format(self.function_name)
|
||||
|
||||
@property
|
||||
def vpc_config(self):
|
||||
config = self._vpc_config.copy()
|
||||
if config['SecurityGroupIds']:
|
||||
config.update({"VpcId": "vpc-123abc"})
|
||||
return config
|
||||
|
||||
def __repr__(self):
|
||||
return json.dumps(self.get_configuration())
|
||||
|
||||
|
@ -6,4 +6,5 @@ coverage
|
||||
freezegun
|
||||
flask
|
||||
boto3>=1.2.3
|
||||
botocore>=1.3.26
|
||||
six
|
@ -37,12 +37,10 @@ def test_create_function_from_aws_bucket():
|
||||
Timeout=3,
|
||||
MemorySize=128,
|
||||
Publish=True,
|
||||
# boto3 doesnt support it
|
||||
# VpcConfig={
|
||||
# "SecurityGroupIds": ["sg-123abc"],
|
||||
# "SubnetIds": ["subnet-123abc"],
|
||||
# "VpcId": "vpc-123abc"
|
||||
# },
|
||||
VpcConfig={
|
||||
"SecurityGroupIds": ["sg-123abc"],
|
||||
"SubnetIds": ["subnet-123abc"],
|
||||
},
|
||||
)
|
||||
result.should.equal({
|
||||
'FunctionName': 'testFunction',
|
||||
@ -57,12 +55,11 @@ def test_create_function_from_aws_bucket():
|
||||
'LastModified': '2015-01-01 00:00:00',
|
||||
'CodeSha256': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
'Version': '$LATEST',
|
||||
# boto3 doesnt support it
|
||||
# VpcConfig={
|
||||
# "SecurityGroupIds": ["sg-123abc"],
|
||||
# "SubnetIds": ["subnet-123abc"],
|
||||
# "VpcId": "vpc-123abc"
|
||||
# },
|
||||
'VpcConfig': {
|
||||
"SecurityGroupIds": ["sg-123abc"],
|
||||
"SubnetIds": ["subnet-123abc"],
|
||||
"VpcId": "vpc-123abc"
|
||||
},
|
||||
|
||||
'ResponseMetadata': {'HTTPStatusCode': 201},
|
||||
})
|
||||
@ -93,12 +90,6 @@ def handler(event, context):
|
||||
Timeout=3,
|
||||
MemorySize=128,
|
||||
Publish=True,
|
||||
# boto3 doesnt support it
|
||||
# VpcConfig={
|
||||
# "SecurityGroupIds": ["sg-123abc"],
|
||||
# "SubnetIds": ["subnet-123abc"],
|
||||
# "VpcId": "vpc-123abc"
|
||||
# },
|
||||
)
|
||||
result.should.equal({
|
||||
'FunctionName': 'testFunction',
|
||||
@ -113,12 +104,10 @@ def handler(event, context):
|
||||
'LastModified': '2015-01-01 00:00:00',
|
||||
'CodeSha256': hashlib.sha256(zip_content).hexdigest(),
|
||||
'Version': '$LATEST',
|
||||
# boto3 doesnt support it
|
||||
# VpcConfig={
|
||||
# "SecurityGroupIds": ["sg-123abc"],
|
||||
# "SubnetIds": ["subnet-123abc"],
|
||||
# "VpcId": "vpc-123abc"
|
||||
# },
|
||||
'VpcConfig': {
|
||||
"SecurityGroupIds": [],
|
||||
"SubnetIds": [],
|
||||
},
|
||||
|
||||
'ResponseMetadata': {'HTTPStatusCode': 201},
|
||||
})
|
||||
@ -164,15 +153,10 @@ def test_get_function():
|
||||
"Runtime": "python2.7",
|
||||
"Timeout": 3,
|
||||
"Version": '$LATEST',
|
||||
# "VpcConfig": {
|
||||
# "SecurityGroupIds": [
|
||||
# "string"
|
||||
# ],
|
||||
# "SubnetIds": [
|
||||
# "string"
|
||||
# ],
|
||||
# "VpcId": "string"
|
||||
# }
|
||||
"VpcConfig": {
|
||||
"SecurityGroupIds": [],
|
||||
"SubnetIds": [],
|
||||
}
|
||||
},
|
||||
'ResponseMetadata': {'HTTPStatusCode': 200},
|
||||
})
|
||||
@ -250,15 +234,10 @@ def test_list_create_list_get_delete_list():
|
||||
"Runtime": "python2.7",
|
||||
"Timeout": 3,
|
||||
"Version": '$LATEST',
|
||||
# "VpcConfig": {
|
||||
# "SecurityGroupIds": [
|
||||
# "string"
|
||||
# ],
|
||||
# "SubnetIds": [
|
||||
# "string"
|
||||
# ],
|
||||
# "VpcId": "string"
|
||||
# }
|
||||
"VpcConfig": {
|
||||
"SecurityGroupIds": [],
|
||||
"SubnetIds": [],
|
||||
}
|
||||
},
|
||||
'ResponseMetadata': {'HTTPStatusCode': 200},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user