• Stars
    star
    1,697
  • Rank 27,502 (Top 0.6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Read your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.

InfraMap

PkgGoDev AUR package Homebrew Join the chat at https://gitter.im/cycloidio/inframap

Read your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.

Cloud Providers

We support all cloud providers, but we have some (listed below) that we have specific logic that allows us to better represent information that comes from these providers.

For the other providers the resulting representation will simply be all resources present without any simplification or refinement.

For TFState generations we are limited to versions 3 and 4.

Provider State HCL Grouping1 External Nodes2 IAM3
AWS βœ”οΈ βœ”οΈ WIP βœ”οΈ βœ–οΈ (#11)
Google βœ”οΈ βœ”οΈ βœ–οΈ βœ–οΈ βœ–οΈ
Azure βœ”οΈ βœ”οΈ βœ–οΈ βœ–οΈ βœ–οΈ
OpenStack βœ”οΈ βœ”οΈ βœ–οΈ βœ–οΈ βœ–οΈ
FlexibleEngine βœ”οΈ βœ”οΈ βœ–οΈ βœ–οΈ βœ–οΈ
  1. Grouping: Group elements that belong to the same group like VPCs or regions
  2. External Nodes: Show the ingress of the Nodes if any
  3. IAM: Connections based on IAM (Identity Access Management)

Installation

Stable

To install the latest release of Inframap, you can pick one of this methods:

  • pull the latest release from the Releases page
  • pull the latest docker image from the Docker hub
  • use your Linux package manager (only AUR at the moment)

Development

You can build and install with the latest sources, you will enjoy the new features and bug fixes. It uses Go Modules (1.13+)

$ git clone https://github.com/cycloidio/inframap
$ cd inframap
$ go mod download
$ make build

Install via brew

If you're macOS user and using Homebrew, you can install via brew command:

$ brew install inframap

Usage

The inframap --help will show you the basics.

asciicast

The most important subcommands are:

  • generate: generates the graph from STDIN or file.
  • prune: removes all unnecessary information from the state or HCL (not supported yet) so it can be shared without any security concerns

Example

Visualizing with dot

$ inframap generate state.tfstate | dot -Tpng > graph.png

or from the terminal itself with graph-easy

$ inframap generate state.tfstate | graph-easy

or from HCL

$ inframap generate config.tf | graph-easy

or HCL module

$ inframap generate ./my-module/ | graph-easy

using docker image (assuming that your Terraform files are in the working directory)

$ docker run --rm -v ${PWD}:/opt cycloid/inframap generate /opt/terraform.tfstate

Note: InfraMap will guess the type of the input (HCL or TFState) by validating if it's a JSON and if it fails then we fallback to HCL (except if you send a directory on args, the it'll use HCL directly), to force one specific type you can use --hcl or --tfstate flags.

How is it different to terraform graph

Terraform Graph outputs a dependency graph of all the resources on the tfstate/HCL. We try to go one step further, by trying to make it human-readable.

If the provider is not supported, the output will be closer to the Terraform Graph version (without displaying provider / variable nodes)

Taking https://github.com/cycloid-community-catalog/stack-magento/ as a reference this is the difference in output:

With terraform graph:

With inframap generate ./terraform/module-magento/ | dot -Tpng > inframap.png:

With inframap generate --connections=false ./terraform/module-magento/ | dot -Tpng > inframapconnections.png:

With inframap generate ./terraform/module-magento/ --raw | dot -Tpng > inframapraw.png:

How does it work?

For each provider, we support specific types of connections; we have a static list of resources that can be nodes or edges. Once we identify the edges, we try to create one unique edge from the resources they connect.

For a state file, we rely on the dependencies key (for the <0.13 we replace all depends_on for dependencies so we support them) and, for HCL we rely on interpolation to create the base graph one which we then apply specific provider logic if supported. If not supported, then basic graph is returned.

FAQ

Why is my Graph generated empty?

If a graph is returned empty, it means that we support one of the providers you are using on your HCL/TFState but we do not recognize any connection or relevant node.

To show the configuration without any InfraMap applied logic you can use the --raw flag logic and print everything that we read. If it works, it would be good to try to know why it was empty before so we can take a look at it as it could potentially be an issue on InfraMap (open an issue if you want us to take a look).

By default unconnected nodes are removed, you can use --clean=false to prevent that.

Does InfraMap support Terraform backends ?

Terraform allows users to use backends (S3, Google Cloud Storage, Swift, etc.) in order to store the terraform.state. We currently do not support graph generation from tfstate stored in such backends. As mentioned in this issue, it is possible to play around stdin/out to generate graph from Terraform backends.

backend command
S3 aws s3 cp s3://bucket/path/to/your/file.tfstate - | inframap generate
GCS gsutil cat gs://bucket/path/to/your/file.tfstate | inframap generate

A general solution is also to just use terraform state pull \| inframap generate as it'll pull the state from whichever backend is actually stored

License

Please see the MIT LICENSE file.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Meet Cycloid

Cycloid is a hybrid cloud DevOps collaboration platform providing end-to-end frameworks to accelerate and industrialize software delivery.

As of now, we have three open-source tools:

  • TerraCognita: Read from your existing cloud providers and generate IaC in Terraform
  • InfraMap: Reads .tfstate or HCL to generate a graph specific for each provider
  • TerraCost: Cloud cost estimation for Terraform in the CLI

...and the functionality of each is also embedded in our DevOps solution, which you can find out more about here.

More Repositories

1

terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
Go
2,163
star
2

terracost

Cloud cost estimation for Terraform in your CLI
Go
283
star
3

cycloid-cli

Source code of Cycloid Command Line to interface Cycloid APIs
Go
17
star
4

raws

[UNMAINTAINED] AWS Reader
Go
15
star
5

cyclosible

Python
8
star
6

vuex-type-const-generator

Generate a file with constants for getters, actions and mutations from a Vuex store definition
JavaScript
6
star
7

ansible-backup

Shell
5
star
8

tfdocs

Generated structured documentation for Terraform Providers
Go
5
star
9

auth0-rules-runtime

Wrapper of webtask runtime for helping to write tests for Auth0 rules
JavaScript
3
star
10

import-index-generator

Autogenerate a JS modules which exports all the modules present on a directory
JavaScript
3
star
11

aws-billing

Import detailed billing from AWS
Go
3
star
12

goat

Go SDK for auth0 API
Go
2
star
13

mxwriter

MXWriter is a small library that emulates a Multiplexer and Demultiplexer for io.Write.
Go
2
star
14

cycloid-hooks

Gathering of hooks used at cycloid
Shell
2
star
15

gopa

GO Client for OPA
Go
2
star
16

flatmap

This lib is a "fork" from of "terraform/flatmap" v0.14.10
Go
2
star
17

ansible-ecs

Install ECS-agent on servers
1
star
18

docker-cycloid-toolkit

Docker image which contain tools and a scripts for cycloid.io
Python
1
star
19

ansible-php

Jinja
1
star
20

docker-image-mailslurper

Dockerized MailsSlurper
Dockerfile
1
star
21

cycloid-resource

Concourse resource to use Cycloid features inside pipelines
Go
1
star
22

ansible-telegraf

Cycloid wrapper who call dj-wasabi/ansible-telegraf role and add some additionnal plugins
Python
1
star
23

ansible-systemd

Complement of https://github.com/tumf/ansible-role-systemd-service.git to provide features like mount and timer
1
star
24

ansible-backup-snapshot

Jinja
1
star
25

sqlr

Set of useful interfaces to work with the GO 'database/sql'
Go
1
star
26

approval-resource

Python
1
star
27

ansible-cyclosible

1
star
28

bootstrap-stacks

Collection of stack templates to be used by customer to create simple functioning stack
HCL
1
star