Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing an image from a cloudformation template

Is the any drawing / export tool that I can use to turn a cloudformation template into a diagram.

In need to export my cloudformation stack into an image, or a graphviz file.

Regards,

like image 514
waghanza Avatar asked Mar 07 '23 05:03

waghanza


2 Answers

You can use the latest version of the cfn-lint tool to get a graph of resources from your template.

Use it like this:

pip3 install cfn-lint pydot
cfn-lint template.json -g

For example, it will generate a DOT file that renders like this:

Resource dependency graph

Which corresponds to this template:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Sample template that demonstrates Fn::GetAtt",
  "Resources": {
    "DetectTextInImage": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Role": {
          "Fn::GetAtt": [
            "DetectTextInImageRole",
            "Arn"
          ]
        }
      }
    },
    "DetectTextInImageBucketEvent1Permission": {
      "Type": "AWS::Lambda::Permission",
      "Properties": {}
    },
    "DetectTextInImageRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {}
    },
    "ResultsTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {}
    },
    "SourceImageBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "NotificationConfiguration": {
          "LambdaConfigurations": [
            {
              "Function": {
                "Fn::GetAtt": [
                  "DetectTextInImage",
                  "Arn"
                ]
              }
            }
          ]
        }
      }
    }
  }
}

The CloudFormation Linter Visual Studio Code extension also has a resource dependency graph preview button in the top right while editing CloudFormation templates:

Resource dependency graph in Visual Studio Code extension

like image 111
Maria Ines Parnisari Avatar answered Mar 09 '23 17:03

Maria Ines Parnisari


You can use the AWS CloudFormation designer. Click on Open, then upload your template. Finally take a screenshot of the result to have it in an image format.

Here's an exemple of what the result might look like:

enter image description here

For more information, have a look at the doc.

like image 21
Laurent Jalbert Simard Avatar answered Mar 09 '23 19:03

Laurent Jalbert Simard