From d1281ca16dc528e134a060f423fa52a7a9b80f94 Mon Sep 17 00:00:00 2001 From: goldeneggg Date: Sun, 20 Jan 2019 01:07:56 +0900 Subject: [PATCH 1/2] fix(layers): show warning if `!Sub` function is used in `Layers` section of template.yaml (#948) --- samcli/commands/local/lib/sam_function_provider.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/samcli/commands/local/lib/sam_function_provider.py b/samcli/commands/local/lib/sam_function_provider.py index 784593c3ec..65083d6490 100644 --- a/samcli/commands/local/lib/sam_function_provider.py +++ b/samcli/commands/local/lib/sam_function_provider.py @@ -238,6 +238,10 @@ def _parse_layer_info(list_of_layers, resources): """ layers = [] for layer in list_of_layers: + if isinstance(layer, dict) and layer.get("Fn::Sub"): + LOG.warning("'!Sub' keyword in Layer configuration does not work locally. " + "Please replace all parameter strings(like '${AWS::Region}') with the original value(like 'ap-northeast-1') and remove '!Sub' keyword.") + # If the layer is a string, assume it is the arn if isinstance(layer, six.string_types): layers.append(LayerVersion(layer, None)) From 00af3c34c3cfe02b6bc9b69a430c70fc5ec30945 Mon Sep 17 00:00:00 2001 From: goldeneggg Date: Sun, 20 Jan 2019 14:17:28 +0900 Subject: [PATCH 2/2] fix message --- samcli/commands/local/lib/sam_function_provider.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samcli/commands/local/lib/sam_function_provider.py b/samcli/commands/local/lib/sam_function_provider.py index 65083d6490..c8f7a8eb45 100644 --- a/samcli/commands/local/lib/sam_function_provider.py +++ b/samcli/commands/local/lib/sam_function_provider.py @@ -239,8 +239,9 @@ def _parse_layer_info(list_of_layers, resources): layers = [] for layer in list_of_layers: if isinstance(layer, dict) and layer.get("Fn::Sub"): - LOG.warning("'!Sub' keyword in Layer configuration does not work locally. " - "Please replace all parameter strings(like '${AWS::Region}') with the original value(like 'ap-northeast-1') and remove '!Sub' keyword.") + LOG.warning("'!Sub' keyword in Layer configuration does not work at local. " + "Please replace all parameter strings(like '${AWS::Region}') with the original value " + "and remove '!Sub' keyword from template.yaml .") # If the layer is a string, assume it is the arn if isinstance(layer, six.string_types):