Skip to content

Commit fb2329f

Browse files
feat(lambda): support enums in loggingFormat (#28942)
> # Issue > > The issue is that LogFormat is a String so it doesn't allow the enum LogFormat. > # Solution > > Created a new enum for the LoggingFormat and added testing. So the solution sets these values as potential environment variables. The main difference is LoggingFormat is assigned to an enum instead of a string. > # Important Design Decisions > > This is so that an enum could be used for LoggingFormat without breaking JSII target languages. Some background information is in this pr #28127. Was a recommended solution here. #28127 > > Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any > code you submit. > > [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md > [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md Closes #28114. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1546b60 commit fb2329f

File tree

11 files changed

+449
-16
lines changed

11 files changed

+449
-16
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/aws-cdk-lambda-logging-config.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/aws-cdk-lambda-logging-config.template.json

+106
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,112 @@
233233
"LambdaWithJSONFormatServiceRole37FFB486"
234234
]
235235
},
236+
"LambdaWithTextLoggingFormatServiceRole3ADC91E1": {
237+
"Type": "AWS::IAM::Role",
238+
"Properties": {
239+
"AssumeRolePolicyDocument": {
240+
"Statement": [
241+
{
242+
"Action": "sts:AssumeRole",
243+
"Effect": "Allow",
244+
"Principal": {
245+
"Service": "lambda.amazonaws.com"
246+
}
247+
}
248+
],
249+
"Version": "2012-10-17"
250+
},
251+
"ManagedPolicyArns": [
252+
{
253+
"Fn::Join": [
254+
"",
255+
[
256+
"arn:",
257+
{
258+
"Ref": "AWS::Partition"
259+
},
260+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
261+
]
262+
]
263+
}
264+
]
265+
}
266+
},
267+
"LambdaWithTextLoggingFormatD614C37E": {
268+
"Type": "AWS::Lambda::Function",
269+
"Properties": {
270+
"Code": {
271+
"ZipFile": "foo"
272+
},
273+
"Handler": "index.handler",
274+
"LoggingConfig": {
275+
"LogFormat": "Text"
276+
},
277+
"Role": {
278+
"Fn::GetAtt": [
279+
"LambdaWithTextLoggingFormatServiceRole3ADC91E1",
280+
"Arn"
281+
]
282+
},
283+
"Runtime": "nodejs18.x"
284+
},
285+
"DependsOn": [
286+
"LambdaWithTextLoggingFormatServiceRole3ADC91E1"
287+
]
288+
},
289+
"LambdaWithJSONLoggingFormatServiceRole0B3D5672": {
290+
"Type": "AWS::IAM::Role",
291+
"Properties": {
292+
"AssumeRolePolicyDocument": {
293+
"Statement": [
294+
{
295+
"Action": "sts:AssumeRole",
296+
"Effect": "Allow",
297+
"Principal": {
298+
"Service": "lambda.amazonaws.com"
299+
}
300+
}
301+
],
302+
"Version": "2012-10-17"
303+
},
304+
"ManagedPolicyArns": [
305+
{
306+
"Fn::Join": [
307+
"",
308+
[
309+
"arn:",
310+
{
311+
"Ref": "AWS::Partition"
312+
},
313+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
314+
]
315+
]
316+
}
317+
]
318+
}
319+
},
320+
"LambdaWithJSONLoggingFormatFA0D6903": {
321+
"Type": "AWS::Lambda::Function",
322+
"Properties": {
323+
"Code": {
324+
"ZipFile": "foo"
325+
},
326+
"Handler": "index.handler",
327+
"LoggingConfig": {
328+
"LogFormat": "JSON"
329+
},
330+
"Role": {
331+
"Fn::GetAtt": [
332+
"LambdaWithJSONLoggingFormatServiceRole0B3D5672",
333+
"Arn"
334+
]
335+
},
336+
"Runtime": "nodejs18.x"
337+
},
338+
"DependsOn": [
339+
"LambdaWithJSONLoggingFormatServiceRole0B3D5672"
340+
]
341+
},
236342
"LambdaWithLogLevelServiceRole90A45743": {
237343
"Type": "AWS::IAM::Role",
238344
"Properties": {

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/lambdaloggingconfigDefaultTestDeployAssert24012B25.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/manifest.json

+26-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)