modules.tf — Convert visual AWS diagram into Terraform configuration
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):
- 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.tfvarsare 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.
Here are visual diagrams for 2-tier web-applications hosted on AWS:
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.mdwhich is inside. It contains all information about dependencies, and how to create the desired infrastructure.
- modules.tf is open-source, MIT licensed. Source code: https://github.com/antonbabenko/modules.tf-lambda
- modules.tf is using AWS Lambda and running Serverless framework with Python 3.6
- modules.tf is free for all. It is available for all types of users on cloudcraft.co (including free users)
- modules.tf has support for a limited amount of AWS resources, because we don’t have Terraform AWS modules for all of them (yet).
- 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?
- modules.tf — is also a static web-site, but I have not updated it yet :)
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