@667/terraform-ts 中文文档教程

发布于 4年前 浏览 21 项目主页 更新于 3年前

terraform-ts

用于 terraform CLI 的 Javascript 包装器。

支持除 terraform console 之外的所有命令。

Installation

npm install terraform-ts

Usage

有关详细文档,请参阅生成的 API 文档

Using the Terraform Class

import { Terraform, Parse } from "terraform-ts"

const tf = new Terraform({
    path: "/path/to/terraform",
    cwd: "/path/to/project"
})

tf.workspaceList().then(console.log)

//   workspace1
// * workspace2
//   workspace3

Functional Style

import { exec, map, Config, WorkspaceList, WorkspaceSelect, WorkspaceNew } from 'terraform-ts'

const cfg = Config({ cwd: "/path/to/project" })

// execute a single command
exec(WorkspaceNew("test-2"), cfg).then((console.log))

//> * default


// execute multiple commands
const commands = [
    WorkspaceNew("test-1"),
    WorkspaceSelect("default")
    WorkspaceList()
]

mapExec(commands, cfg).then(results => results.forEach(console.log))

// logs output of each command

terraform-ts

A Javascript wrapper for terraform CLI.

Supports all commands with the exception of terraform console.

Installation

npm install terraform-ts

Usage

See the generated API Docs for detailed documentation.

Using the Terraform Class

import { Terraform, Parse } from "terraform-ts"

const tf = new Terraform({
    path: "/path/to/terraform",
    cwd: "/path/to/project"
})

tf.workspaceList().then(console.log)

//   workspace1
// * workspace2
//   workspace3

Functional Style

import { exec, map, Config, WorkspaceList, WorkspaceSelect, WorkspaceNew } from 'terraform-ts'

const cfg = Config({ cwd: "/path/to/project" })

// execute a single command
exec(WorkspaceNew("test-2"), cfg).then((console.log))

//> * default


// execute multiple commands
const commands = [
    WorkspaceNew("test-1"),
    WorkspaceSelect("default")
    WorkspaceList()
]

mapExec(commands, cfg).then(results => results.forEach(console.log))

// logs output of each command
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文