{"id":26295546,"url":"https://github.com/elmo33/terraforge","last_synced_at":"2026-05-20T09:31:47.446Z","repository":{"id":282445436,"uuid":"948631047","full_name":"Elmo33/TerraForge","owner":"Elmo33","description":"A Python library for generating and manipulating Terraform HCL configurations.","archived":false,"fork":false,"pushed_at":"2025-03-14T17:16:44.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T17:41:53.672Z","etag":null,"topics":["automation","configuration","devops","hcl","infrastructure-as-code","python","terraform"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Elmo33.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-14T17:14:10.000Z","updated_at":"2025-03-14T17:17:28.000Z","dependencies_parsed_at":"2025-03-14T17:51:55.926Z","dependency_job_id":null,"html_url":"https://github.com/Elmo33/TerraForge","commit_stats":null,"previous_names":["elmo33/terraforge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elmo33%2FTerraForge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elmo33%2FTerraForge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elmo33%2FTerraForge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elmo33%2FTerraForge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Elmo33","download_url":"https://codeload.github.com/Elmo33/TerraForge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681077,"owners_count":20330155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","configuration","devops","hcl","infrastructure-as-code","python","terraform"],"created_at":"2025-03-15T04:14:22.315Z","updated_at":"2026-05-20T09:31:47.373Z","avatar_url":"https://github.com/Elmo33.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# TerraForge\n\nTerraForge is a Python library for generating and manipulating Terraform configurations in HCL format. It provides an intuitive, programmatic interface to create and manage Terraform files, making it easier to build, modify, and maintain infrastructure-as-code configurations.\n\n## Features\n\n- **HCL Generation**: Create HCL expressions, blocks, and entire Terraform configurations.\n- **Flexible Configuration**: Easily add providers, variables, resources, and modules.\n- **Simple API**: Designed to be used as a Python module for quick integration into your projects.\n\n## Installation\n\nTerraForge is available on PyPI. You can install it using pip:\n\n```bash\npip install terraforge\n```\n\nAlternatively, install it from source:\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/yourusername/terraforge.git\n    ```\n2. Change to the project directory:\n    ```bash\n    cd terraforge\n    ```\n3. Install the package:\n    ```bash\n    pip install .\n    ```\n\n## Usage\n\nHere is a simple example that demonstrates how to create a Terraform configuration with TerraForge:\n\n```python\nfrom terraforge import TerraformConfig\n\n# Create a new Terraform configuration\nconfig = TerraformConfig()\n\n# Add a provider configuration\nconfig.add_provider(\"aws\", region=\"us-west-2\")\n\n# Add a variable\nconfig.add_variable(\"instance_type\", default=\"t2.micro\")\n\n# Add a resource\nconfig.add_resource(\"aws_instance\", \"example\", ami=\"ami-0abcdef1234567890\", instance_type=\"t2.micro\")\n\n# Format the configuration as HCL and print it\nhcl_config = config.format_config()\nprint(hcl_config)\n\n# Save the configuration to a file\nconfig.save(\"main.tf\")\n```\n\nThis example creates a basic Terraform configuration with:\n- An AWS provider configured for the `us-west-2` region.\n- A variable called `instance_type` with a default value.\n- A resource (AWS EC2 instance) with specified attributes.\n\n## API Overview\n\n### Core Classes\n\n- **HCLExpression**  \n  Wraps a raw HCL expression so that it is output without quotes when rendered.\n\n- **HCLBlock**  \n  Represents a generic HCL block. This class supports:\n  - Adding attributes (key/value pairs)\n  - Nesting blocks (useful for complex configurations)\n\n- **TerraformConfig**  \n  A configuration builder that provides methods to:\n  - `add_required_provider(provider_name, source, version)`: Specify a required provider.\n  - `add_provider(provider_name, **kwargs)`: Add a provider block.\n  - `add_variable(var_name, **kwargs)`: Define a variable.\n  - `add_resource(resource_type, resource_name, **kwargs)`: Define a resource.\n  - `add_module(module_name, source, **kwargs)`: Add a module.\n  - `format_config()`: Render the complete configuration as an HCL string.\n  - `save(filename)`: Write the configuration to a file.\n\n### Utility Functions\n\n- **render_value(value, indent=0)**  \n  Recursively renders a Python value (strings, numbers, booleans, lists, dicts, etc.) into an HCL-formatted string.\n\n- **is_simple_scalar(value)**  \n  Returns `True` if the value is a simple scalar (int, float, bool, str, or HCLExpression) that can be rendered inline.\n\n## Running Tests\n\nTo run the tests, execute the following command from the root of the project:\n\n```bash\npython -m unittest discover\n```\n\nThis command will discover and run all tests located in the `tests/` directory.\n\n## Contributing\n\nContributions are welcome! If you have suggestions or improvements:\n- Open an issue or submit a pull request on [GitHub](https://github.com/yourusername/terraforge).\n- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guidelines.\n- Include tests for any new features or bug fixes.\n\n## License\n\nThis project is licensed under the Apache License 2.0. See the LICENSE file for details.\n\n## Contact\n\nFor questions or feedback, please open an issue in the GitHub repository.\n\n---\n\nHappy Terraforming!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felmo33%2Fterraforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felmo33%2Fterraforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felmo33%2Fterraforge/lists"}