Skip to content

Commit b98e69c

Browse files
committed
Release Changes for 1.25.0
1 parent d17bc09 commit b98e69c

File tree

11 files changed

+452
-3
lines changed

11 files changed

+452
-3
lines changed

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.24.0"
1+
__version__ = "1.25.0"

samtranslator/model/lambda_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class LambdaFunction(Resource):
2222
"KmsKeyArn": PropertyType(False, one_of(is_type(dict), is_str())),
2323
"Layers": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
2424
"ReservedConcurrentExecutions": PropertyType(False, any_type()),
25+
"FileSystemConfigs": PropertyType(False, list_of(is_type(dict))),
2526
}
2627

2728
runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")}

samtranslator/model/sam_resources.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class SamFunction(SamResourceMacro):
8282
"AutoPublishCodeSha256": PropertyType(False, one_of(is_str())),
8383
"VersionDescription": PropertyType(False, is_str()),
8484
"ProvisionedConcurrencyConfig": PropertyType(False, is_type(dict)),
85+
"FileSystemConfigs": PropertyType(False, list_of(is_type(dict))),
8586
}
8687
event_resolver = ResourceTypeResolver(
8788
samtranslator.model.eventsources,
@@ -404,6 +405,7 @@ def _construct_lambda_function(self):
404405
lambda_function.ReservedConcurrentExecutions = self.ReservedConcurrentExecutions
405406
lambda_function.Tags = self._construct_tag_list(self.Tags)
406407
lambda_function.Layers = self.Layers
408+
lambda_function.FileSystemConfigs = self.FileSystemConfigs
407409

408410
if self.Tracing:
409411
lambda_function.TracingConfig = {"Mode": self.Tracing}

samtranslator/plugins/globals/globals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Globals(object):
4040
"ProvisionedConcurrencyConfig",
4141
"AssumeRolePolicyDocument",
4242
"EventInvokeConfig",
43+
"FileSystemConfigs",
4344
],
4445
# Everything except
4546
# DefinitionBody: because its hard to reason about merge of Swagger dictionaries

