in chalice/awsclient.py [0:0]
def create_function(self,
function_name, # type: str
role_arn, # type: str
zip_contents, # type: str
runtime, # type: str
handler, # type: str
environment_variables=None, # type: StrMap
tags=None, # type: StrMap
xray=None, # type: Optional[bool]
timeout=None, # type: OptInt
memory_size=None, # type: OptInt
security_group_ids=None, # type: OptStrList
subnet_ids=None, # type: OptStrList
layers=None, # type: OptStrList
):
# pylint: disable=too-many-locals
# type: (...) -> str
kwargs = {
'FunctionName': function_name,
'Runtime': runtime,
'Code': {'ZipFile': zip_contents},
'Handler': handler,
'Role': role_arn,
} # type: Dict[str, Any]
if environment_variables is not None:
kwargs['Environment'] = {"Variables": environment_variables}
if tags is not None:
kwargs['Tags'] = tags
if xray is True:
kwargs['TracingConfig'] = {'Mode': 'Active'}
if timeout is not None:
kwargs['Timeout'] = timeout
if memory_size is not None:
kwargs['MemorySize'] = memory_size
if security_group_ids is not None and subnet_ids is not None:
kwargs['VpcConfig'] = self._create_vpc_config(
security_group_ids=security_group_ids,
subnet_ids=subnet_ids,
)
if layers is not None:
kwargs['Layers'] = layers
arn, state = self._create_lambda_function(kwargs)
# Avoid the GetFunctionConfiguration call unless
# we're not immediately active.
if state != 'Active':
self._wait_for_active(function_name)
return arn