How aws-solutions/aws-control-tower-customizations works
Based on our analysis of the file tree and the README, this solution is an AWS backend customization tool that augments AWS Control Tower. Its purpose is to allow customers to add custom CloudFormation templates, service control policies (SCPs), and resource control policies (RCPs) to their AWS Control Tower landing zone. The repository contains deployment scripts and CloudFormation templates for distributing the solution and Python source code that implements the core logic, AWS service integrations, and Lambda handlers.
Main Components
• Deployment Layer:
• CloudFormation Templates and Scripts: Represented by files under the “deployment” folder (e.g., custom-control-tower-initiation.template, build scripts, and policy templates). These components package and initiate the solution.
• Distribution and S3: The build-s3-dist.sh script produces a distributable that is uploaded to S3 buckets following specific naming patterns.
• Core Backend Services:
• Lambda Handlers: The “source/src/cfct/lambda_handlers” directory includes handlers such as “lifecycle_event_handler”, “config_deployer”, and “state_machine_router” that respond to AWS Control Tower lifecycle events.
• AWS Services Integration: The “source/src/cfct/aws/services” folder contains modules for interacting with various AWS APIs (e.g., CloudFormation, CodePipeline, EC2, KMS, Organizations, S3, SCP, SSM, etc.). These modules encapsulate service-specific logic.
• Utility and Helper Modules: Modules under “source/src/cfct/utils” (e.g., logger, parameter manipulation, retry decorator) support the core functions.
• Manifest & Validation: The “manifest” and “validation” folders in the source present the logic to parse, merge, and validate CloudFormation parameters and policies.
• Metrics Collection: The “metrics” component is designed to gather operational data, as described in the README.
• Build and Integration Automation:
• CodeBuild Scripts: Located in “source/codebuild_scripts”, these scripts assist with tasks such as merging templates, updating baseline parameters, and running unit tests.
• Unit Testing: There is an explicit shell script in “deployment” for running unit tests, ensuring code quality before deployment.
Relationships and Interactions
• How these events are picked up by the Lambda functions (lifecycle_event_handler, state_machine_router) deployed as part of the solution.
• Interactions from the Lambda functions to the various AWS service integration modules (for CloudFormation, CodePipeline, etc.) which, in turn, call AWS APIs and manage deployments.
• Demonstrate how the manifest and validation modules process and merge configuration parameters and templates to drive these deployments.
• CodeBuild stage that builds the distribution package and uploads the artifacts (CloudFormation templates and zipped source code) to the appropriate S3 buckets.
• Finally, include a metrics collection component that sends anonymized usage data to support operational insights.
Architectural Patterns
• Modular Design: Emphasize the separation among AWS service wrappers, Lambda handlers, utilities, and validation modules.
• Event-Driven Architecture: Illustrate how lifecycle events from AWS Control Tower initiate the flow, managed by serverless functions.
• Infrastructure as Code (IaC): Highlight the use of CloudFormation templates to deploy and manage the customized environment.
Relevant Technologies
• Python (version 3.6+): For the core backend.
• AWS Lambda: For serverless event handlers.
• AWS SDK (boto3): For interacting with AWS services.
• CloudFormation: For resource provisioning.
• CodeBuild and Shell Scripts: For building and packaging the solution.
• Amazon S3: For storing the distribution artifacts.