How templatemechanics/pulumi-aws-classic works
Project type and purpose
• This is an infrastructure-as-code tool built with Pulumi. It reads a user’s config.yaml, dynamically maps resource definitions to Pulumi AWS classes, applies naming conventions & secret resolution, and then provisions or fetches AWS resources.
File structure
• __main__.py – the CLI/entry point.
• config.py – defines data models (dataclasses) for the YAML schema and a generic factory/mapping layer that, given a resource type (e.g., “ec2.Vpc”), picks the correct Pulumi AWS class and feeds it the args.
• awsclassic.py – houses AWS-specific logic: name templating (team-service-env-region-resource), region abbreviations, existing-vs-new resource lookup, and secret resolution (secret:).
• config.yaml – the user’s declarative spec.
• Pulumi.yaml + requirements.txt – Pulumi stack metadata & Python deps.
README for additional insights
• The README describes the naming convention, resource-referencing (ref:<name>.<attr>), secret syntax (secret:<key>), and dynamic introspection of Pulumi AWS classes.
a. Main components
• CLI/Entry Point (__main__.py)
• YAML Config Loader
• Schema & Mapper (config.py)
• AWS Logic & Naming (awsclassic.py)
• Pulumi Engine (Pulumi Python SDK)
• AWS Provider/API
• AWS Resources (VPC, Subnet, EC2, etc.)
• Pulumi Config Store (for secrets)
b. Relationships & interactions
1. User runs python -m project or pulumi up.
2. Entry Point reads config.yaml.
3. Loader hands raw YAML to Schema & Mapper → yields typed resource definitions.
4. Each definition is passed to AWS Logic → applies naming conventions, resolves existing vs new, secret lookups via Pulumi config.
5. Resulting Pulumi resource calls are sent to the Pulumi Engine.
6. Pulumi Engine communicates with the AWS Provider/API to create/update/fetch resources.
7. Outputs flow back into resource references, enabling ref: linking.
c. Architectural patterns / design principles
• Separation of concerns: parsing (config loader), mapping (config.py), AWS naming/logic (awsclassic.py), orchestration (main).
• Factory/Reflection: dynamic introspection of Pulumi AWS packages to map resource type strings to classes.
• Declarative model → imperative execution: YAML → Python dataclasses → Pulumi API calls.
• Dependency graph: Pulumi tracks resource dependencies automatically via references.
d. Key technologies/frameworks
• Pulumi Python SDK (pulumi, pulumi_aws)
• YAML parsing (pyyaml or equivalent)
• Python dataclasses
• AWS APIs
Detailed element checklist
• Distinguish synchronous flows (config → code) versus eventual consistency (Pulumi → AWS).