{"id":21217064,"url":"https://github.com/ansible-collections/cloud.terraform","last_synced_at":"2025-05-07T20:12:43.100Z","repository":{"id":64836339,"uuid":"539594702","full_name":"ansible-collections/cloud.terraform","owner":"ansible-collections","description":"The collection automates the management and provisioning of infrastructure as code (IaC) using the Terraform CLI tool within Ansible playbooks and Execution Environment runtimes.","archived":false,"fork":false,"pushed_at":"2025-05-02T12:43:27.000Z","size":482,"stargazers_count":115,"open_issues_count":23,"forks_count":43,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-07T20:12:37.401Z","etag":null,"topics":["ansible","infrastructure-as-code","terraform"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ansible-collections.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-21T16:56:31.000Z","updated_at":"2025-05-04T16:17:04.000Z","dependencies_parsed_at":"2023-11-21T07:52:37.604Z","dependency_job_id":"7ddc12ec-5a01-4f0e-a164-bb6a04e980a4","html_url":"https://github.com/ansible-collections/cloud.terraform","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":"ansible-collections/collection_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-collections%2Fcloud.terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-collections%2Fcloud.terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-collections%2Fcloud.terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-collections%2Fcloud.terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansible-collections","download_url":"https://codeload.github.com/ansible-collections/cloud.terraform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949285,"owners_count":21830153,"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":["ansible","infrastructure-as-code","terraform"],"created_at":"2024-11-20T21:56:55.075Z","updated_at":"2025-05-07T20:12:43.080Z","avatar_url":"https://github.com/ansible-collections.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform Collection for Ansible Automation Platform\n\nThe `cloud.terraform` collection houses modules that help in the management and provisioning of infrastructure as code using Terraform CLI tool within Ansible playbooks and Execution Environment runtimes.\n\n## Description\n\ncloud.terraform is intended to support similar automation capabilities consistent with other cloud provisioning tool integrations for Ansible such as AWS Cloudformation, Azure Resource Manager and Helm with the added challenge of effectively managing a state file.\n\n## Requirements\n\n### Ansible version compatibility\n\nThis collection requires Ansible Core 2.15 or later and thus Python 3.9 or later.\n\n## Included content\n\u003c!--start collection content--\u003e\n### Inventory plugins\nName | Description\n--- | ---\n[cloud.terraform.terraform_provider](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.terraform_provider_inventory.rst)|Builds an inventory from Terraform state file.\n[cloud.terraform.terraform_state](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.terraform_state_inventory.rst)|Builds an inventory from resources created by cloud providers.\n\n### Lookup plugins\nName | Description\n--- | ---\n[cloud.terraform.tf_output](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.tf_output_lookup.rst)|Reads state file outputs.\n\n### Modules\nName | Description\n--- | ---\n[cloud.terraform.plan_stash](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.plan_stash_module.rst)|Handle the base64 encoding or decoding of a terraform plan file\n[cloud.terraform.terraform](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.terraform_module.rst)|Manages a Terraform deployment (and plans)\n[cloud.terraform.terraform_output](https://github.com/ansible-collections/cloud.terraform/blob/main/docs/cloud.terraform.terraform_output_module.rst)|Returns Terraform module outputs.\n\n\u003c!--end collection content--\u003e\n\n## Installation\n\nYou can install the cloud.terraform collection with the Ansible Galaxy CLI:\n\n    ansible-galaxy collection install cloud.terraform\n\nYou can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format:\n\n```yaml\n---\ncollections:\n  - name: cloud.terraform\n```\n\nA specific version of the collection can be installed by using the `version` keyword in the `requirements.yml` file:\n\n```yaml\n---\ncollections:\n  - name: cloud.terraform\n    version: 1.1.0\n```\n\n## Use Cases\n\nThis collection is intended to support the following use cases:\n\n* Automated create, update and teardown of infrastructure using an existing Terraform plan\n* Transparent fetch and store Terraform state file to a remote source\n* Read information from an existing Terraform state file\n* Fetch Terraform project (plan and var) files from an external source such git with a Role\n* Utilizing state files as dynamic inventory source with a Terraform Provider\n\nThis collection is not intended to manage the installation, configuration and operation of local developer instances of Terraform. Some of these operations may be possible through the overlap with the scope of this work, but not mean to be explicitly and comprehensively through modules, plugins and documentation support of this collection. This includes:\n\n* Direct manipulation of Terraform state files (mv, rm, import)\n* Direct manipulation or generation of Terraform plan files and variable files (fmt)\n* Managing Terraform Workspaces\n* Console subcommand\n* Graph subcommand\n\nYou can either call modules by their Fully Qualified Collection Name (FQCN), such as `cloud.terraform.terraform`, or you can call modules by their short name if you list the `cloud.terraform` collection in the playbook's `collections` keyword:\n\n```yaml\n---\n  - name: Basic deploy of a service\n    cloud.terraform.terraform:\n      project_path: '{{ project_dir }}'\n      state: present\n \n  # Inventory built from state file containing AWS, AzureRM and GCP instances\n  - name: Create inventory from state file containing AWS, AzureRM and GCP instances\n    plugin: cloud.terraform.terraform_state\n    backend_type: azurerm\n    backend_config:\n      resource_group_name: my-resource-group\n      storage_account_name: mystorageaccount\n      container_name: terraformstate\n      key: inventory.tfstate\n\n  # Encode terraform plan file into variable 'stashed_plan'\n  - name: Encode a terraform plan file into terraform_plan variable\n    cloud.terraform.plan_stash:\n      path: /path/to/terraform_plan_file\n      var_name: stashed_plan\n      state: stash\n    no_log: true\n\n  # Load terraform plan file from variable 'stashed_plan'\n  - name: Load a terraform plan file data from variable 'stashed_plan' into file 'tfplan'\n    cloud.terraform.plan_stash:\n      path: tfplan\n      var_name: stashed_plan\n      state: load\n    no_log: true\n```\n\n## Testing\n\nThe project uses `mypy` and `black`.\nBlack works without special configuration, while `mypy` requires a valid package structure.\nAssuming this repository is checked out in the proper structure,\ne.g. `collections_root/ansible_collections/cloud/terraform/`, run:\n\n```shell\nblack --check --diff .\nblack .\n\nexport MYPYPATH=\"$(realpath \"$PWD/../../../\")\"\nmypy -p ansible_collections.cloud.terraform.plugins\n```\n\nSanity and unit tests are run as normal:\n\n```shell\nansible-test sanity\nansible-test units\nantsibull-docs lint-collection-docs .\n```\n\nTo run integration tests, install `terraform` and ensure it is in your `PATH`.\nIf you want to run cloud integration tests, ensure you log in to the clouds:\n\n```shell\n### using the \"default\" profile on AWS\naws configure set aws_access_key_id     my-access-key\naws configure set aws_secret_access_key my-secret-key\naws configure set region                eu-north-1\n\n### Azure login\naz login\naz account set --subscription \u003cid\u003e\n\n### GCP login\ngcloud auth application-default login\ngcloud auth application-default set-quota-project \u003cid\u003e\n\nblack --check --diff .\nMYPYPATH=\"$(realpath \"$PWD/../../../\")\" mypy -p ansible_collections.cloud.terraform.plugins\nansible-test integration [target] [--exclude aws|azure|gcp]\n\n### Generate docs\nansible-doc --list | grep cloud.terraform | cut -d \" \" -f 1 | xargs -I {} antsibull-docs plugin --dest-dir docs/ {}\n```\n\n## Contributing to this collection\n\nWe welcome community contributions to this collection. If you find problems, please open an issue or create a PR against this collection repository.\nSee [CONTRIBUTING.md](https://github.com/ansible-collections/cloud.terraform/blob/main/CONTRIBUTING.md) for more details.\n\n## Support\n\nFor the latest supported versions, refer to the release notes below.\n\nIf you encounter issues or have questions, you can submit a support request through the following channels:\n - GitHub Issues: Report bugs, request features, or ask questions by opening an issue in the [GitHub repository](https://github.com/ansible-collections/cloud.terraform).\n\n## Release Notes\n\nSee the [raw generated changelog](https://github.com/ansible-collections/cloud.terraform/blob/main/CHANGELOG.rst).\n\n\n## Related Information\n\n - [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html).\n - [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)\n\n## Licensing\n\nGNU General Public License v3.0 or later.\n\nSee [LICENSE](https://github.com/ansible-collections/cloud.terraform/blob/main/LICENSE) to see the full text.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansible-collections%2Fcloud.terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansible-collections%2Fcloud.terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansible-collections%2Fcloud.terraform/lists"}