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