从 cloudformation 模板绘制图像

wag*_*nza 6 aws-cloudformation aws-cli

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

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

问候,

Mar*_*ari 6

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

像这样使用它:

pip3 install cfn-lint pydot
cfn-lint template.json -g
Run Code Online (Sandbox Code Playgroud)

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

资源依赖图

对应这个模板:

{
  "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"
                ]
              }
            }
          ]
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

在编辑 CloudFormation 模板时, CloudFormation Linter Visual Studio Code 扩展的右上角还有一个资源依赖关系图预览按钮:

Visual Studio Code 扩展中的资源依赖关系图


Lau*_*ard 4

您可以使用AWS CloudFormation 设计器。单击“打开”,然后上传您的模板。最后截取结果的屏幕截图以将其转换为图像格式。

下面是结果的示例:

在此输入图像描述

有关更多信息,请查看文档。