This github repository is part of AWS blog post https://aws.amazon.com/blogs/mt/customize-aws-config-resource-tracking-in-aws-control-tower-environment/
Please refer to the blog for what this sample code does and how to use it.
This solution uses CloudFormation parameters to customize the AWS Config Recorder behavior across your Control Tower environment. Parameters are organized into three categories:
- Description: Version number to force stack updates and rerun the solution
- Type: String
- Default:
1 - Usage: Increment this value whenever you need to force the solution to re-execute across all accounts
- Description: List of AWS account IDs to exclude from Config Recorder customization
- Type: String (Python list format)
- Default:
['111111111111', '222222222222', '333333333333'] - Constraints: 36-4096 characters
- Required Accounts: Must include Management account, Log Archive account, and Audit account at minimum
- Usage: Replace default values with your actual account IDs that should not have Config Recorder modifications
- Description: S3 bucket containing Lambda deployment packages
- Type: String
- Default:
marketplace-sa-resources - Usage: Leave as default unless you've customized the Lambda function code and stored it in your own S3 bucket
- Description: Strategy for resource recording in AWS Config
- Type: String
- Default:
EXCLUSION - Allowed Values:
EXCLUSION,INCLUSION - Usage:
EXCLUSION: Record all resources except those specified inConfigRecorderExcludedResourceTypesINCLUSION: Only record resources specified inConfigRecorderIncludedResourceTypes
- Description: Comma-separated list of AWS resource types to exclude from recording
- Type: String
- Default:
AWS::HealthLake::FHIRDatastore,AWS::Pinpoint::Segment,AWS::Pinpoint::ApplicationSettings - Usage: Only applies when
ConfigRecorderStrategyis set toEXCLUSION - Example:
AWS::EC2::Volume,AWS::S3::Bucket,AWS::RDS::DBInstance
- Description: Comma-separated list of AWS resource types to include in recording
- Type: String
- Default:
AWS::S3::Bucket,AWS::CloudTrail::Trail - Usage: Only applies when
ConfigRecorderStrategyis set toINCLUSION - Example:
AWS::IAM::Role,AWS::IAM::Policy,AWS::EC2::Instance
- Description: Default frequency for recording configuration changes
- Type: String
- Default:
CONTINUOUS - Allowed Values:
CONTINUOUS,DAILY - Usage:
CONTINUOUS: Records configuration changes as they occur (higher AWS Config costs)DAILY: Records configuration once per day (lower costs, 24-hour detection delay)
- Description: Comma-separated list of resource types to record on a daily cadence
- Type: String
- Default:
AWS::AutoScaling::AutoScalingGroup,AWS::AutoScaling::LaunchConfiguration - Usage: Resources listed here will be recorded daily regardless of
ConfigRecorderDefaultRecordingFrequencysetting - Example:
AWS::EC2::Volume,AWS::Lambda::Function
- Description: Comma-separated list of global resource types to record daily in the Control Tower home region
- Type: String
- Default:
AWS::IAM::Policy,AWS::IAM::User,AWS::IAM::Role,AWS::IAM::Group - Usage: Global resources (IAM, CloudFront, etc.) are only recorded in the home region to avoid duplication
- Note: These resources are automatically added to daily recording in the Control Tower home region only
ConfigRecorderStrategy: EXCLUSION
ConfigRecorderExcludedResourceTypes: "AWS::EC2::NetworkInterface,AWS::EC2::Volume,AWS::Lambda::Function"
ConfigRecorderDefaultRecordingFrequency: CONTINUOUSConfigRecorderStrategy: INCLUSION
ConfigRecorderIncludedResourceTypes: "AWS::IAM::Role,AWS::IAM::Policy,AWS::S3::Bucket,AWS::KMS::Key"
ConfigRecorderDefaultRecordingFrequency: DAILYConfigRecorderStrategy: EXCLUSION
ConfigRecorderExcludedResourceTypes: "AWS::EC2::NetworkInterface"
ConfigRecorderDefaultRecordingFrequency: DAILY
ConfigRecorderDailyResourceTypes: "AWS::EC2::Instance,AWS::RDS::DBInstance"See CONTRIBUTING for more information.
When you delete the CloudFormation stack, the following resources are intentionally retained to prevent race conditions and allow for complete rollback of AWS Config settings to their default Control Tower configuration:
- Lambda Functions:
ProducerLambdaandConsumerLambda - Lambda Permissions:
ProducerLambdaPermissions - Lambda Event Source Mapping:
ConsumerLambdaEventSourceMapping - IAM Roles:
ProducerLambdaExecutionRoleandConsumerLambdaExecutionRole - SQS Queue:
SQSConfigRecorder
Important: These retained resources will continue to incur minimal costs. If you want to completely remove all resources after stack deletion, you must manually delete these retained resources from the AWS Console or using the AWS CLI.
To manually clean up retained resources after stack deletion:
- Delete the Lambda functions via the Lambda console
- Delete the IAM roles via the IAM console
- Delete the SQS queue via the SQS console
- Lambda permissions and event source mappings will be automatically removed when their associated functions are deleted
This library is licensed under the MIT-0 License. See the LICENSE file.