How levetty/terraform-aws-cloudbase works
Main Components
• Terraform Root Module: Represented by the top-level files (main.tf, variables.tf, versions.tf, README.md, LICENSE). This is the entry point for setting module configuration.
• Submodules: In particular, the “vm_scan” submodule inside the module folder. This submodule handles resources (e.g., IAM and KMS configurations) specific to virtual machine scanning.
• Policies: A directory containing JSON files for each scanning type (container_scan, vm_scan, lambda_scan, and various CSPM policies). These represent the policy definitions that are attached to the IAM roles.
• User Configuration Interface: Illustrated in the README examples, where the user specifies various booleans (allow_container_scan_permissions, allow_vm_scan_permissions, etc.) that control which policies are applied.
Relationships and Interactions
• The Root Module accepts user inputs and variables that determine what scan permissions are enabled.
• It then integrates with the VM Scan Submodule if VM scan permissions are toggled on. The submodule defines resources (as seen by the presence of iam.tf, kms.tf, etc.) that are specific to VM scanning.
• The module leverages JSON policy definitions stored in the policies directory. These are attached to the IAM roles created in the module.
• Outputs (like cloudbase_role_arn) provide the resulting IAM role ARN back to the user, connecting the configured module to the consumer (e.g., Cloudbase console).
Architectural Patterns
• Modularization: The use of submodules (e.g., vm_scan) shows a well-separated and modular design.
• Declarative Infrastructure: All components are defined in Terraform with configuration files and policy JSON files.
• Parameterization: The module uses variables to customize behavior, allowing extensive configuration and reuse.
Relevant Technologies
• Terraform: As the core technology, with HCL for configuration.
• AWS Services: IAM (for role creation and policy attachments), KMS (used in the vm_scan module for encryption), and likely other services implicitly used by scanning (ECR for container scanning, EC2 snapshots for VM scans, Lambda functions, CloudTrail).
• JSON: For policy definitions.
Instructing the Principal Software Engineer
• Clear Labels: Each component (Root Module, VM Scan Module, Policies, IAM Role, KMS configuration).