awslabs / aws-config-rules

[Node, Python, Java] Repository of sample Custom Rules for AWS Config.
http://aws.amazon.com/config/
Creative Commons Zero v1.0 Universal
1.58k stars 851 forks source link

KeyError for AWS::ApiGatewayV2::Stage in API_GW_EXECUTION_LOGGING_ENABLED #358

Open tnickl opened 3 years ago

tnickl commented 3 years ago

The config rule API_GW_EXECUTION_LOGGING_ENABLED does not catch 'KeyError' for 'loggingLevel'.

When an ApiGatewayV2 is used no 'loggingLevel' is defined for HTTP. The validation by API_GW_EXECUTION_LOGGING_ENABLED rule will fail with a

"errorMessage": "'loggingLevel'" "errorType": "KeyError", ... .

The code should check if the 'loggingLevel' key does exist for ApiGatewayV2. If not the rule should be 'COMPLIANT'.

Example event: ... "configuration": { "stageName": "$default", "defaultRouteSettings": { "detailedMetricsEnabled": false }, "routeSettings": {}, "stageVariables": {}, "autoDeploy": true, "createdDate": "Apr 6, 2021 9:40:17 AM", "lastUpdatedDate": "Apr 6, 2021 9:40:17 AM", "tags": { "internalId": "evu2", "resourceArn": "arn:aws:apigateway:eu-west-1::/apis/3clha2m2t5/stages/$default" } }, ... Check that failes with 'KeyError': if stage["defaultRouteSettings"]["loggingLevel"]