从cloudformation模板中绘制图像

时间:2018-01-04 20:18:55

标签: amazon-cloudformation aws-cli

我可以使用任何绘图/导出工具将cloudformation 模板转换为图表。

需要将cloudformation 堆栈导出到图像 graphviz 文件中。

此致

2 个答案:

答案 0 :(得分:1)

您可以使用AWS CloudFormation designer。点击打开,然后上传您的模板。最后截取结果的屏幕截图,使其以图像格式显示。

以下是结果可能的示例:

enter image description here

有关详细信息,请查看doc

答案 1 :(得分:1)

您可以使用cfn-lint工具的最新版本来从模板中获取资源图。

像这样使用它:

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

例如,它将生成一个如下所示的DOT文件:

Resource dependency graph

与此模板相对应:

{
  "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"
                ]
              }
            }
          ]
        }
      }
    }
  }
}

编辑CloudFormation模板时,CloudFormation Linter Visual Studio Code extension的右上角还有一个resource dependency graph preview button

Resource dependency graph in Visual Studio Code extension