Deploy a custom AWS Config rule using a Lambda function to evaluate EC2 instance compliance

domain: docs.aws.amazon.com/config · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Write a Lambda function handler that receives a `configurationItem` or `oversizedConfigurationItem` event and returns a compliance evaluation using the `config.put_evaluations` API call with `ComplianceType` set to `COMPLIANT` or `NON_COMPLIANT`.
  2. Ensure the Lambda execution role includes `config:PutEvaluations` and the `AWSLambdaBasicExecutionRole` managed policy.
  3. Create the Config rule via the AWS console or CLI: `aws configservice put-config-rule --config-rule file://rule.json` where `rule.json` specifies `Source.Owner: CUSTOM_LAMBDA` and the Lambda ARN.
  4. Set `Source.SourceDetails[].MessageType` to `ConfigurationItemChangeNotification` for change-triggered rules or `ScheduledNotification` for periodic evaluation.
  5. Grant AWS Config permission to invoke the Lambda: `aws lambda add-permission --function-name <NAME> --statement-id config-invoke --action lambda:InvokeFunction --principal config.amazonaws.com`.
  6. Deploy Config rules across an organization using a Conformance Pack: author a YAML template and deploy with `aws configservice put-organization-conformance-pack`.

Known gotchas

Related routes

Deploy an AWS Config conformance pack to evaluate multi-account compliance against a managed rule set
docs.aws.amazon.com · 5 steps · unrated
Package and deploy AWS Lambda functions as container images versus zip archives and know when to choose each
aws-lambda · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans