in chalice/package.py [0:0]
def _generate_lambdafunction(self, resource, template):
# type: (models.LambdaFunction, Dict[str, Any]) -> None
resources = template['Resources']
cfn_name = self._register_cfn_resource_name(resource.resource_name)
lambdafunction_definition = {
'Type': 'AWS::Serverless::Function',
'Properties': {
'Runtime': resource.runtime,
'Handler': resource.handler,
'CodeUri': resource.deployment_package.filename,
'Tags': resource.tags,
'Tracing': resource.xray and 'Active' or 'PassThrough',
'Timeout': resource.timeout,
'MemorySize': resource.memory_size,
},
} # type: Dict[str, Any]
if resource.environment_variables:
environment_config = {
'Environment': {
'Variables': resource.environment_variables
}
} # type: Dict[str, Dict[str, Dict[str, str]]]
lambdafunction_definition['Properties'].update(environment_config)
if resource.security_group_ids and resource.subnet_ids:
vpc_config = {
'VpcConfig': {
'SecurityGroupIds': resource.security_group_ids,
'SubnetIds': resource.subnet_ids,
}
} # type: Dict[str, Dict[str, List[str]]]
lambdafunction_definition['Properties'].update(vpc_config)
if resource.reserved_concurrency is not None:
reserved_concurrency_config = {
'ReservedConcurrentExecutions': resource.reserved_concurrency
}
lambdafunction_definition['Properties'].update(
reserved_concurrency_config)
layers = list(resource.layers) or [] # type: List[Any]
if self._chalice_layer:
layers.insert(0, {'Ref': self._chalice_layer})
if layers:
layers_config = {
'Layers': layers
} # type: Dict[str, Any]
lambdafunction_definition['Properties'].update(layers_config)
resources[cfn_name] = lambdafunction_definition
self._add_iam_role(resource, resources[cfn_name])