Skip to content

Commit 34f27a9

Browse files
committed
Add first integration test function
1 parent 2af972a commit 34f27a9

File tree

6 files changed

+770
-0
lines changed

6 files changed

+770
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "The AWS CloudFormation template for this Serverless application",
4+
"Resources": {
5+
"ServerlessDeploymentBucket": {
6+
"Type": "AWS::S3::Bucket",
7+
"Properties": {
8+
"BucketEncryption": {
9+
"ServerSideEncryptionConfiguration": [
10+
{
11+
"ServerSideEncryptionByDefault": {
12+
"SSEAlgorithm": "AES256"
13+
}
14+
}
15+
]
16+
}
17+
}
18+
}
19+
},
20+
"Outputs": {
21+
"ServerlessDeploymentBucketName": {
22+
"Value": {
23+
"Ref": "ServerlessDeploymentBucket"
24+
}
25+
}
26+
}
27+
}
Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "The AWS CloudFormation template for this Serverless application",
4+
"Resources": {
5+
"ServerlessDeploymentBucket": {
6+
"Type": "AWS::S3::Bucket",
7+
"Properties": {
8+
"BucketEncryption": {
9+
"ServerSideEncryptionConfiguration": [
10+
{
11+
"ServerSideEncryptionByDefault": {
12+
"SSEAlgorithm": "AES256"
13+
}
14+
}
15+
]
16+
}
17+
}
18+
},
19+
"CustomDashmetricDashwriterDashpython27LogGroup": {
20+
"Type": "AWS::Logs::LogGroup",
21+
"Properties": {
22+
"LogGroupName": "/aws/lambda/integration-tester-dev-custom-metric-writer-python27"
23+
}
24+
},
25+
"IamRoleLambdaExecution": {
26+
"Type": "AWS::IAM::Role",
27+
"Properties": {
28+
"AssumeRolePolicyDocument": {
29+
"Version": "2012-10-17",
30+
"Statement": [
31+
{
32+
"Effect": "Allow",
33+
"Principal": {
34+
"Service": [
35+
"lambda.amazonaws.com"
36+
]
37+
},
38+
"Action": [
39+
"sts:AssumeRole"
40+
]
41+
}
42+
]
43+
},
44+
"Policies": [
45+
{
46+
"PolicyName": {
47+
"Fn::Join": [
48+
"-",
49+
[
50+
"dev",
51+
"integration-tester",
52+
"lambda"
53+
]
54+
]
55+
},
56+
"PolicyDocument": {
57+
"Version": "2012-10-17",
58+
"Statement": [
59+
{
60+
"Effect": "Allow",
61+
"Action": [
62+
"logs:CreateLogStream"
63+
],
64+
"Resource": [
65+
{
66+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/integration-tester-dev*:*"
67+
}
68+
]
69+
},
70+
{
71+
"Effect": "Allow",
72+
"Action": [
73+
"logs:PutLogEvents"
74+
],
75+
"Resource": [
76+
{
77+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/integration-tester-dev*:*:*"
78+
}
79+
]
80+
}
81+
]
82+
}
83+
}
84+
],
85+
"Path": "/",
86+
"RoleName": {
87+
"Fn::Join": [
88+
"-",
89+
[
90+
"integration-tester",
91+
"dev",
92+
{
93+
"Ref": "AWS::Region"
94+
},
95+
"lambdaRole"
96+
]
97+
]
98+
}
99+
}
100+
},
101+
"TestLambdaLayer": {
102+
"Type": "AWS::Lambda::LayerVersion",
103+
"Properties": {
104+
"Content": {
105+
"S3Bucket": {
106+
"Ref": "ServerlessDeploymentBucket"
107+
},
108+
"S3Key": "serverless/integration-tester/dev/1582571794655-2020-02-24T19:16:34.655Z/datadog_lambda_py2.7.zip"
109+
},
110+
"LayerName": "test"
111+
}
112+
},
113+
"CustomDashmetricDashwriterDashpython27LambdaFunction": {
114+
"Type": "AWS::Lambda::Function",
115+
"Properties": {
116+
"Code": {
117+
"S3Bucket": {
118+
"Ref": "ServerlessDeploymentBucket"
119+
},
120+
"S3Key": "serverless/integration-tester/dev/1582571794655-2020-02-24T19:16:34.655Z/integration-tester.zip"
121+
},
122+
"FunctionName": "integration-tester-dev-custom-metric-writer-python27",
123+
"Handler": "handler.handle",
124+
"MemorySize": 1024,
125+
"Role": {
126+
"Fn::GetAtt": [
127+
"IamRoleLambdaExecution",
128+
"Arn"
129+
]
130+
},
131+
"Runtime": "python2.7",
132+
"Timeout": 6,
133+
"Layers": [
134+
{
135+
"Ref": "TestLambdaLayer"
136+
}
137+
]
138+
},
139+
"DependsOn": [
140+
"CustomDashmetricDashwriterDashpython27LogGroup",
141+
"IamRoleLambdaExecution"
142+
]
143+
},
144+
"CustomDashmetricDashwriterDashpython27LambdaVersion8Uuw4UZraNHeUFMZ6gOKWETimHZStyXU1J9Csl1Rrxo": {
145+
"Type": "AWS::Lambda::Version",
146+
"DeletionPolicy": "Retain",
147+
"Properties": {
148+
"FunctionName": {
149+
"Ref": "CustomDashmetricDashwriterDashpython27LambdaFunction"
150+
},
151+
"CodeSha256": "hN8ew3WnFE5Y5SjxBqvugAkr9bLFz+oiWqGPMUqUkV4="
152+
}
153+
},
154+
"ApiGatewayRestApi": {
155+
"Type": "AWS::ApiGateway::RestApi",
156+
"Properties": {
157+
"Name": "dev-integration-tester",
158+
"EndpointConfiguration": {
159+
"Types": [
160+
"EDGE"
161+
]
162+
}
163+
}
164+
},
165+
"ApiGatewayResourceHello": {
166+
"Type": "AWS::ApiGateway::Resource",
167+
"Properties": {
168+
"ParentId": {
169+
"Fn::GetAtt": [
170+
"ApiGatewayRestApi",
171+
"RootResourceId"
172+
]
173+
},
174+
"PathPart": "hello",
175+
"RestApiId": {
176+
"Ref": "ApiGatewayRestApi"
177+
}
178+
}
179+
},
180+
"ApiGatewayMethodHelloGet": {
181+
"Type": "AWS::ApiGateway::Method",
182+
"Properties": {
183+
"HttpMethod": "GET",
184+
"RequestParameters": {},
185+
"ResourceId": {
186+
"Ref": "ApiGatewayResourceHello"
187+
},
188+
"RestApiId": {
189+
"Ref": "ApiGatewayRestApi"
190+
},
191+
"ApiKeyRequired": false,
192+
"AuthorizationType": "NONE",
193+
"Integration": {
194+
"IntegrationHttpMethod": "POST",
195+
"Type": "AWS_PROXY",
196+
"Uri": {
197+
"Fn::Join": [
198+
"",
199+
[
200+
"arn:",
201+
{
202+
"Ref": "AWS::Partition"
203+
},
204+
":apigateway:",
205+
{
206+
"Ref": "AWS::Region"
207+
},
208+
":lambda:path/2015-03-31/functions/",
209+
{
210+
"Fn::GetAtt": [
211+
"CustomDashmetricDashwriterDashpython27LambdaFunction",
212+
"Arn"
213+
]
214+
},
215+
"/invocations"
216+
]
217+
]
218+
}
219+
},
220+
"MethodResponses": []
221+
}
222+
},
223+
"ApiGatewayDeployment1582571794121": {
224+
"Type": "AWS::ApiGateway::Deployment",
225+
"Properties": {
226+
"RestApiId": {
227+
"Ref": "ApiGatewayRestApi"
228+
},
229+
"StageName": "dev"
230+
},
231+
"DependsOn": [
232+
"ApiGatewayMethodHelloGet"
233+
]
234+
},
235+
"CustomDashmetricDashwriterDashpython27LambdaPermissionApiGateway": {
236+
"Type": "AWS::Lambda::Permission",
237+
"Properties": {
238+
"FunctionName": {
239+
"Fn::GetAtt": [
240+
"CustomDashmetricDashwriterDashpython27LambdaFunction",
241+
"Arn"
242+
]
243+
},
244+
"Action": "lambda:InvokeFunction",
245+
"Principal": "apigateway.amazonaws.com",
246+
"SourceArn": {
247+
"Fn::Join": [
248+
"",
249+
[
250+
"arn:",
251+
{
252+
"Ref": "AWS::Partition"
253+
},
254+
":execute-api:",
255+
{
256+
"Ref": "AWS::Region"
257+
},
258+
":",
259+
{
260+
"Ref": "AWS::AccountId"
261+
},
262+
":",
263+
{
264+
"Ref": "ApiGatewayRestApi"
265+
},
266+
"/*/*"
267+
]
268+
]
269+
}
270+
}
271+
}
272+
},
273+
"Outputs": {
274+
"ServerlessDeploymentBucketName": {
275+
"Value": {
276+
"Ref": "ServerlessDeploymentBucket"
277+
}
278+
},
279+
"TestLambdaLayerQualifiedArn": {
280+
"Description": "Current Lambda layer version",
281+
"Value": {
282+
"Ref": "TestLambdaLayer"
283+
}
284+
},
285+
"CustomDashmetricDashwriterDashpython27LambdaFunctionQualifiedArn": {
286+
"Description": "Current Lambda function version",
287+
"Value": {
288+
"Ref": "CustomDashmetricDashwriterDashpython27LambdaVersion8Uuw4UZraNHeUFMZ6gOKWETimHZStyXU1J9Csl1Rrxo"
289+
}
290+
},
291+
"ServiceEndpoint": {
292+
"Description": "URL of the service endpoint",
293+
"Value": {
294+
"Fn::Join": [
295+
"",
296+
[
297+
"https://",
298+
{
299+
"Ref": "ApiGatewayRestApi"
300+
},
301+
".execute-api.",
302+
{
303+
"Ref": "AWS::Region"
304+
},
305+
".",
306+
{
307+
"Ref": "AWS::URLSuffix"
308+
},
309+
"/dev"
310+
]
311+
]
312+
}
313+
}
314+
}
315+
}
288 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)