{"id":15022620,"url":"https://github.com/puppetlabs/puppetlabs-terraform","last_synced_at":"2025-08-24T22:31:07.297Z","repository":{"id":49110270,"uuid":"214280970","full_name":"puppetlabs/puppetlabs-terraform","owner":"puppetlabs","description":"Bolt Terraform plugin","archived":false,"fork":false,"pushed_at":"2024-11-20T12:55:50.000Z","size":104,"stargazers_count":6,"open_issues_count":5,"forks_count":20,"subscribers_count":64,"default_branch":"main","last_synced_at":"2025-07-23T21:17:48.365Z","etag":null,"topics":["module","supported"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/puppetlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-10T20:37:04.000Z","updated_at":"2024-03-02T21:21:57.000Z","dependencies_parsed_at":"2024-12-24T15:13:47.848Z","dependency_job_id":"519c2059-88e0-4900-99d9-ed59299b658e","html_url":"https://github.com/puppetlabs/puppetlabs-terraform","commit_stats":{"total_commits":48,"total_committers":9,"mean_commits":5.333333333333333,"dds":0.7916666666666666,"last_synced_commit":"1550fd17fa9b589c1d722ecae46df5f9cf4fb21b"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/puppetlabs/puppetlabs-terraform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puppetlabs","download_url":"https://codeload.github.com/puppetlabs/puppetlabs-terraform/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-terraform/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268331162,"owners_count":24233197,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["module","supported"],"created_at":"2024-09-24T19:58:12.534Z","updated_at":"2025-08-02T03:37:19.389Z","avatar_url":"https://github.com/puppetlabs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform\n\n#### Table of Contents\n\n1. [Description](#description)\n2. [Requirements](#requirements)\n3. [Usage](#usage)\n\n## Description\n\nThe Terraform plugin module supports looking up target objects from a Terraform state file, applying, destroying and querying outputs from Terraform project directories.\n\n## Requirements\n\nYou will need to have installed `Terraform` on the system you wish to run bolt from. The executable must be on the system `$PATH`. \n\n## Inventory plugin usage\n\nThe `resolve_reference` task supports looking up target objects from a Terraform state file. It accepts several fields:\n\n-   `dir`: The directory containing either a local Terraform state file or Terraform configuration to read remote state from. Relative to the active Boltdir unless absolute path is specified.\n-   `resource_type`: The Terraform resources to match, as a regular expression.\n-   `state`: (Optional) The name of the local Terraform state file to load, relative to `dir` (defaults to `terraform.tfstate)`.\n-   `backend`: (Optional) The type of backend to load the state form, either `remote` or `local` (defaults to `local`).\n-   `target_mapping`: A hash of target attributes to populate with resource values (e.g. `target_mapping: { name: 'id' }`).\n\nThe `target_mapping` parameter requires either a `uri` or `name` field. If only `uri` is set, the value of `uri` is used as the `name`.\n\n### Examples\n\n```yaml\ngroups:\n  - name: cloud-webs\n    targets:\n      - _plugin: terraform\n        dir: /path/to/terraform/project1\n        resource_type: google_compute_instance.web\n        target_mapping:\n          uri: network_interface.0.access_config.0.nat_ip\n      - _plugin: terraform\n        dir: /path/to/terraform/project2\n        resource_type: aws_instance.web\n        target_mapping:\n          uri: public_ip\n```\n\nMultiple resources with the same name are identified as \u003cresource\u003e.0, \u003cresource\u003e.1, etc.\n\nThe path to nested properties must be separated with `.`: for example, `network_interface.0.access_config.0.nat_ip`.\n\nFor example, the following truncated output creates two targets, named `34.83.150.52` and `34.83.16.240`. These targets are created by matching the resources `google_compute_instance.web.0` and `google_compute_instance.web.1`. The `uri` for each target is the value of their `network_interface.0.access_config.0.nat_ip` property, which corresponds to the externally routable IP address in Google Cloud.\n\n```\ngoogle_compute_instance.web.0:\n  id = web-0\n  cpu_platform = Intel Broadwell\n  machine_type = f1-micro\n  name = web-0\n  network_interface.# = 1\n  network_interface.0.access_config.# = 1\n  network_interface.0.access_config.0.assigned_nat_ip =\n  network_interface.0.access_config.0.nat_ip = 34.83.150.52\n  network_interface.0.address =\n  network_interface.0.name = nic0\n  network_interface.0.network = https://www.googleapis.com/compute/v1/projects/cloud-app1/global/networks/default\n  network_interface.0.network_ip = 10.138.0.22\n  project = cloud-app1\n  self_link = https://www.googleapis.com/compute/v1/projects/cloud-app1/zones/us-west1-a/instances/web-0\n  zone = us-west1-a\ngoogle_compute_instance.web.1:\n  id = web-1\n  cpu_platform = Intel Broadwell\n  machine_type = f1-micro\n  name = web-1\n  network_interface.# = 1\n  network_interface.0.access_config.# = 1\n  network_interface.0.access_config.0.assigned_nat_ip =\n  network_interface.0.access_config.0.nat_ip = 34.83.16.240\n  network_interface.0.address =\n  network_interface.0.name = nic0\n  network_interface.0.network = https://www.googleapis.com/compute/v1/projects/cloud-app1/global/networks/default\n  network_interface.0.network_ip = 10.138.0.21\n  project = cloud-app1\n  self_link = https://www.googleapis.com/compute/v1/projects/cloud-app1/zones/us-west1-a/instances/web-1\n  zone = us-west1-a\ngoogle_compute_instance.app.1:\n  id = app-1\n  cpu_platform = Intel Broadwell\n  machine_type = f1-micro\n  name = app-1\n  network_interface.# = 1\n  network_interface.0.access_config.# = 1\n  network_interface.0.access_config.0.assigned_nat_ip =\n  network_interface.0.access_config.0.nat_ip = 35.197.93.137\n  network_interface.0.address =\n  network_interface.0.name = nic0\n  network_interface.0.network = https://www.googleapis.com/compute/v1/projects/cloud-app1/global/networks/default\n  network_interface.0.network_ip = 10.138.0.23\n  project = cloud-app1\n  self_link = https://www.googleapis.com/compute/v1/projects/cloud-app1/zones/us-west1-a/instances/app-1\n  zone = us-west1-a\n```\n\n## Setting up Terraform project directories\n\nThe `initialize` task will setup a Terraform project directory with all the appropriate modules and providers needed to execute your configuration. It accepts a single field:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n\n## Provisioning resources \n\nThe `apply` task will apply resources and return the logs printed to stdout. It accepts several fields:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n-   `state`: (Optional) Path to read and save state. Defaults to `terraform.tfstate`. Path is relative to `dir`.\n-   `state_out`: (Optional) Path to write state to that is different than `state`. This can be used to preserve the old state. Path is relative to `dir`.\n-   `target`: (Optional) Resource to target. Operation will be limited to this resource and its dependencies. Accepts a single resource string or an array of resources.\n-   `var`: (Optional) Set Terraform variables, expects a hash with key value pairs representing variables and values (NOTE: single quotes `'` are incompatible).\n-   `var_file`: (Optional) Set variables in the Terraform configuration from a file. Path is relative to `dir`.\n\nThe `apply` plan will run the `apply` task against the `localhost` target and optionally return the result of the `output` task. It accepts several fields:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n-   `state`: (Optional) Path to read and save state. Defaults to `terraform.tfstate`. Path is relative to `dir`.\n-   `state_out`: (Optional) Path to write state to that is different than `state`. This can be used to preserve the old state. Path is relative to `dir`.\n-   `target`: (Optional) Resource to target. Operation will be limited to this resource and its dependencies. Accepts a single resource string or an array of resources.\n-   `var`: (Optional) Set Terraform variables, expects a hash with key value pairs representing variables and values (NOTE: single quotes `'` are incompatible).\n-   `var_file`: (Optional) Set variables in the Terraform configuration from a file. Path is relative to `dir`.\n-   `return_output`: (Optional) Return the result of the `output` task (defualts to `false`). \n\nThe `output` task will return the result of executing `terraform output`. It accepts several fields:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n-   `state`: (Optional) Path to read and save state. Defaults to `terraform.tfstate`. Path is relative to `dir`.\n\n## Destroying resources\n\nThe `destroy` task will destroy resources and return the logs printed to stdout. It accepts several fields:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n-   `state`: (Optional) Path to read and save state. Defaults to `terraform.tfstate`. Path is relative to `dir`.\n-   `state_out`: (Optional) Path to write state to that is different than `state`. This can be used to preserve the old state. Path is relative to `dir`.\n-   `target`: (Optional) Resource to target. Operation will be limited to this resource and its dependencies. Accepts a single resource string or an array of resources.\n-   `var`: (Optional) Set Terraform variables, expects a hash with key value pairs representing variables and values (NOTE: single quotes `'` are incompatible).\n-   `var_file`: (Optional) Set variables in the Terraform configuration from a file. Path is relative to `dir`.\n\nThe `destroy` plan will run the `destroy` task against the `localhost` and return it's result. It accepts several fields:\n\n-   `dir`: (Optional) Path to Terraform project directory. Path is relative to CWD, unless an absolute path is specified.\n-   `state`: (Optional) Path to read and save state. Defaults to `terraform.tfstate`. Path is relative to `dir`.\n-   `state_out`: (Optional) Path to write state to that is different than `state`. This can be used to preserve the old state. Path is relative to `dir`.\n-   `target`: (Optional) Resource to target. Operation will be limited to this resource and its dependencies. Accepts a single resource string or an array of resources.\n-   `var`: (Optional) Set Terraform variables, expects a hash with key value pairs representing variables and values (NOTE: single quotes `'` are incompatible).\n-   `var_file`: (Optional) Set variables in the Terraform configuration from a file. Path is relative to `dir`.\n\n\n### Example\n\nIn this example plan, resources are applied and then destroyed during plan execution. The outputs from the `terraform::apply` plan are used to pass as data to a task. \n\n```puppet\nplan example(TargetSpec $targets){\n  run_task('terraform::initialize', 'dir' =\u003e '/home/cas/working_dir/dynamic-inventory-demo')\n  $apply_result = run_plan('terraform::apply', 'dir' =\u003e '/home/cas/working_dir/dynamic-inventory-demo', 'return_output' =\u003e true)\n  run_task('important::stuff', $targets, 'task_var' =\u003e $apply_result)\n  run_plan('destroy', 'dir' =\u003e '/home/cas/working_dir/dynamic-inventory-demo')\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-terraform/lists"}