Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,17 @@ def _construct_version(self, function, intrinsics_resolver):
# SHA Collisions: For purposes of triggering a new update, we are concerned about just the difference previous
# and next hashes. The chances that two subsequent hashes collide is fairly low.
prefix = "{id}Version".format(id=self.logical_id)
logical_id = logical_id_generator.LogicalIdGenerator(prefix, code_dict).gen()
logical_dict = {}
try:
logical_dict = code_dict.copy()
except (AttributeError, UnboundLocalError):
pass
else:
if function.Environment:
logical_dict.update(function.Environment)
if function.MemorySize:
logical_dict.update({'MemorySize': function.MemorySize})
logical_id = logical_id_generator.LogicalIdGenerator(prefix, logical_dict).gen()

attributes = self.get_passthrough_resource_attributes()
if attributes is None:
Expand Down
8 changes: 4 additions & 4 deletions tests/translator/output/aws-cn/globals_for_function.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"FunctionWithOverridesVersion640128d35d",
"FunctionWithOverridesVersion096ed3b52b",
"Version"
]
},
Expand Down Expand Up @@ -211,7 +211,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"MinimalFunctionVersionfb7aeaa544",
"MinimalFunctionVersion0a06fc8fb1",
"Version"
]
},
Expand All @@ -221,7 +221,7 @@
"Name": "live"
}
},
"FunctionWithOverridesVersion640128d35d": {
"FunctionWithOverridesVersion096ed3b52b": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand All @@ -230,7 +230,7 @@
}
}
},
"MinimalFunctionVersionfb7aeaa544": {
"MinimalFunctionVersion0a06fc8fb1": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"FunctionWithOverridesVersion640128d35d",
"FunctionWithOverridesVersion096ed3b52b",
"Version"
]
},
Expand Down Expand Up @@ -211,7 +211,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"MinimalFunctionVersionfb7aeaa544",
"MinimalFunctionVersion0a06fc8fb1",
"Version"
]
},
Expand All @@ -221,7 +221,7 @@
"Name": "live"
}
},
"FunctionWithOverridesVersion640128d35d": {
"FunctionWithOverridesVersion096ed3b52b": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand All @@ -230,7 +230,7 @@
}
}
},
"MinimalFunctionVersionfb7aeaa544": {
"MinimalFunctionVersion0a06fc8fb1": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand Down
8 changes: 4 additions & 4 deletions tests/translator/output/globals_for_function.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"FunctionWithOverridesVersion640128d35d",
"FunctionWithOverridesVersion096ed3b52b",
"Version"
]
},
Expand Down Expand Up @@ -211,7 +211,7 @@
"Properties": {
"FunctionVersion": {
"Fn::GetAtt": [
"MinimalFunctionVersionfb7aeaa544",
"MinimalFunctionVersion0a06fc8fb1",
"Version"
]
},
Expand All @@ -221,7 +221,7 @@
"Name": "live"
}
},
"FunctionWithOverridesVersion640128d35d": {
"FunctionWithOverridesVersion096ed3b52b": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand All @@ -230,7 +230,7 @@
}
}
},
"MinimalFunctionVersionfb7aeaa544": {
"MinimalFunctionVersion0a06fc8fb1": {
"DeletionPolicy": "Retain",
"Type": "AWS::Lambda::Version",
"Properties": {
Expand Down