From 84ac256167804473eb6c4a7b10f0a701a9320572 Mon Sep 17 00:00:00 2001 From: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Date: Thu, 6 Oct 2022 11:22:27 -0700 Subject: [PATCH] feat: add _link_lambda_function_to_layer function stub (#4280) * add _link_lambda_function_to_layer function stub * fix lint error --- .../hooks/prepare/resource_linking.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py b/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py index 32c31af576..ff5c139aee 100644 --- a/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py +++ b/samcli/hook_packages/terraform/hooks/prepare/resource_linking.py @@ -597,3 +597,26 @@ def _resolve_resource_attribute( else: results.append(ResolvedReference(reference, resource.module.full_address)) return results + + +def _link_lambda_function_to_layer( + function_tf_resource: TFResource, cfn_functions: List[Dict], tf_layers: Dict[str, Dict] +) -> None: + """ + Resolve the lambda layer for the input lambda function configuration resource, and then update the equivalent cfn + lambda functions list. + The Lambda configuration resource in Terraform can match multiple actual resources in case if it was defined using + count or for_each pattern. + + Parameters + ---------- + function_tf_resource: TFResource + The input lambda function terraform configuration resource + + cfn_functions: List[Dict] + A list of mapped lambda functions that are equivalent to the input terraform configuration lambda function + + tf_layers: Dict[str, Dict] + Dictionary of all actual terraform layers resources (not configuration resources). The dictionary's key is the + calculated logical id for each resource + """