Skip to content

Commit

Permalink
feat(lambda): support enums in loggingFormat (#28942)
Browse files Browse the repository at this point in the history
> # 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*
  • Loading branch information
ConnorRobertson committed Jan 31, 2024
1 parent 1546b60 commit fb2329f
Show file tree
Hide file tree
Showing 11 changed files with 449 additions and 16 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,112 @@
"LambdaWithJSONFormatServiceRole37FFB486"
]
},
"LambdaWithTextLoggingFormatServiceRole3ADC91E1": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"LambdaWithTextLoggingFormatD614C37E": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "foo"
},
"Handler": "index.handler",
"LoggingConfig": {
"LogFormat": "Text"
},
"Role": {
"Fn::GetAtt": [
"LambdaWithTextLoggingFormatServiceRole3ADC91E1",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"LambdaWithTextLoggingFormatServiceRole3ADC91E1"
]
},
"LambdaWithJSONLoggingFormatServiceRole0B3D5672": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"LambdaWithJSONLoggingFormatFA0D6903": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "foo"
},
"Handler": "index.handler",
"LoggingConfig": {
"LogFormat": "JSON"
},
"Role": {
"Fn::GetAtt": [
"LambdaWithJSONLoggingFormatServiceRole0B3D5672",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"LambdaWithJSONLoggingFormatServiceRole0B3D5672"
]
},
"LambdaWithLogLevelServiceRole90A45743": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb2329f

Please sign in to comment.