@@ -15,11 +15,76 @@ Globals:
15
15
MemorySize : 1024
16
16
Environment :
17
17
Variables :
18
- JAVA_TOOL_OPTIONS : " -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dspring.context.checkpoint=onRefresh -XX:CRaCCheckpointTo=/tmp/crac"
19
18
MAIN_CLASS : software.amazonaws.Application
20
19
PRODUCT_TABLE_NAME : !Ref ProductsTable
21
20
22
21
Resources :
22
+
23
+ EfsLambdaVpc :
24
+ Type : AWS::EC2::VPC
25
+ Properties :
26
+ CidrBlock : " 10.0.0.0/16"
27
+ EfsLambdaSecurityGroup :
28
+ Type : AWS::EC2::SecurityGroup
29
+ Properties :
30
+ GroupDescription : " EFS + Lambda on SAM Security Group"
31
+ VpcId : !Ref EfsLambdaVpc
32
+ SecurityGroupEgress :
33
+ - CidrIp : " 0.0.0.0/0"
34
+ FromPort : 0
35
+ ToPort : 65535
36
+ IpProtocol : tcp
37
+ SecurityGroupIngress :
38
+ - CidrIp : " 0.0.0.0/0"
39
+ FromPort : 0
40
+ ToPort : 65535
41
+ IpProtocol : tcp
42
+ EfsLambdaSubnetA :
43
+ Type : AWS::EC2::Subnet
44
+ Properties :
45
+ VpcId : !Ref EfsLambdaVpc
46
+ AvailabilityZone : !Select [ 0, !GetAZs '' ]
47
+ MapPublicIpOnLaunch : false
48
+ CidrBlock : " 10.0.0.0/24"
49
+ EfsLambdaSubnetB :
50
+ Type : AWS::EC2::Subnet
51
+ Properties :
52
+ VpcId : !Ref EfsLambdaVpc
53
+ AvailabilityZone : !Select [ 1, !GetAZs '' ]
54
+ MapPublicIpOnLaunch : false
55
+ CidrBlock : " 10.0.1.0/24"
56
+ EfsFileSystem :
57
+ Type : AWS::EFS::FileSystem
58
+ MountTargetA :
59
+ Type : AWS::EFS::MountTarget
60
+ Properties :
61
+ FileSystemId : !Ref EfsFileSystem
62
+ SubnetId : !Ref EfsLambdaSubnetA
63
+ SecurityGroups :
64
+ - !Ref EfsLambdaSecurityGroup
65
+ MountTargetB :
66
+ Type : AWS::EFS::MountTarget
67
+ Properties :
68
+ FileSystemId : !Ref EfsFileSystem
69
+ SubnetId : !Ref EfsLambdaSubnetB
70
+ SecurityGroups :
71
+ - !Ref EfsLambdaSecurityGroup
72
+ AccessPoint :
73
+ Type : AWS::EFS::AccessPoint
74
+ Properties :
75
+ FileSystemId : !Ref EfsFileSystem
76
+ PosixUser :
77
+ Gid : " 1000"
78
+ Uid : " 1000"
79
+ RootDirectory :
80
+ Path : " /lambda"
81
+ CreationInfo :
82
+ OwnerGid : " 1000"
83
+ OwnerUid : " 1000"
84
+ Permissions : " 755"
85
+
86
+
87
+
23
88
MyApi :
24
89
Type : AWS::Serverless::Api
25
90
DependsOn : MyApiCWLRoleArn
@@ -108,18 +173,35 @@ Resources:
108
173
109
174
GetProductByIdFunction :
110
175
Type : AWS::Serverless::Function
176
+ DependsOn :
177
+ - MountTargetA
178
+ - MountTargetB
179
+
111
180
Properties :
112
181
PackageType : Image
113
- ImageUri : !Sub ${AWS::AccountId}.dkr.ecr.eu-central-1.amazonaws.com/aws-spring-boot-3.2-java21-with- crac-custom-docker-image:v1
182
+ ImageUri : !Sub ${AWS::AccountId}.dkr.ecr.eu-central-1.amazonaws.com/aws-spring-boot-3.2-java21-crac-custom-docker-image:v1
114
183
ImageConfig :
115
184
Command : ["org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest"]
116
185
Environment :
117
186
Variables :
187
+ JAVA_TOOL_OPTIONS : " -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dspring.context.checkpoint=onRefresh -XX:CRaCCheckpointTo=/mnt/msg/crac"
118
188
SPRING_CLOUD_FUNCTION_DEFINITION : getProductByIdHandler
119
189
FunctionName : GetProductByIdWithSpringBootJava21DockerImageWithCRaC
120
190
Policies :
191
+ - EFSWriteAccessPolicy :
192
+ FileSystem : !Ref EfsFileSystem
193
+ AccessPoint : !Ref AccessPoint
121
194
- DynamoDBReadPolicy :
122
195
TableName : !Ref ProductsTable
196
+ VpcConfig :
197
+ SecurityGroupIds :
198
+ - !Ref EfsLambdaSecurityGroup
199
+ SubnetIds :
200
+ - !Ref EfsLambdaSubnetA
201
+ - !Ref EfsLambdaSubnetB
202
+ FileSystemConfigs :
203
+ - Arn : !GetAtt AccessPoint.Arn
204
+ LocalMountPath : /mnt/msg
123
205
Events :
124
206
GetRequestById :
125
207
Type : Api
@@ -144,6 +226,7 @@ Resources:
144
226
Command : ["org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest"]
145
227
Environment :
146
228
Variables :
229
+ JAVA_TOOL_OPTIONS : " -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
147
230
SPRING_CLOUD_FUNCTION_DEFINITION : createProductHandler
148
231
FunctionName : PutProductWithSpringBoot32Java21DockerImageWithCRaC
149
232
Policies :
0 commit comments