Skip to content

Commit ed2f24e

Browse files
authored
fix: Enhance CompatibleRuntimes property of AWS::Serverless::LayerVersion (#1683)
1 parent 8b3ea4f commit ed2f24e

File tree

6 files changed

+134
-4
lines changed

6 files changed

+134
-4
lines changed

samtranslator/model/lambda_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class LambdaLayerVersion(Resource):
107107
"Content": PropertyType(True, is_type(dict)),
108108
"Description": PropertyType(False, is_str()),
109109
"LayerName": PropertyType(False, is_str()),
110-
"CompatibleRuntimes": PropertyType(False, list_of(is_str())),
110+
"CompatibleRuntimes": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
111111
"LicenseInfo": PropertyType(False, is_str()),
112112
}
113113

samtranslator/model/sam_resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SamFunction(SamResourceMacro):
6666
"VpcConfig": PropertyType(False, is_type(dict)),
6767
"Role": PropertyType(False, is_str()),
6868
"AssumeRolePolicyDocument": PropertyType(False, is_type(dict)),
69-
"Policies": PropertyType(False, one_of(is_str(), list_of(one_of(is_str(), is_type(dict), is_type(dict))))),
69+
"Policies": PropertyType(False, one_of(is_str(), is_type(dict), list_of(one_of(is_str(), is_type(dict))))),
7070
"PermissionsBoundary": PropertyType(False, is_str()),
7171
"Environment": PropertyType(False, dict_of(is_str(), is_type(dict))),
7272
"Events": PropertyType(False, dict_of(is_str(), is_type(dict))),
@@ -1015,7 +1015,7 @@ class SamLayerVersion(SamResourceMacro):
10151015
"LayerName": PropertyType(False, one_of(is_str(), is_type(dict))),
10161016
"Description": PropertyType(False, is_str()),
10171017
"ContentUri": PropertyType(True, one_of(is_str(), is_type(dict))),
1018-
"CompatibleRuntimes": PropertyType(False, list_of(is_str())),
1018+
"CompatibleRuntimes": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
10191019
"LicenseInfo": PropertyType(False, is_str()),
10201020
"RetentionPolicy": PropertyType(False, is_str()),
10211021
}
@@ -1120,7 +1120,7 @@ class SamStateMachine(SamResourceMacro):
11201120
"Name": PropertyType(False, is_str()),
11211121
"Type": PropertyType(False, is_str()),
11221122
"Tags": PropertyType(False, is_type(dict)),
1123-
"Policies": PropertyType(False, one_of(is_str(), list_of(one_of(is_str(), is_type(dict), is_type(dict))))),
1123+
"Policies": PropertyType(False, one_of(is_str(), is_type(dict), list_of(one_of(is_str(), is_type(dict))))),
11241124
}
11251125
event_resolver = ResourceTypeResolver(samtranslator.model.stepfunctions.events,)
11261126

tests/translator/input/layers_with_intrinsics.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Parameters:
77
Default: MIT-0 License
88
LayerRuntimeList:
99
Type: CommaDelimitedList
10+
LayerRuntimeRefString:
11+
Type: String
12+
Default: SomeRuntimeName
1013

1114
Resources:
1215
LayerWithLicenseIntrinsic:
@@ -22,6 +25,21 @@ Resources:
2225
CompatibleRuntimes:
2326
Ref: LayerRuntimeList
2427

28+
LayerWithSingleListRefRuntimesIntrinsic:
29+
Type: 'AWS::Serverless::LayerVersion'
30+
Properties:
31+
ContentUri: s3://sam-demo-bucket/layer.zip
32+
CompatibleRuntimes:
33+
- Ref: LayerRuntimeRefString
34+
35+
LayerWithMixedListRefRuntimesIntrinsic:
36+
Type: 'AWS::Serverless::LayerVersion'
37+
Properties:
38+
ContentUri: s3://sam-demo-bucket/layer.zip
39+
CompatibleRuntimes:
40+
- Ref: LayerRuntimeString
41+
- 'SomeRuntimeNameString'
42+
2543
LayerWithNameIntrinsic:
2644
Type: AWS::Serverless::LayerVersion
2745
Properties:
@@ -46,3 +64,4 @@ Resources:
4664
ContentUri: s3://sam-demo-bucket/layer.zip
4765
LayerName: !Sub 'layer-${AWS::Region}'
4866

67+

