cycloidio / inframap

Read your tfstate or HCL to generate a graph specific for each provider, showing only the resources that are most important/relevant.
MIT License
1.76k stars 95 forks source link

No return code #157

Open emergrin opened 3 years ago

emergrin commented 3 years ago

Hi all

I'm trying to test your code into my OS Ubuntu 20.04.3 and this was the response when I run the program:

$./inframap generate ~/IdeaProjects/terraform/tfstate/ad_connector.tfstate 
strict digraph G {

}

I was try to use the version allocated into brew repository and then I was try to compile the code like it's appear into your readme. Now I have the compiler version from your git repo:

$./inframap version
The current version is: v0.6.7-1-gd9632dd

Any suggestion of what i did wrong?

Best Regards

xlr-8 commented 3 years ago

Hello @emergrin,

Would you mind sharing a bit the content of the tfstate (removing sensitive info, if any). The support from provider to provider can vary quite a bit, and so can the overall linking/grouping logic.

Thanks for the help

emergrin commented 3 years ago

Thank for your reply... I can add this data:

Provider: AWS tfstate file:

{
  "version": 4,
  "terraform_version": "0.15.3",
  "serial": 0,
  "lineage": "XXXXXXXXXXXXXXXXXX-1ef8-2fe0-5262-XXXXXXXXXXXXXXXXXX",
  "outputs": {
    "connector_id": {
      "value": "d-XXXXXXXXXXXXXXXXXX",
      "type": "string"
    },
    "da04_ip": {
      "value": "10.12.108.56",
      "type": "string"
    },
    "da05_ip": {
      "value": "10.12.119.98",
      "type": "string"
    },
    "dns_ip_addresses": {
      "value": [
        "10.12.106.60",
        "10.12.115.125"
      ],
      "type": [
        "set",
        "string"
      ]
    },
    "security_group_id": {
      "value": "sg-XXXXXXXXXXXXXXXXXX",
      "type": "string"
    }
  },
  "resources": [
    {
      "mode": "data",
      "type": "aws_secretsmanager_secret",
      "name": "ad_XXXXXXX",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:secretsmanager:eu-west-1:000000000000:secret:XXXXXXX",
            "description": "Service Account for AD Connector",
            "id": "arn:aws:secretsmanager:eu-west-1:000000000000:secret:XXXXXXX",
            "kms_key_id": "",
            "name": "XXXXXXX",
            "policy": "",
            "rotation_enabled": false,
            "rotation_lambda_arn": "",
            "rotation_rules": [],
            "tags": {}
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "aws_secretsmanager_secret_version",
      "name": "XXXXXXX",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:secretsmanager:eu-west-1:000000000000:secret:XXXXXXX",
            "id": "arn:aws:secretsmanager:eu-west-1:000000000000:secret:XXXXXXX|AWSCURRENT",
            "secret_binary": "",
            "secret_id": "arn:aws:secretsmanager:eu-west-1:000000000000:secret:XXXXXXX",
            "secret_string": "{\"Password\":\"XXXXXXX\",\"Account\":\"XXXXXXX\"}",
            "version_id": "XXXXXXXXXXX-6467-404e-ad90-XXXXXXXXXXXXXXXXXX",
            "version_stage": "AWSCURRENT",
            "version_stages": [
              "AWSCURRENT"
            ]
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "aws_subnet_ids",
      "name": "private_subnet_ids_eu_west_1a",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "filter": [
              {
                "name": "availability-zone",
                "values": [
                  "eu-west-1a"
                ]
              },
              {
                "name": "tag:Tier",
                "values": [
                  "services2"
                ]
              }
            ],
            "id": "vpc-0000000000000000",
            "ids": [
              "subnet-0000000000000000"
            ],
            "tags": null,
            "vpc_id": "vpc-0000000000000000"
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "aws_subnet_ids",
      "name": "private_subnet_ids_eu_west_1b",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "filter": [
              {
                "name": "availability-zone",
                "values": [
                  "eu-west-1b"
                ]
              },
              {
                "name": "tag:Tier",
                "values": [
                  "services2"
                ]
              }
            ],
            "id": "vpc-0000000000000000",
            "ids": [
              "subnet-0000000000000000"
            ],
            "tags": null,
            "vpc_id": "vpc-0000000000000000"
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "aws_vpc",
      "name": "vpc_dev",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:eu-west-1:000000000000:vpc/vpc-0000000000000000",
            "cidr_block": "10.12.0.0/16",
            "cidr_block_associations": [
              {
                "association_id": "vpc-cidr-assoc-0000000000000000",
                "cidr_block": "10.12.0.0/16",
                "state": "associated"
              }
            ],
            "default": false,
            "dhcp_options_id": "dopt-XXXXXXXXXXXXXXXXXX",
            "enable_dns_hostnames": true,
            "enable_dns_support": true,
            "filter": null,
            "id": "vpc-0000000000000000",
            "instance_tenancy": "default",
            "ipv6_association_id": null,
            "ipv6_cidr_block": null,
            "main_route_table_id": "rtb-XXXXXXXXXXXXXXXXXX",
            "owner_id": "000000000000",
            "state": "available",
            "tags": {
              "Environment": "dev",
              "Name": "ec_vpc_dev",
              "Terraform": "true"
            }
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "aws_vpc",
      "name": "vpc_prod",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "arn": "arn:aws:ec2:eu-west-1:000000000000:vpc/vpc-0000000000000000",
            "cidr_block": "10.11.0.0/16",
            "cidr_block_associations": [
              {
                "association_id": "vpc-cidr-assoc-0000000000000000",
                "cidr_block": "10.11.0.0/16",
                "state": "associated"
              }
            ],
            "default": false,
            "dhcp_options_id": "dopt-XXXXXXXXXXXXXXXXXX",
            "enable_dns_hostnames": true,
            "enable_dns_support": true,
            "filter": null,
            "id": "vpc-0000000000000000",
            "instance_tenancy": "default",
            "ipv6_association_id": null,
            "ipv6_cidr_block": null,
            "main_route_table_id": "rtb-XXXXXXXXXXXXXXXXXX",
            "owner_id": "000000000000",
            "state": "available",
            "tags": {
              "Environment": "prod",
              "Name": "ec_vpc_prod",
              "Terraform": "true"
            }
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "data",
      "type": "terraform_remote_state",
      "name": "ad_ec2",
      "provider": "provider[\"terraform.io/builtin/terraform\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "backend": "s3",
            "config": {
              "value": {
                "bucket": "XXXXXXXXXXXXXXXXX",
                "key": "XXXXXX.tfstate",
                "profile": "XXXXXXX",
                "region": "eu-west-1"
              },
              "type": [
                "object",
                {
                  "bucket": "string",
                  "key": "string",
                  "profile": "string",
                  "region": "string"
                }
              ]
            },
            "defaults": null,
            "outputs": {
              "value": {
                "da04_ip": "10.12.108.56",
                "da05_ip": "10.12.119.98"
              },
              "type": [
                "object",
                {
                  "da04_ip": "string",
                  "da05_ip": "string"
                }
              ]
            },
            "workspace": null
          },
          "sensitive_attributes": []
        }
      ]
    },
    {
      "mode": "managed",
      "type": "aws_directory_service_directory",
      "name": "connector",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "access_url": "e-XXXXXXXXXXX.awsapps.com",
            "alias": "e-XXXXXXXXXXX",
            "connect_settings": [
              {
                "availability_zones": [
                  "eu-west-1a",
                  "eu-west-1b"
                ],
                "connect_ips": [
                  "10.12.106.60",
                  "10.12.115.125"
                ],
                "customer_dns_ips": [
                  "10.12.108.56",
                  "10.12.119.98"
                ],
                "customer_username": "adconnector",
                "subnet_ids": [
                  "subnet-0000000000000000",
                  "subnet-0000000000000000"
                ],
                "vpc_id": "vpc-0000000000000000"
              }
            ],
            "description": "",
            "dns_ip_addresses": [
              "10.12.106.60",
              "10.12.115.125"
            ],
            "edition": "",
            "enable_sso": false,
            "id": "e-XXXXXXXXXXX",
            "name": "domain.int",
            "password": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
            "security_group_id": "sg-XXXXXXXXXXX",
            "short_name": "domain",
            "size": "Small",
            "tags": null,
            "tags_all": {},
            "type": "ADConnector",
            "vpc_settings": []
          },
          "sensitive_attributes": [
            [
              {
                "type": "get_attr",
                "value": "password"
              }
            ]
          ],
          "private": "XXXXXXXXXXXXX",
          "dependencies": [
            "data.aws_secretsmanager_secret_version.ad_connector",
            "data.aws_subnet_ids.private_subnet_ids_eu_west_1a",
            "data.aws_subnet_ids.private_subnet_ids_eu_west_1b",
            "data.aws_vpc.vpc_dev",
            "data.terraform_remote_state.ad_ec2"
          ]
        }
      ]
    }
  ]
}
xescugc commented 3 years ago

The main reason why this is not printed is because those are "data" resources, and we never print them as they are not infrastructure objects. And the idea behind InfraMap is to display only the relevant resources that define your infrastrucure.