Skip to content

AWS Config Rules error, Question regarding this behavior

0

During the very first run as soon as new AWS account gets created I'm receiving Non Compliant status. But after sometime when I retrigger the evaluation without changing anything in the resource these rules are giving Complaint status. This is a custom config rule written in python.

i'm wondering what behavior can cause this in AWS config rules, is it possible that hte order of the code in which it is written can cause this and is there anyway to fix this?

2 Answers
1

This behavior in AWS Config rules can occur for several reasons. When you first create a custom rule, AWS Config evaluates your resources against that rule, but there might be a delay in the evaluation process or issues with the Lambda function that powers your custom rule.

The "INSUFFICIENT_DATA" status might be returned initially if:

  1. AWS Config has not yet completed its first evaluation for the rule.
  2. The Lambda function for your custom rule is failing to send evaluation results to AWS Config.
  3. There might be permission issues with your Lambda function not having the proper config:PutEvaluations permission.

When you retrigger the evaluation later, these initial issues might have been resolved automatically:

  • The Lambda function might have successfully completed its evaluation
  • Any temporary permission or configuration issues might have been resolved
  • AWS Config might have completed gathering all necessary data for evaluation

To fix this issue:

  1. Ensure your Lambda execution role includes the config:PutEvaluations permission
  2. Verify that the role assigned to your configuration recorder has the necessary permissions
  3. Check the Lambda function logs for any errors during the initial evaluation
  4. Consider the order of operations in your Python code - if it's making assumptions about resource state that might not be valid during the first evaluation

You can also use the DescribeConfigRuleEvaluationStatus API to check the LastSuccessfulInvocationTime and LastFailedInvocationTime to better understand the evaluation timing.
Sources
DescribeComplianceByConfigRule - AWS Config
Evaluating Your Resources with AWS Config Rules - AWS Config
Components of an AWS Config Rule - AWS Config
Config rule with custom lambda permission issue | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

0

You mentioned the issue is happening on new accounts. When you create a new AWS account, not all AWS resources and service metadata are immediately available. Some resources may not yet exist (e.g., IAM roles, baseline buckets, default VPC, CloudTrail trail, etc.). The custom rule runs immediately and results NON_COMPLIANT. Eventually, CloudTrail is created, SCP is configured, etc and eventually the status is changed to COMPLIANT.

EXPERT

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.