tests/translator/output/aws-cn/layers_with_intrinsics.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"LayerNameParam": {
1111
"Default": "SomeLayerName",
1212
"Type": "String"
13+
},
14+
"LayerRuntimeRefString": {
15+
"Default": "SomeRuntimeName",
16+
"Type": "String"
1317
}
1418
},
1519
"Resources": {
@@ -62,6 +66,39 @@
6266
}
6367
}
6468
},
69+
"LayerWithSingleListRefRuntimesIntrinsic9d7a72f24a": {
70+
"DeletionPolicy": "Retain",
71+
"Properties": {
72+
"CompatibleRuntimes": [
73+
{
74+
"Ref": "LayerRuntimeRefString"
75+
}
76+
],
77+
"Content": {
78+
"S3Bucket": "sam-demo-bucket",
79+
"S3Key": "layer.zip"
80+
},
81+
"LayerName": "LayerWithSingleListRefRuntimesIntrinsic"
82+
},
83+
"Type": "AWS::Lambda::LayerVersion"
84+
},
85+
"LayerWithMixedListRefRuntimesIntrinsic71fd80f592": {
86+
"DeletionPolicy": "Retain",
87+
"Properties": {
88+
"CompatibleRuntimes": [
89+
{
90+
"Ref": "LayerRuntimeString"
91+
},
92+
"SomeRuntimeNameString"
93+
],
94+
"Content": {
95+
"S3Bucket": "sam-demo-bucket",
96+
"S3Key": "layer.zip"
97+
},
98+
"LayerName": "LayerWithMixedListRefRuntimesIntrinsic"
99+
},
100+
"Type": "AWS::Lambda::LayerVersion"
101+
},
65102
"LayerWithLicenseIntrinsic965c8d0c9b": {
66103
"DeletionPolicy": "Retain",
67104
"Type": "AWS::Lambda::LayerVersion",

tests/translator/output/aws-us-gov/layers_with_intrinsics.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"LayerNameParam": {
1111
"Default": "SomeLayerName",
1212
"Type": "String"
13+
},
14+
"LayerRuntimeRefString": {
15+
"Default": "SomeRuntimeName",
16+
"Type": "String"
1317
}
1418
},
1519
"Resources": {
@@ -62,6 +66,39 @@
6266
}
6367
}
6468
},
69+
"LayerWithSingleListRefRuntimesIntrinsic9d7a72f24a": {
70+
"DeletionPolicy": "Retain",
71+
"Properties": {
72+
"CompatibleRuntimes": [
73+
{
74+
"Ref": "LayerRuntimeRefString"
75+
}
76+
],
77+
"Content": {
78+
"S3Bucket": "sam-demo-bucket",
79+
"S3Key": "layer.zip"
80+
},
81+
"LayerName": "LayerWithSingleListRefRuntimesIntrinsic"
82+
},
83+
"Type": "AWS::Lambda::LayerVersion"
84+
},
85+
"LayerWithMixedListRefRuntimesIntrinsic71fd80f592": {
86+
"DeletionPolicy": "Retain",
87+
"Properties": {
88+
"CompatibleRuntimes": [
89+
{
90+
"Ref": "LayerRuntimeString"
91+
},
92+
"SomeRuntimeNameString"
93+
],
94+
"Content": {
95+
"S3Bucket": "sam-demo-bucket",
96+
"S3Key": "layer.zip"
97+
},
98+
"LayerName": "LayerWithMixedListRefRuntimesIntrinsic"
99+
},
100+
"Type": "AWS::Lambda::LayerVersion"
101+
},
65102
"LayerWithLicenseIntrinsic965c8d0c9b": {
66103
"DeletionPolicy": "Retain",
67104
"Type": "AWS::Lambda::LayerVersion",

tests/translator/output/layers_with_intrinsics.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"LayerNameParam": {
1111
"Default": "SomeLayerName",
1212
"Type": "String"
13+
},
14+
"LayerRuntimeRefString": {
15+
"Default": "SomeRuntimeName",
16+
"Type": "String"
1317
}
1418
},
1519
"Resources": {
@@ -62,6 +66,39 @@
6266
}
6367
}
6468
},
69+
"LayerWithSingleListRefRuntimesIntrinsic9d7a72f24a": {
70+
"DeletionPolicy": "Retain",
71+
"Properties": {
72+
"CompatibleRuntimes": [
73+
{
74+
"Ref": "LayerRuntimeRefString"
75+
}
76+
],
77+
"Content": {
78+
"S3Bucket": "sam-demo-bucket",
79+
"S3Key": "layer.zip"
80+
},
81+
"LayerName": "LayerWithSingleListRefRuntimesIntrinsic"
82+
},
83+
"Type": "AWS::Lambda::LayerVersion"
84+
},
85+
"LayerWithMixedListRefRuntimesIntrinsic71fd80f592": {
86+
"DeletionPolicy": "Retain",
87+
"Properties": {
88+
"CompatibleRuntimes": [
89+
{
90+
"Ref": "LayerRuntimeString"
91+
},
92+
"SomeRuntimeNameString"
93+
],
94+
"Content": {
95+
"S3Bucket": "sam-demo-bucket",
96+
"S3Key": "layer.zip"
97+
},
98+
"LayerName": "LayerWithMixedListRefRuntimesIntrinsic"
99+
},
100+
"Type": "AWS::Lambda::LayerVersion"
101+
},
65102
"LayerWithLicenseIntrinsic965c8d0c9b": {
66103
"DeletionPolicy": "Retain",
67104
"Type": "AWS::Lambda::LayerVersion",

0 commit comments

Comments
 (0)