使用[Pluralith]Terraform代码创建配置图/架构
首先
我听说有一个名为Pluralith的工具,它能够从Terrafom代码中创建构图。我想验证一下它的使用感受。
公式网页
公式文件
费用

公式页面的价格
进行此操作的步骤是什么?
用户注册

为了这次活动的本地实施,选择本地设置。
选择CI设置后,可以在Github Actions或Terraform Cloud中执行。
我在开头提到了一件事,据说在CI设置上需要支付费用,所以这次我选择了本地设置进行测试。

设置
官方网页
选择下载命令行界面(CLI),然后下载模块。
請把在Login中提到的Key儲存起來,因為稍後在登錄時會用到。

在更改模块名称后,通过以下命令设置路径并授予执行权限。
mv pluralith_cli_darwin_amd64_v0.2.2 pluralith
mv pluralith /usr/local/bin/
chmod 755 /usr/local/bin/pluralith
由于可以执行命令pluralith,请设置上述显示的密钥并登录。
pluralith login --api-key 7b2f928475b3bdxxxxxxxxx
如果显示如下,则可以确认是正确的。
✔ No graph module installed, found latest release
⠿ None → 0.2.1
Installing Latest Graph Module 100% [██████████████████████████████] (22.656 MB/s)
✔ Graph Module updated!
_
|_)| _ _ |._|_|_
| ||_|| (_||| | | |
Welcome to Pluralith!
✔ API key is valid, you are authenticated!
这样配置就完成了。
执行Pluralith并进行构图
运行Terraform目录并执行以下命令。
pluralith graph
由于未执行terraform init命令,因此出现了以下错误。看起来它已经检查了tfstate的存储位置。
⠿ Initiating Graph ⇢ Posting Diagram To Pluralith Dashboard
→ Authentication
✔ API key is valid, you are authenticated!
→ Plan
✘ Couldn't Generate Local Execution Plan
Error: Backend initialization required, please run "terraform init"
Reason: Initial configuration of the requested backend "s3"
The "backend" is the interface that Terraform uses to store state,
perform operations, etc. If this message is showing up, it means that the
Terraform configuration you're using is using a custom configuration for
the Terraform backend.
Changes to backend configurations require reinitialization. This allows
Terraform to set up the new configuration, copy existing state, etc. Please
run
"terraform init" with either the "-reconfigure" or "-migrate-state" flags to
use the current configuration.
If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existing
configuration or state have been made.
running terraform plan failed -> GenerateGraph: RunPlan: exit status 1

确认更改差异
由于屏幕右下角显示了”Created”或”Update”等内容,因此我决定尝试修改Terraform代码并进行实施。
如果要全部删除的话

如果有任何更改

其他功能
费用显示

执行历史

填补
运行`pluralith`命令后,确认目录存在名为`directory`的目录。
如果将其包含在GitHub等中,似乎可以共享执行记录等。
.
├── .DS_Store
├── .pluralith
│ ├── pluralith.cache.json
│ ├── pluralith.plan.bin
│ └── pluralith.state.json
├── .terraform
│ ├── modules
│ │ └── modules.json
│ ├── providers
│ │ └── registry.terraform.io
│ │ └── hashicorp
│ │ └── aws
│ │ └── 4.55.0
│ │ └── darwin_arm64
│ │ └── terraform-provider-aws_v4.55.0_x5
│ └── terraform.tfstate
├── .terraform.lock.hcl
├── cloudfront-s3.tf
├── datasource.tf
├── locals.tf
├── modules
│ ├── .DS_Store
│ └── public-static-web
│ ├── .DS_Store
│ ├── cloudfront.tf
│ ├── img
│ │ ├── error.html
│ │ ├── index.html
│ │ └── mock_img.jpeg
│ ├── output.tf
│ ├── s3.tf
│ └── variables.tf
├── provider.tf
├── terraform.tfvars
└── variables.tf
13 directories, 23 files
最后的话
-
- これまで、Terraformコードから構成図を作成するものはいくつかあったが、moduleに対応していないなど、少し不便なところがあったがPluralithはStateファイルから読みってくれるのでかなり良い。
- 構成図作成する際はもうこれで良いんじゃないかなと思う。
请你提供一篇日志作为参考。