modules.tf — Convert visual AWS diagram into Terraform configurations

I am excited to announce the public-release of modules.tf, which allows a conversion from visual AWS diagrams using cloudcraft.co to infrastructure code using Terraform.

See this in action (added 21.3.2019):

modules.tf demo — from visual diagrams (cloudcraft.co) to infrastructure as code using Terraform

Features

  • Resources with arguments once specified during creation of diagrams are present in infrastructure code.
  • Most popular EC2 types of resources are supported, more will be added in the future. VPC, Security group, Autoscaling Group, RDS, ELB, ALB, SNS, SQS, EC2 instances are implemented already.
  • Many of relations between resources and their dependencies are respected in infrastructure code. For example, ELB will be created before Autoscaling Group, VPC will be created before Autoscaling Group and ELB.
  • Incorrect relations are ignored. For example, ELB can’t depend on RDS even if a user draws a connection in a diagram.
  • The orchestration of infrastructure modules is supported. Thanks to built-in features of Terragrunt.
  • Dynamic values in terraform.tfvars are supported! Dependent arguments are updated by a link. (Hack or know-how — you decide)
  • The generated code is good for bootstrap.
  • The generated code is not a boilerplate which you should rewrite entirely — it is a working solution for small and medium infrastructures.

Excited? Let’s walk through some components to see how to convert your AWS diagram to Terraform infrastructure code.

First, Cloudcraft.co

Here are visual diagrams for 2-tier web-applications hosted on AWS:

Typical 2-tier web-application hosted on AWS may use a couple of auto-scaling groups, a couple of ELBs, RDS instances, CloudFront (CDN) and Route53 (DNS).
Same 2-tier web-application with VPC and security groups added to the picture.

Terraform

Terraform is a well-known (and my favorite) tool to write, plan and create infrastructure as code.

NB: modules.tf generates infrastructure code and relies on Terragrunt for heavy-lifting. Terragrunt is used as a wrapper for Terraform modules, allows orchestration of dependencies, updates of arguments dynamically and keeps infrastructure configurations DRY.

Terraform AWS modules

https://github.com/terraform-aws-modules — these building blocks of AWS infrastructure are used by thousands of people around the globe. As a core maintainer, it was natural for me to bring them as first-class citizens to modules.tf.

Let’s try it!

  • Once you draw AWS infrastructure, which can be a single resource or several interconnected resources (as shown above), you should click “Export” and then “Terraform code export” in top-right corner.
  • Zip-archive with all configurations and extra files will be generated dynamically.
  • Extract content of this archive into your working directory and read README.md which is inside. It contains all information about dependencies, and how to create the desired infrastructure.

Notes

  1. modules.tf is open-source, MIT licensed. Source code: https://github.com/antonbabenko/modules.tf-lambda
  2. modules.tf is using AWS Lambda and running Serverless framework with Python 3.6
  3. modules.tf is free for all. It is available for all types of users on cloudcraft.co (including free users)
  4. modules.tf has support for a limited amount of AWS resources, because we don’t have Terraform AWS modules for all of them (yet).
  5. This is the first iteration of public release, and definitely contain bugs. I couldn’t imagine what kind of scenarios people were building, so PLEASE report problems on GitHub issues. I am especially interested in learning about any usability issues or problems with the developer experience. What makes you stuck? What is not logical? What is simply missing? What is useless? What would be AMAZING?
  6. modules.tf — is also a static web-site, but I have not updated it yet :)

Summary

Go to cloudcraft.co, open an account (free is fine, too), draw your AWS infrastructure, click “Export” then “Terraform code export”, download and unzip archive, read README.md.


Please share and clap on this post to support my work!

If you want to stay updated with what I am working on, or hire me — follow me on Twitter, GitHub, LinkedIn and Medium.