https://github.com/tatomoaki/tfconfigbuilder
Parse and convert draw.io xml files into Terraform configuration file
https://github.com/tatomoaki/tfconfigbuilder
drawio terraform xml
Last synced: 6 months ago
JSON representation
Parse and convert draw.io xml files into Terraform configuration file
- Host: GitHub
- URL: https://github.com/tatomoaki/tfconfigbuilder
- Owner: tatomoaki
- License: mit
- Created: 2023-11-16T17:27:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-19T12:03:21.000Z (over 2 years ago)
- Last Synced: 2025-03-12T21:40:28.373Z (over 1 year ago)
- Topics: drawio, terraform, xml
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tfconfigbuilder
tfconfigbuilder is a Proof of Concept command-line tool that parses and converts an infrastructure diagram drawn in [draw.io](https://www.drawio.com/) and exported as an xml file into a terraform configuration file. Support is only for infrastructure mappings targeted at AWS resources.

> Note, this project is WIP and still experimental. No guarantees are provided.
## Getting Started
These instructions will get you a copy of the project on your local machine for development and testing purposes.
Before you begin, ensure you have the following installed:
* Go (~ 1.20)
* Terraform
### Installing
To get stated with `tfconfigbuilder`:
```bash
git clone https://github.com/tatomoaki/tfconfigbuilder.git
cd tfconfigbuilder
go build -o tfconfigbuilder
```
### Usage
To generate a HCL file using `tfconfigbuilder`:
1. Draw your AWS infrastructure in [draw.io](https://www.drawio.com/).
2. Export file as an uncompressed XML File. (File -> Export as -> XML -> Export -> Save to filesystem)
3. Run `tfconfigbuilder` tool with command below.
```bash
./tfconfigbuilder gen --file path/to/your/draw.io.xml
```
Assuming you have an XML file with this content below:
```xml
```
`tfconfigbuilder` will convert above XML content into this Terraform configuration file
```terraform
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "af-south-1"
}
resource "aws_instance" "this" {
instance_type = "t2.micro"
}
```
### Testing
To run tests, use the following command
```bash
go test ./... -coverage=coverage.out
```
This will generate a coverage report, which can be viewed by running
```bash
go tool cover -html=coverage.out
```