Advertisement
Advanced AWS, AWS Config

How can custom Config rules built with Lambda functions evaluate complex, organization specific compliance requirements that AWS managed rules do not cover?

Short answer

A custom Config rule invokes a Lambda function you write whenever a relevant resource changes, and that function contains your own logic to evaluate whatever specific business or security requirement you need to check, such as ensuring an EC2 instance's tags follow a specific…

Save AWS mock interview
Advertisement
AModel answer
A custom Config rule invokes a Lambda function you write whenever a relevant resource changes, and that function contains your own logic to evaluate whatever specific business or security requirement you need to check, such as ensuring an EC2 instance's tags follow a specific naming convention or that a database's backup retention period meets an internally mandated minimum, giving you unlimited flexibility beyond what any predefined managed rule could offer.
def lambda_handler(event, context):
    configuration_item = event['configurationItem']
    is_compliant = configuration_item['tags'].get('CostCenter') is not None
    return {'compliance_type': 'COMPLIANT' if is_compliant else 'NON_COMPLIANT'}
Real-world example
A company writes a custom Config rule that flags any EC2 instance missing a required CostCenter tag as non compliant, enforcing an internal financial tracking requirement that no AWS managed rule could have covered out of the box.
Likely follow-ups
  • What event structure does a custom Config rule Lambda function receive?
  • How do you test a custom Config rule before deploying it broadly?
Related topics