samtranslator/policy_templates_data/policy_templates.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,52 @@
22602260
}
22612261
]
22622262
}
2263+
},
2264+
"EFSWriteAccessPolicy": {
2265+
"Description": "Gives permission to mount an Elastic File System with write access",
2266+
"Parameters": {
2267+
"FileSystem": {
2268+
"Description": "Resource ID of the Elastic File System"
2269+
},
2270+
"AccessPoint": {
2271+
"Description": "Resource ID of the Elastic File System Access Point"
2272+
}
2273+
},
2274+
"Definition": {
2275+
"Statement": [
2276+
{
2277+
"Effect": "Allow",
2278+
"Action": [
2279+
"elasticfilesystem:ClientMount",
2280+
"elasticfilesystem:ClientWrite"
2281+
],
2282+
"Resource": {
2283+
"Fn::Sub": [
2284+
"arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${FileSystem}",
2285+
{
2286+
"FileSystem": {
2287+
"Ref": "FileSystem"
2288+
}
2289+
}
2290+
]
2291+
},
2292+
"Condition": {
2293+
"StringEquals": {
2294+
"elasticfilesystem:AccessPointArn": {
2295+
"Fn::Sub": [
2296+
"arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:access-point/${AccessPoint}",
2297+
{
2298+
"AccessPoint": {
2299+
"Ref": "AccessPoint"
2300+
}
2301+
}
2302+
]
2303+
}
2304+
}
2305+
}
2306+
}
2307+
]
2308+
}
22632309
}
22642310
}
22652311
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Description: SAM + Lambda + EFS
2+
3+
Parameters:
4+
ExistingEfsFileSystem:
5+
Type: String
6+
7+
SecurityGroupIds:
8+
Type: List<AWS::EC2::SecurityGroup::Id>
9+
Description: Security Group IDs that Lambda will use
10+
11+
VpcSubnetIds:
12+
Type: List<AWS::EC2::Subnet::Id>
13+
Description: VPC Subnet IDs that Lambda will use
14+
15+
Resources:
16+
EfsFileSystem:
17+
Type: AWS::EFS::FileSystem
18+
19+
MountTarget:
20+
Type: AWS::EFS::MountTarget
21+
Properties:
22+
FileSystemId: !Ref EfsFileSystem
23+
SubnetId: subnet-abc123
24+
SecurityGroups: !Ref SecurityGroupIds
25+
26+
AccessPoint:
27+
Type: AWS::EFS::AccessPoint
28+
Properties:
29+
FileSystemId: !Ref EfsFileSystem
30+
31+
LambdaFunctionWithEfs:
32+
Type: AWS::Serverless::Function
33+
Properties:
34+
InlineCode: |
35+
const fs = require('fs')
36+
const path = require('path')
37+
const efsMountPath = '/mnt/efs'
38+
39+
exports.handler = async (event, context, callback) => {
40+
const directory = path.join(efsMountPath, event.body)
41+
const files = fs.readdirSync(directory)
42+
return files
43+
}
44+
Handler: index.handler
45+
MemorySize: 128
46+
Runtime: nodejs12.x
47+
Timeout: 3
48+
VpcConfig:
49+
SecurityGroupIds: !Ref SecurityGroupIds
50+
SubnetIds: !Ref VpcSubnetIds
51+
FileSystemConfigs:
52+
- Arn: !GetAtt AccessPoint.Arn
53+
LocalMountPath: /mnt/EFS
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"Resources": {
3+
"EfsFileSystem": {
4+
"Type": "AWS::EFS::FileSystem"
5+
},
6+
"LambdaFunctionWithEfs": {
7+
"Type": "AWS::Lambda::Function",
8+
"Properties": {
9+
"Code": {
10+
"ZipFile": "const fs = require('fs')\nconst path = require('path')\nconst efsMountPath = '/mnt/efs'\n\nexports.handler = async (event, context, callback) => {\nconst directory = path.join(efsMountPath, event.body)\nconst files = fs.readdirSync(directory)\nreturn files\n}\n"
11+
},
12+
"VpcConfig": {
13+
"SubnetIds": {
14+
"Ref": "VpcSubnetIds"
15+
},
16+
"SecurityGroupIds": {
17+
"Ref": "SecurityGroupIds"
18+
}
19+
},
20+
"Tags": [
21+
{
22+
"Value": "SAM",
23+
"Key": "lambda:createdBy"
24+
}
25+
],
26+
"MemorySize": 128,
27+
"Handler": "index.handler",
28+
"Role": {
29+
"Fn::GetAtt": [
30+
"LambdaFunctionWithEfsRole",
31+
"Arn"
32+
]
33+
},
34+
"Timeout": 3,
35+
"FileSystemConfigs": [
36+
{
37+
"Arn": {
38+
"Fn::GetAtt": [
39+
"AccessPoint",
40+
"Arn"
41+
]
42+
},
43+
"LocalMountPath": "/mnt/EFS"
44+
}
45+
],
46+
"Runtime": "nodejs12.x"
47+
}
48+
},
49+
"MountTarget": {
50+
"Type": "AWS::EFS::MountTarget",
51+
"Properties": {
52+
"SubnetId": "subnet-abc123",
53+
"FileSystemId": {
54+
"Ref": "EfsFileSystem"
55+
},
56+
"SecurityGroups": {
57+
"Ref": "SecurityGroupIds"
58+
}
59+
}
60+
},
61+
"LambdaFunctionWithEfsRole": {
62+
"Type": "AWS::IAM::Role",
63+
"Properties": {
64+
"AssumeRolePolicyDocument": {
65+
"Version": "2012-10-17",
66+
"Statement": [
67+
{
68+
"Action": [
69+
"sts:AssumeRole"
70+
],
71+
"Effect": "Allow",
72+
"Principal": {
73+
"Service": [
74+
"lambda.amazonaws.com"
75+
]
76+
}
77+
}
78+
]
79+
},
80+
"ManagedPolicyArns": [
81+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
82+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
83+
],
84+
"Tags": [
85+
{
86+
"Value": "SAM",
87+
"Key": "lambda:createdBy"
88+
}
89+
]
90+
}
91+
},
92+
"AccessPoint": {
93+
"Type": "AWS::EFS::AccessPoint",
94+
"Properties": {
95+
"FileSystemId": {
96+
"Ref": "EfsFileSystem"
97+
}
98+
}
99+
}
100+
},
101+
"Description": "SAM + Lambda + EFS",
102+
"Parameters": {
103+
"ExistingEfsFileSystem": {
104+
"Type": "String"
105+
},
106+
"VpcSubnetIds": {
107+
"Type": "List<AWS::EC2::Subnet::Id>",
108+
"Description": "VPC Subnet IDs that Lambda will use"
109+
},
110+
"SecurityGroupIds": {
111+
"Type": "List<AWS::EC2::SecurityGroup::Id>",
112+
"Description": "Security Group IDs that Lambda will use"
113+
}
114+
}
115+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"Resources": {
3+
"EfsFileSystem": {
4+
"Type": "AWS::EFS::FileSystem"
5+
},
6+
"LambdaFunctionWithEfs": {
7+
"Type": "AWS::Lambda::Function",
8+
"Properties": {
9+
"Code": {
10+
"ZipFile": "const fs = require('fs')\nconst path = require('path')\nconst efsMountPath = '/mnt/efs'\n\nexports.handler = async (event, context, callback) => {\nconst directory = path.join(efsMountPath, event.body)\nconst files = fs.readdirSync(directory)\nreturn files\n}\n"
11+
},
12+
"VpcConfig": {
13+
"SubnetIds": {
14+
"Ref": "VpcSubnetIds"
15+
},
16+
"SecurityGroupIds": {
17+
"Ref": "SecurityGroupIds"
18+
}
19+
},
20+
"Tags": [
21+
{
22+
"Value": "SAM",
23+
"Key": "lambda:createdBy"
24+
}
25+
],
26+
"MemorySize": 128,
27+
"Handler": "index.handler",
28+
"Role": {
29+
"Fn::GetAtt": [
30+
"LambdaFunctionWithEfsRole",
31+
"Arn"
32+
]
33+
},
34+
"Timeout": 3,
35+
"FileSystemConfigs": [
36+
{
37+
"Arn": {
38+
"Fn::GetAtt": [
39+
"AccessPoint",
40+
"Arn"
41+
]
42+
},
43+
"LocalMountPath": "/mnt/EFS"
44+
}
45+
],
46+
"Runtime": "nodejs12.x"
47+
}
48+
},
49+
"MountTarget": {
50+
"Type": "AWS::EFS::MountTarget",
51+
"Properties": {
52+
"SubnetId": "subnet-abc123",
53+
"FileSystemId": {
54+
"Ref": "EfsFileSystem"
55+
},
56+
"SecurityGroups": {
57+
"Ref": "SecurityGroupIds"
58+
}
59+
}
60+
},
61+
"LambdaFunctionWithEfsRole": {
62+
"Type": "AWS::IAM::Role",
63+
"Properties": {
64+
"AssumeRolePolicyDocument": {
65+
"Version": "2012-10-17",
66+
"Statement": [
67+
{
68+
"Action": [
69+
"sts:AssumeRole"
70+
],
71+
"Effect": "Allow",
72+
"Principal": {
73+
"Service": [
74+
"lambda.amazonaws.com"
75+
]
76+
}
77+
}
78+
]
79+
},
80+
"ManagedPolicyArns": [
81+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
82+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole"
83+
],
84+
"Tags": [
85+
{
86+
"Value": "SAM",
87+
"Key": "lambda:createdBy"
88+
}
89+
]
90+
}
91+
},
92+
"AccessPoint": {
93+
"Type": "AWS::EFS::AccessPoint",
94+
"Properties": {
95+
"FileSystemId": {
96+
"Ref": "EfsFileSystem"
97+
}
98+
}
99+
}
100+
},
101+
"Description": "SAM + Lambda + EFS",
102+
"Parameters": {
103+
"ExistingEfsFileSystem": {
104+
"Type": "String"
105+
},
106+
"VpcSubnetIds": {
107+
"Type": "List<AWS::EC2::Subnet::Id>",
108+
"Description": "VPC Subnet IDs that Lambda will use"
109+
},
110+
"SecurityGroupIds": {
111+
"Type": "List<AWS::EC2::SecurityGroup::Id>",
112+
"Description": "Security Group IDs that Lambda will use"
113+
}
114+
}
115+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"errors": [
33
{
4-
"errorMessage": "'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'EventInvokeConfig']"
4+
"errorMessage": "'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'EventInvokeConfig', 'FileSystemConfigs']"
55
}
66
],
7-
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. 'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'AssumeRolePolicyDocument', 'EventInvokeConfig']"
7+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. 'Globals' section is invalid. 'SomeKey' is not a supported property of 'Function'. Must be one of the following values - ['Handler', 'Runtime', 'CodeUri', 'DeadLetterQueue', 'Description', 'MemorySize', 'Timeout', 'VpcConfig', 'Environment', 'Tags', 'Tracing', 'KmsKeyArn', 'AutoPublishAlias', 'Layers', 'DeploymentPreference', 'PermissionsBoundary', 'ReservedConcurrentExecutions', 'ProvisionedConcurrencyConfig', 'AssumeRolePolicyDocument', 'EventInvokeConfig', 'FileSystemConfigs']"
88
}

0 commit comments

Comments
 (0)