An open API service indexing awesome lists of open source software.

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

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.

![Tool Overview](assets/tfconfigbuilder.drawio.png)

> 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
```