{"id":23654878,"url":"https://github.com/stocard/terraform-js","last_synced_at":"2025-09-01T06:32:29.648Z","repository":{"id":48017714,"uuid":"184254214","full_name":"Stocard/terraform-js","owner":"Stocard","description":"A TypeScript/JavaScript wrapper around terraform and terragrunt","archived":false,"fork":false,"pushed_at":"2023-07-10T23:03:28.000Z","size":206,"stargazers_count":8,"open_issues_count":6,"forks_count":7,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-28T04:04:25.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Stocard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-30T11:59:43.000Z","updated_at":"2023-04-23T10:08:09.000Z","dependencies_parsed_at":"2022-08-12T16:50:11.815Z","dependency_job_id":null,"html_url":"https://github.com/Stocard/terraform-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stocard%2Fterraform-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stocard%2Fterraform-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stocard%2Fterraform-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stocard%2Fterraform-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stocard","download_url":"https://codeload.github.com/Stocard/terraform-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231670153,"owners_count":18408698,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-28T19:34:16.143Z","updated_at":"2024-12-28T19:34:16.906Z","avatar_url":"https://github.com/Stocard.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS-Terraform\n\nA TypeScript/JavaScript wrapper around Terraform and Terragrunt. Fully Promise-based.\n\n* [Installation](#installation)\n* [Terraform](#terraform)\n* [Terragrunt](#terragrunt)\n\n## Installation\n\n```sh\n$ npm install js-terraform\n```\nor\n\n```sh\n$ yarn add js-terraform\n```\n\n## Terraform\n\nCreate a new `Terraform` instance:\n```js\nconst {Terraform} = require('js-terraform');\nconst terraform = new Terraform()\n```\n\n### Functions\n\n#### `init(path: string, options: ExecuteOptions): Promise\u003cvoid\u003e`\n\nExecutes `terraform init` on the given `path`.\n\nOptions: [ExecuteOptions](#ExecuteOptions): `silent` defaults to `true`\n\n#### `plan(path: string, options: ExecuteOptions): Promise\u003cResourceCounts\u003e`\n\nExecutes `terraform plan` on the given `path`. Returns [ResourceCounts](#ResourceCounts).\n\nOptions: [ExecuteOptions](#ExecuteOptions): `silent` defaults to `true`\n\n#### `destroy(path: string, options: DestroyOptions): Promise\u003cResourceCounts\u003e`\nExecutes `terraform destroy` on the given `path`. Returns [ResourceCounts](#ResourceCounts).\n\nOptions: [DestroyOptions](#InteractiveOptions): `silent` defaults to `false`, `autoApprove` defaults to `false`\n\n#### `apply(path: string, options: ApplyOptions): Promise\u003cResourceCounts\u003e`\n\nExecutes `terraform apply` on the given `path`. Returns an `ResourceCounts` object with information how many resources were added, changed or destroyed.\n\nOptions: [ApplyOptions](#InteractiveOptions): `silent` defaults to `false`, `autoApprove` defaults to `false`\n\n#### `getOutputKeys(path: string, options: ExecuteOptions) Promise\u003cstring[]\u003e`\n\nExecutes `terraform output -json` on the given `path` and returns the keys. E.g. when you have two outputs \n  ```hcl\n  output \"output_1\" {\n    value = \"1\"\n  }\n  output \"output_2\" {\n    value = \"2\"\n  }\n  ```\n\n  the function would return `['output_1', 'output_2]`\n  \nOptions: [ExecuteOptions](#ExecuteOptions): `silent` defaults to `true`\n\n#### `outputValue(path: string, value: string, options: OutputOptions) Promise\u003cSimpleOutput | Output\u003e`\n\nExecutes `terraform output -json ${value}` on the given `path` and returns the value. E.g. for\n  ```hcl\n  output \"output_1\" {\n    value = \"1\"\n  }\n  ```\n\n  the function would return `{'output_1': 1}` (when `simple: true`) or \n\n  ```js\n  output_1: {\n        sensitive: false,\n        type: 'string',\n        value: '1'\n    }\n  ```\n  when `simple: false`\n\nOptions: [OutputOptions](#OutputOptions): `silent` defaults to `true`, `simple` defaults to `true`\n\n#### `outputValue(path: string,options: OutputOptions) Promise\u003cSimpleOutput | Output\u003e`\n\nExecutes `terraform output -json` on the given `path` and returns the values. E.g. for\n  ```hcl\n  output \"output_1\" {\n    value = \"1\"\n  }\n  output \"output_2\" {\n    value = \"2\"\n  }\n  ```\n\n  the function would return `{'output_1': 1, 'output_2': 2}` (`simple: true`) or \n\n  ```js\n  output_1: {\n        sensitive: false,\n        type: 'string',\n        value: '1'\n    },\n    output_2: {\n        sensitive: false,\n        type: 'string',\n        value: '3'\n    }\n  ```\n\n  when `simple: false`\n\nOptions: [OutputOptions](#OutputOptions): `silent` defaults to `true`, `simple` defaults to `true`\n\n\n\n## Terragrunt\n\nCreate a new `Terragrunt` instance:\n```js\nconst terragrunt = new Terragrunt()\n```\n\n### `applyAll(path: string, options: ApplyOptions = {}): Promise\u003cvoid\u003e`\n\nExecutes `terragrunt apply` on the given `path`. Returns void.\n\nOptions: [ApplyOptions](#InteractiveOptions): `silent` defaults to `false`, `autoApprove` defaults to `false`\n\n### `destroyAll(path: string, options: DestroyOptions = {}): Promise\u003cvoid\u003e`\n\nExecutes `terragrunt destroy` on the given `path`. Returns void.\n\nOptions: [DestroyOptions](#InteractiveOptions): `silent` defaults to `false`, `autoApprove` defaults to `false`\n\n### `planAll(path: string, options: ExecuteOptions = {}): Promise\u003cvoid\u003e`\n\nExecutes `terragrunt destroy` on the given `path`. Returns void.\n\nOptions: [ExecuteOptions](#ExecuteOptions): `silent` defaults to `false`\n\n### `output`\n\nSame signature and options as the `Terraform.output` function, except that it uses `terragrunt`\n\n### `outputValue`\n\nSame signature and options as the `Terraform.outputValue` function, except that it uses `terragrunt`\n\n### `getOutputKeys`\n\nSame signature and options as the `Terraform.getOutputKeys` function, except that it uses `terragrunt`\n\n## Types\n\n#### ExecuteOptions\n\n```ts\ninterface ExecuteOptions {\n  silent?: boolean\n}\n```\n\n#### OutputOptions\n\n```ts\ninterface OutputOptions {\n  silent?: boolean\n  simple?: boolean\n}\n```\n\n\n#### InteractiveOptions\n\n```ts\ninterface InteractiveOptions {\n  autoApprove?: boolean\n  silent?: boolean\n}\n```\n`DestroyOptions` and `ApplyOptions` are an alias for `InteractiveOptions`\n\n#### ResourceCounts\n```js\ntype ResourceCounts = {\n  addCount: number\n  changeCount: number\n  destroyCount: number\n}\n```\nInformation how many resources are added, changed or destroyed. \n\n## Silent mode\n\nMany functions have the possibility to be executed in silent mode by passing a `silent` flag in the options object. If `silent: true` no output is passed to any logger nor the output streams (more on that below)! \n\nThe default depends on the function, please read the documentation carefully!\n\n## Custom loggers\n\nThere are two different ways of \"logging\", the `logger` and `outputStreams`\n\n* `logger`: Is used for any `terraform`/`terragrunt` function which does not need any interactive input (`plan`, `output`..). The default logger is `console.log`. You can pass a custom logger by calling `setLogger` for, e.g. writing data to a file. But be careful, `silent` must be `true` when you use custom logger and want to get the output\n\n* `outputStreams` (`out` and `err`): Are used for any `terraform`/`terragrunt` function which needs input by the user (`apply`, `destroy`...) The default streams are `process.stderr` and `process.stdout`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstocard%2Fterraform-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstocard%2Fterraform-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstocard%2Fterraform-js/lists"}