├── .gitattributes ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── stale.yml └── workflows │ ├── publish.yaml │ ├── push.yaml │ └── scorecard.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Invoke-Terraform ├── Configuration.psd1 ├── Invoke-Terraform.psd1 ├── Invoke-Terraform.psm1 ├── Private │ ├── Copy-TerraformBinary.ps1 │ ├── Get-TerraformLatestRelease.ps1 │ ├── Get-TerraformPath.ps1 │ ├── Get-TerraformPlatform.ps1 │ ├── Get-TerraformVersion.ps1 │ ├── Get-TerraformZip.ps1 │ ├── Install-TerraformBinary.ps1 │ ├── Test-TerraformArchiveChecksum.ps1 │ ├── Test-TerraformCodeSignature.ps1 │ └── Test-TerraformPath.ps1 └── Public │ ├── Confirm-TerraformHashicorpKey.ps1 │ ├── Get-TerraformConfiguration.ps1 │ ├── Get-TerraformStableBinary.ps1 │ ├── Install-Terraform.ps1 │ ├── Invoke-Terraform.ps1 │ ├── Set-TerraformAutoDownload.ps1 │ ├── Set-TerraformAutoStableBinary.ps1 │ ├── Set-TerraformConfiguration.ps1 │ ├── Set-TerraformSquelchChecksumWarning.ps1 │ ├── Set-TerraformStableBinary.ps1 │ ├── Set-TerraformVersion.ps1 │ └── Uninstall-Terraform.ps1 ├── LICENSE ├── README.md ├── build.ps1 ├── docs └── en-US │ ├── Confirm-TerraformHashicorpKey.md │ ├── Get-TerraformBinary.md │ ├── Get-TerraformConfiguration.md │ ├── Get-TerraformStableBinary.md │ ├── Install-Terraform.md │ ├── Invoke-Terraform.md │ ├── Set-TerraformAutoDownload.md │ ├── Set-TerraformAutoStableBinary.md │ ├── Set-TerraformAutoSwitchBinary.md │ ├── Set-TerraformBinary.md │ ├── Set-TerraformConfiguration.md │ ├── Set-TerraformSquelchChecksumWarning.md │ ├── Set-TerraformStableBinary.md │ ├── Set-TerraformVersion.md │ └── Uninstall-Terraform.md ├── psakeFile.ps1 ├── requirements.psd1 └── tests ├── Help.tests.ps1 ├── Manifest.tests.ps1 └── unit ├── Get-TerraformConfiguration.tests.ps1 ├── Install-Terraform.tests.ps1 ├── Invoke-Terraform.tests.ps1 ├── Set-TerraformAutoDownload.tests.ps1 ├── Set-TerraformAutoStableBinary.tests.ps1 ├── Set-TerraformConfiguration.tests.ps1 ├── Set-TerraformSquelchChecksumWarning.tests.ps1 ├── Set-TerraformStableBinary.tests.ps1 ├── Set-TerraformVersion.tests.ps1 └── Uninstall-Terraform.tests.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | Contributions to Invoke-Tearraform are highly encouraged and desired. Below are some guidelines that will help make the process as smooth as possible. 3 | 4 | # Getting Started 5 | * Make sure you have a [GitHub account](https://github.com/signup/free) 6 | * Submit a new issue, assuming one does not already exist. 7 | * Clearly describe the issue including steps to reproduce when it is a bug. 8 | * Make sure you fill in the earliest version that you know has the issue. 9 | * Fork the repository on GitHub 10 | 11 | # Suggesting Enhancements 12 | We want to know what you think is missing from Invoke-Tearraform and how it can be made better. 13 | * When submitting an issue for an enhancement, please be as clear as possible about why you think the enhancement is needed and what the benefit of 14 | it would be. 15 | 16 | # Making Changes 17 | * From your fork of the repository, create a topic branch where work on your change will take place. 18 | * To quickly create a topic branch based on master; `git checkout -b my_contribution main`. Please avoid working directly on the `main` branch. 19 | * Make commits of logical units. 20 | * Check for unnecessary whitespace with `git diff --check` before committing. 21 | * Please follow the prevailing code conventions in the repository. Differences in style make the code harder to understand for everyone. 22 | * Make sure your commit messages are in the proper format. 23 | ```` 24 | Add more cowbell to Get-Something.ps1 25 | 26 | The functionaly of Get-Something would be greatly improved if there was a little 27 | more 'pizzazz' added to it. I propose a cowbell. Adding more cowbell has been 28 | shown in studies to both increase one's mojo, and cement one's status 29 | as a rock legend. 30 | ```` 31 | 32 | * Make sure you have added all the necessary Pester tests for your changes. 33 | * Run _all_ PESTER tests in the module to assure nothing else was accidentally broken. 34 | 35 | # Documentation 36 | We are infallible and as such the documenation needs no corectoin. In the highly 37 | unlikely event that that is _not_ the case, commits to update or add documentation 38 | are highly apprecaited. 39 | 40 | # Submitting Changes 41 | * Push your changes to a topic branch in your fork of the repository. 42 | * Submit a pull request to the main repository. 43 | * Once the pull request has been reviewed and accepted, it will be merged with the main branch. 44 | * Celebrate 45 | 46 | # Additional Resources 47 | * [General GitHub documentation](https://help.github.com/) 48 | * [GitHub forking documentation](https://guides.github.com/activities/forking/) 49 | * [GitHub pull request documentation](https://help.github.com/send-pull-requests/) 50 | * [GitHub Flow guide](https://guides.github.com/introduction/flow/) 51 | * [GitHub's guide to contributing to open source projects](https://guides.github.com/activities/contributing-to-open-source/) 52 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. 16 | 2. 17 | 3. 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Output** 23 | If applicable, add debugging output to help explain your problem. 24 | 25 | **Desktop (please complete the following information):** 26 | - OS: [e.g. ubuntu] 27 | - Version [e.g. 18.04] 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Related Issue 7 | 8 | 9 | 10 | 11 | 12 | ## Motivation and Context 13 | 14 | 15 | ## How Has This Been Tested? 16 | 17 | 18 | 19 | 20 | ## Screenshots (if appropriate): 21 | 22 | ## Types of changes 23 | 24 | - [ ] Bug fix (non-breaking change which fixes an issue) 25 | - [ ] New feature (non-breaking change which adds functionality) 26 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 27 | 28 | ## Checklist: 29 | 30 | 31 | - [ ] My code follows the code style of this project. 32 | - [ ] My change requires a change to the documentation. 33 | - [ ] I have updated the documentation accordingly. 34 | - [ ] I have read the **CONTRIBUTING** document. 35 | - [ ] I have added tests to cover my changes. 36 | - [ ] All new and existing tests passed. 37 | 38 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 14 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: stale 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | publish: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Check out repository code 14 | uses: actions/checkout@v2 15 | 16 | - name: Publish 17 | env: 18 | PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }} 19 | shell: pwsh 20 | run: | 21 | $ErrorActionPreference = 'SilentlyContinue' 22 | .\build.ps1 -Bootstrap -Task Init 23 | .\build.ps1 -Task Publish -------------------------------------------------------------------------------- /.github/workflows/push.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push] 3 | jobs: 4 | test: 5 | name: test 6 | runs-on: ${{ matrix.os }} 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ubuntu-latest, windows-latest, macOS-latest] 11 | steps: 12 | - uses: actions/checkout@v1 13 | - name: Test 14 | run: pwsh -f ./build.ps1 -Task Test -Bootstrap 15 | - name: Publish Test Results 16 | uses: EnricoMi/publish-unit-test-result-action/composite@v2 17 | if: always() 18 | with: 19 | files: | 20 | Output/*.xml 21 | -------------------------------------------------------------------------------- /.github/workflows/scorecard.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. They are provided 2 | # by a third-party and are governed by separate terms of service, privacy 3 | # policy, and support documentation. 4 | 5 | name: Scorecard supply-chain security 6 | on: 7 | # For Branch-Protection check. Only the default branch is supported. See 8 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection 9 | branch_protection_rule: 10 | # To guarantee Maintained check is occasionally updated. See 11 | # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained 12 | schedule: 13 | - cron: '38 22 * * 6' 14 | push: 15 | branches: [ "main" ] 16 | 17 | # Declare default permissions as read only. 18 | permissions: read-all 19 | 20 | jobs: 21 | analysis: 22 | name: Scorecard analysis 23 | runs-on: ubuntu-latest 24 | permissions: 25 | # Needed to upload the results to code-scanning dashboard. 26 | security-events: write 27 | # Needed to publish results and get a badge (see publish_results below). 28 | id-token: write 29 | # Uncomment the permissions below if installing in a private repository. 30 | # contents: read 31 | # actions: read 32 | 33 | steps: 34 | - name: "Checkout code" 35 | uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 36 | with: 37 | persist-credentials: false 38 | 39 | - name: "Run analysis" 40 | uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2 41 | with: 42 | results_file: results.sarif 43 | results_format: sarif 44 | # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: 45 | # - you want to enable the Branch-Protection check on a *public* repository, or 46 | # - you are installing Scorecard on a *private* repository 47 | # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. 48 | # repo_token: ${{ secrets.SCORECARD_TOKEN }} 49 | 50 | # Public repositories: 51 | # - Publish results to OpenSSF REST API for easy access by consumers 52 | # - Allows the repository to include the Scorecard badge. 53 | # - See https://github.com/ossf/scorecard-action#publishing-results. 54 | # For private repositories: 55 | # - `publish_results` will always be set to `false`, regardless 56 | # of the value entered here. 57 | publish_results: true 58 | 59 | # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF 60 | # format to the repository Actions tab. 61 | - name: "Upload artifact" 62 | uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 63 | with: 64 | name: SARIF file 65 | path: results.sarif 66 | retention-days: 5 67 | 68 | # Upload the results to GitHub's code scanning dashboard. 69 | - name: "Upload to code-scanning" 70 | uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4 71 | with: 72 | sarif_file: results.sarif 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Output/ 2 | coverage.xml 3 | codeCoverage.xml -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 6 | and this project adheres to [Semantic Versioning](http://semver.org/). 7 | 8 | ## [0.6.2] 9 | 10 | ### 11 | 12 | - Issue #24 Update Windows Thumbprint, convert to list for configuration. Backwards compatiable checking. 13 | 14 | ## [0.6.1] 15 | 16 | ### 17 | 18 | - Capture stderr output from gpg. Some automation platforms highlight stderr read. 19 | - Quiet codesign unless running verbose. 20 | 21 | ## [0.6.0] 22 | 23 | ### Fixed 24 | 25 | - Support for 1.0.0, making it the new default 26 | - Removed invalid description of Path from README. `$HOME\bin` is no longer the default. 27 | 28 | ## [0.5.1] 29 | 30 | ### Security 31 | 32 | - Updated GPG keys: due to [HCSEC-2021-12](https://discuss.hashicorp.com/t/hcsec-2021-12-codecov-security-event-and-hashicorp-gpg-key-exposure/23512) Codecov Security Event and HashiCorp GPG Key Exposure. See Terraform Updates for [HCSEC-2021-12](https://discuss.hashicorp.com/t/terraform-updates-for-hcsec-2021-12/23570) for guidance. 33 | 34 | If the following error is received 35 | 36 | ```pwsh 37 | Install-Terraform -TFVersion 0.15.1 38 | 39 | gpg: Signature made 04/26/21 17:02:20 Eastern Daylight Time 40 | gpg: using RSA key B36CBA91A2C0730C435FC280B0B441097685B676 41 | gpg: Can't check signature: No public key 42 | Exception: C:\Users\pearcec\Documents\PowerShell\Modules\Invoke-Terraform\0.5.1\Invoke-Terraform.psm1:173:9 43 | Line | 44 | 173 | throw "Unable to verify signature on $($SHAPath)" 45 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | | Unable to verify signature on 47 | | C:\Users\pearcec\AppData\Local\Temp\8ce5da55-215d-465f-861f-9778ee719d5d_SHA256SUMS 48 | ``` 49 | 50 | Then update the Invoke-Terraform configuration: 51 | 52 | ```pwsh 53 | Set-TerraformConfiguration -Configuration @{ HashiCorpPGPKeyId='0x34365D9472D7468F';} 54 | ``` 55 | 56 | ### Changed 57 | 58 | - Slight documentation tweak 59 | - Removed unused HashiCorpPGPThumbprint 60 | - Source SHA256SUM signatures based on PGP Key ID 61 | 62 | ## [0.5.0] 63 | 64 | ### Changed 65 | 66 | - `Invoke-Terraform` recursively searches up for `.terraform-version` stopping at root ([#12](https://github.com/pearcec/Invoke-Terraform/issues/12)) 67 | - Provide a binary without a version reference in the filename ([#13](https://github.com/pearcec/Invoke-Terraform/issues/13)) 68 | 69 | ## [0.4.0] 70 | 71 | ### Added 72 | 73 | - `Install-Terraform` defaults to latest when `-TFVersion` is not passed (https://github.com/pearcec/Invoke-Terraform/issues/10) 74 | - Add stock contributing guidelines 75 | - Add stock pull request template 76 | 77 | ## [0.3.0] 78 | 79 | ### Changed 80 | - BREAKING: Refactor to use Configuration Module. Existing configurations are ignored. 81 | - Fix PSAnalyzer complaints 82 | 83 | ### Added 84 | - Add ShouldProcess on Set cmdlets 85 | - Add GH Actions testing and publishing 86 | - Adopt PowerShellBuild. 87 | - Add pester testd 88 | - Add .gitignore. 89 | - Add standard build.ps1, psakeFile.ps1 and requirements.psd1. 90 | 91 | 92 | ## [0.2.0] 93 | 94 | ## Changed 95 | - Moved TFPreferences to HashMap, only set preferences passed to Set-TerraformPreference 96 | - Require PowerShellVersion 6.0 for ConvertFrom-Json -AsHashtable 97 | - Platform independent Get-TerraformPath 98 | - Add SkipCodeSignature and SkipChecksum preferences and parameters globally, with better error handling on gpg 99 | 100 | ## [0.1.0] 101 | 102 | ### Added 103 | 104 | - Initial release -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | christian@pearcec.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /Invoke-Terraform/Configuration.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | TFPath = Join-Path -Path $PSScriptRoot -ChildPath '..' -AdditionalChildPath 'bin' 3 | TFVersion = '1.0.0' 4 | ReleaseUrl = 'https://releases.hashicorp.com/terraform' 5 | AutoDownload = $false 6 | AutoStableBinary = $false 7 | 8 | HashiCorpPGPKeyId = '0x34365D9472D7468F' 9 | HashiCorpTeamIdentifier = 'D38WU7D763' 10 | HashiCorpWindowsThumbprint = @('35AB9FC834D217E9E7B1778FB1B97AF7C73792F2', '7868E4F55FD7B047CD8BF93FEA8C38509CFB5939') 11 | PGPKeyServer = 'keyserver.ubuntu.com' 12 | 13 | SquelchChecksumWarning = $false 14 | SkipChecksum = $false 15 | SkipCodeSignature = $false 16 | } 17 | -------------------------------------------------------------------------------- /Invoke-Terraform/Invoke-Terraform.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'Invoke-Terraform' 3 | # 4 | # Generated by: pearcec 5 | # 6 | # Generated on: 4/3/2021 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'Invoke-Terraform.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.6.2' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '0fbd19ac-a335-4de6-a473-382ff8ffd8ce' 22 | 23 | # Author of this module 24 | Author = 'Christian Pearce' 25 | 26 | # Company or vendor of this module 27 | # CompanyName = '' 28 | 29 | # Copyright statement for this module 30 | Copyright = '(c) Christian Pearce. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'A wrapper module for installing, checksum verification, switching and invoking the terraform binary' 34 | 35 | # Minimum version of the PowerShell engine required by this module 36 | PowerShellVersion = '6.0' 37 | 38 | # Name of the PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # ClrVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | RequiredModules = @('Configuration') 55 | 56 | # Assemblies that must be loaded prior to importing this module 57 | # RequiredAssemblies = @() 58 | 59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 60 | # ScriptsToProcess = @() 61 | 62 | # Type files (.ps1xml) to be loaded when importing this module 63 | # TypesToProcess = @() 64 | 65 | # Format files (.ps1xml) to be loaded when importing this module 66 | # FormatsToProcess = @() 67 | 68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 69 | # NestedModules = @() 70 | 71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 72 | FunctionsToExport = @( 73 | 'Confirm-TerraformHashicorpKey' 74 | 'Get-TerraformStableBinary' 75 | 'Get-TerraformConfiguration' 76 | 'Install-Terraform' 77 | 'Invoke-Terraform' 78 | 'Set-TerraformAutoDownload' 79 | 'Set-TerraformAutoStableBinary' 80 | 'Set-TerraformStableBinary' 81 | 'Set-TerraformConfiguration' 82 | 'Set-TerraformSquelchChecksumWarning' 83 | 'Set-TerraformVersion' 84 | 'Uninstall-Terraform' 85 | ) 86 | 87 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 88 | CmdletsToExport = @() 89 | 90 | # Variables to export from this module 91 | VariablesToExport = @() 92 | 93 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 94 | AliasesToExport = @( 95 | 'Switch-Terraform' 96 | 'terraform' 97 | ) 98 | 99 | # DSC resources to export from this module 100 | # DscResourcesToExport = @() 101 | 102 | # List of all modules packaged with this module 103 | # ModuleList = @() 104 | 105 | # List of all files packaged with this module 106 | # FileList = @() 107 | 108 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 109 | PrivateData = @{ 110 | 111 | PSData = @{ 112 | 113 | # Tags applied to this module. These help with module discovery in online galleries. 114 | Tags = @('terraform', 'Windows', 'Wrapper') 115 | 116 | # A URL to the license for this module. 117 | LicenseUri = 'https://raw.githubusercontent.com/pearcec/Invoke-Terraform/main/LICENSE' 118 | 119 | # A URL to the main website for this project. 120 | ProjectUri = 'https://github.com/pearcec/Invoke-Terraform' 121 | 122 | # A URL to an icon representing this module. 123 | # IconUri = '' 124 | 125 | # ReleaseNotes of this module 126 | ReleaseNotes = 'https://raw.githubusercontent.com/pearcec/Invoke-Terraform/main/CHANGELOG.md' 127 | 128 | # Prerelease string of this module 129 | # Prerelease = '' 130 | 131 | # Flag to indicate whether the module requires explicit user acceptance for install/update/save 132 | # RequireLicenseAcceptance = $false 133 | 134 | # External dependent modules of this module 135 | # ExternalModuleDependencies = @() 136 | 137 | } # End of PSData hashtable 138 | 139 | } # End of PrivateData hashtable 140 | 141 | # HelpInfo URI of this module 142 | # HelpInfoURI = '' 143 | 144 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 145 | # DefaultCommandPrefix = '' 146 | 147 | } 148 | 149 | -------------------------------------------------------------------------------- /Invoke-Terraform/Invoke-Terraform.psm1: -------------------------------------------------------------------------------- 1 | $PSDefaultParameterValues = @{ 2 | 'Invoke-WebRequest:Verbose' = $false 3 | 'Invoke-WebRequest:Debug' = $false 4 | } 5 | 6 | $ProgressPreference = 'SilentlyContinue' -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Copy-TerraformBinary.ps1: -------------------------------------------------------------------------------- 1 | Function Copy-TerraformBinary { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion, 5 | [string]$ZipPath 6 | ) 7 | 8 | $installPath = (Get-TerraformConfiguration).TFPath 9 | if (-not (Test-Path $installPath -PathType Container)) { 10 | if (-not (New-Item -Path $installPath -ItemType 'directory')) { 11 | throw "Failed to create $($installPath) preference directory" 12 | } 13 | } 14 | 15 | $binary = 'terraform' 16 | if ($isWindows) { 17 | $binary += '.exe' 18 | } 19 | 20 | $binaryVersion = 'terraform_{0}' -f $TFVersion 21 | if ($IsWindows) { 22 | $binaryVersion += '.exe' 23 | } 24 | 25 | if ($ZipPath) { 26 | $tmpPath = [System.IO.Path]::GetTempPath() 27 | [string] $guid = [System.Guid]::NewGuid() 28 | 29 | $tmpfolder = (Join-Path $tmpPath $guid) 30 | 31 | Expand-Archive -Path $zipPath -DestinationPath $tmpFolder 32 | 33 | $sourcePath = (Join-Path $tmpFolder $binary) 34 | $destPath = (Join-Path $installPath $binaryVersion) 35 | } else { 36 | $sourcePath = (Join-Path $installPath $binaryVersion) 37 | $destPath = (Join-Path $installPath $binary) 38 | } 39 | Copy-Item -Path $sourcePath -Destination $destPath -Force 40 | 41 | # TODO: Is Powershelly way? 42 | if (-not $IsWindows) { 43 | & chmod +x $destPath 44 | } 45 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Get-TerraformLatestRelease.ps1: -------------------------------------------------------------------------------- 1 | function Get-TerraformLatestRelease { 2 | $headers = @{ 3 | Accept = 'application/vnd.github.v3+json' 4 | } 5 | 6 | $response = Invoke-RestMethod 'https://api.github.com/repos/hashicorp/terraform/releases/latest' -Method 'GET' -Headers $headers 7 | $latest = $response.name.substring(1) 8 | return $latest 9 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Get-TerraformPath.ps1: -------------------------------------------------------------------------------- 1 | Function Get-TerraformPath { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion 5 | ) 6 | 7 | if ($isWindows) { 8 | $fileExt = '.exe' 9 | } 10 | return Join-Path (Get-TerraformConfiguration).TFPath "terraform_$($TFVersion)$($fileExt)" 11 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Get-TerraformPlatform.ps1: -------------------------------------------------------------------------------- 1 | function Get-TerraformPlatform { 2 | 3 | if ($IsWindows) { 4 | return 'windows' 5 | } 6 | 7 | if ($IsLinux) { 8 | return 'linux' 9 | } 10 | 11 | if ($IsMacOS) { 12 | return 'darwin' 13 | } 14 | throw 'Unknown platform.' 15 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Get-TerraformVersion.ps1: -------------------------------------------------------------------------------- 1 | Function Get-TerraformVersion { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$Path 5 | ) 6 | 7 | $terraformVersionFile = Join-Path -Path $Path -ChildPath .terraform-version 8 | if (Test-Path -Path $terraformVersionFile -PathType Leaf) { 9 | return $terraformVersionFile 10 | } 11 | 12 | $Parent = Split-Path $Path 13 | if ($Parent -eq $Home) { 14 | return $null 15 | } 16 | if ($Parent) { 17 | return Get-TerraformVersion $Parent 18 | } 19 | 20 | # Shouldn't get here 21 | return $null 22 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Get-TerraformZip.ps1: -------------------------------------------------------------------------------- 1 | Function Get-TerraformZip { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion, 5 | [switch]$SkipChecksum = $False 6 | ) 7 | 8 | $platform = Get-TerraformPlatform 9 | $shaKeyId = ((Get-TerraformConfiguration).HashiCorpPGPKeyId).Substring(10) 10 | 11 | $archiveName = 'terraform_{0}_{1}_amd64.zip' -f $TFVersion, $platform 12 | $zipUrl = '{0}/{1}/terraform_{1}_{2}_amd64.zip' -f (Get-TerraformConfiguration).ReleaseUrl, $TFVersion, $platform 13 | $shaUrl = '{0}/{1}/terraform_{1}_SHA256SUMS' -f (Get-TerraformConfiguration).ReleaseUrl, $TFVersion 14 | $shaSigUrl = '{0}/{1}/terraform_{1}_SHA256SUMS.{2}.sig' -f (Get-TerraformConfiguration).ReleaseUrl, $TFVersion, $shaKeyId 15 | 16 | $tmpPath = [System.IO.Path]::GetTempPath() 17 | [string] $guid = [System.Guid]::NewGuid() 18 | 19 | $zipPath = (Join-Path $tmpPath "$($guid).zip") 20 | $shaPath = (Join-Path $tmpPath "$($guid)_SHA256SUMS") 21 | $shaSigPath = (Join-Path $tmpPath "$($guid)_SHA256SUMS.sig") 22 | 23 | try { 24 | Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath 25 | } catch { 26 | Write-Error "Unable to request $($zipUrl)" 27 | throw $_ 28 | } 29 | 30 | try { 31 | Invoke-WebRequest -Uri $shaUrl -OutFile $shaPath 32 | } catch { 33 | throw "Unable to request $($shaUrl)" 34 | } 35 | 36 | try { 37 | Invoke-WebRequest -Uri $shaSigUrl -OutFile $shaSigPath 38 | } catch { 39 | throw "Unable to request $($shaSigUrl)" 40 | } 41 | 42 | if ( -not (Test-TerraformArchiveChecksum -SkipChecksum:$SkipChecksum -ArchiveName $archiveName -ZipPath $zipPath -SHAPath $shaPath -SHASigPath $shaSigPath) ) { 43 | throw 'Terraform Archive failed Checksum test.' 44 | } 45 | return $zipPath 46 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Install-TerraformBinary.ps1: -------------------------------------------------------------------------------- 1 | Function Install-TerraformBinary { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion, 5 | [switch]$SkipChecksum = $False, 6 | [switch]$SkipCodeSignature = $False 7 | ) 8 | 9 | $zipPath = Get-TerraformZip -TFVersion $TFVersion -SkipChecksum:$SkipChecksum 10 | 11 | try { 12 | Copy-TerraformBinary -TFVersion $TFVersion -ZipPath $zipPath 13 | } catch { 14 | Write-Error "Unable to copy binary from $zipPath." 15 | throw $_ 16 | } 17 | 18 | if (-not (Test-TerraformPath -TFVersion $TFVersion)) { 19 | throw "Failed to install Terraform $($TFversion) binary." 20 | } 21 | 22 | if ( -not (Test-TerraformCodeSignature -TFVersion $TFVersion -SkipCodeSignature:$SkipCodeSignature)) { 23 | Uninstall-Terraform -TFVersion $TFVersion 24 | throw "Terraform $($TFversion) failed to pass Code Signature test. Uninstalling." 25 | } 26 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Test-TerraformArchiveChecksum.ps1: -------------------------------------------------------------------------------- 1 | function Test-TerraformArchiveChecksum { 2 | param ( 3 | [parameter(Mandatory)] 4 | [string]$ArchiveName, 5 | [parameter(Mandatory)] 6 | [string]$ZipPath, 7 | [parameter(Mandatory)] 8 | [string]$SHAPath, 9 | [parameter(Mandatory)] 10 | [string]$SHASigPath, 11 | [switch]$SkipChecksum = $False 12 | 13 | ) 14 | 15 | if ($SkipChecksum -or (Get-TerraformConfiguration).SkipChecksum) { 16 | Write-Verbose 'Skipping Terraform Archive Checksum test.' 17 | return $true 18 | } 19 | 20 | $output = gpg --list-keys (Get-TerraformConfiguration).HashiCorpPGPKeyId 2>&1 21 | if ($LASTEXITCODE -ne 0) { 22 | gpg --quiet --keyserver (Get-TerraformConfiguration).PGPKeyServer --recv (Get-TerraformConfiguration).HashiCorpPGPKeyId 23 | if ($LASTEXITCODE -ne 0) { 24 | throw 'Unable to retrieve HashiCorp key' 25 | } 26 | } else { 27 | # Refresh incase of future revoke user will recevie warning 28 | gpg --quiet --keyserver (Get-TerraformConfiguration).PGPKeyServer --recv (Get-TerraformConfiguration).HashiCorpPGPKeyId 29 | } 30 | 31 | $output = gpg --verify $SHASigPath $SHAPath 2>&1 32 | if ($LASTEXITCODE -ne 0) { 33 | throw "Unable to verify signature on $($SHAPath) : $($output)" 34 | } 35 | if (-not ((Get-TerraformConfiguration).SquelchChecksumWarning) -and ($output | Select-String 'WARNING: This key is not certified' -Quiet)) { 36 | Write-Warning @' 37 | The HashiCorp key has been installed but not certified. Run either of the following 38 | 39 | - Confirm-TerraformHashiCorpKey 40 | - Set-TerraformSquelchChecksumWarning $true 41 | '@ 42 | } 43 | 44 | $SHASum = (Get-FileHash $ZipPath).Hash 45 | $HashiCorpSHASum = (Get-Content $shaPath | Select-String $ArchiveName).ToString().Split()[0] 46 | if ($SHASum -ne $HashiCorpSHASum ) { 47 | throw "Unable to verify SHASUM with $($SHAPath)" 48 | } 49 | 50 | Write-Verbose "Terraform archive $($zipPath) passed checksum test" 51 | return $true 52 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Test-TerraformCodeSignature.ps1: -------------------------------------------------------------------------------- 1 | Function Test-TerraformCodeSignature { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion, 5 | [switch]$SkipCodeSignature 6 | ) 7 | if ($SkipCodeSignature -or (Get-TerraformConfiguration).SkipCodeSignature) { 8 | Write-Verbose 'Skipping Code Signature test' 9 | return $true 10 | } 11 | if ($IsWindows) { 12 | # HashiCorp started signing with version 0.12.24 13 | # HashiCorp updated the signature in 1.3.8 14 | $tfThumbprint = (Get-AuthenticodeSignature -FilePath (Get-TerraformPath -TFVersion $TFVersion)).SignerCertificate.Thumbprint 15 | $configTFThumbprint = (Get-TerraformConfiguration).HashiCorpWindowsThumbprint 16 | 17 | if ($configTFThumbprint -is [String]) { 18 | # The configuration is a string 19 | return ($configTFThumbprint -eq $tfThumbprint) 20 | } elseif ($configTFThumbprint -is [Object[]]) { 21 | # The configuration is a list 22 | return ($configTFThumbprint -contains $tfThumbprint) 23 | } else { 24 | # The configuration is neither a string nor a list 25 | throw 'Invalid configuration for HashiCorpWindowsThumbprint, needs list or string' 26 | } 27 | } 28 | if ($IsMacOs) { 29 | if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) { 30 | codesign --verify -d --verbose=2 (Get-TerraformPath -TFVersion $TFVersion) 31 | } else { 32 | codesign --verify (Get-TerraformPath -TFVersion $TFVersion) 33 | } 34 | return $LASTEXITCODE -eq 0 35 | } 36 | if ($IsLinux) { 37 | Write-Verbose 'CodeSignature check at runtime is not supported on Linux.' 38 | return $true 39 | } 40 | Write-Error 'Unable to test terraform CodeSignature. Unknown platform.' 41 | throw $_ 42 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Private/Test-TerraformPath.ps1: -------------------------------------------------------------------------------- 1 | Function Test-TerraformPath { 2 | param( 3 | [parameter(Mandatory)] 4 | [string]$TFVersion 5 | ) 6 | Write-Verbose "Testing path for Terraform version $($TFVersion) " 7 | return Test-Path (Get-TerraformPath -TFVersion $TFVersion) -PathType leaf 8 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Confirm-TerraformHashicorpKey.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Helper function to sign the Hashi Corp PHP key. 4 | .DESCRIPTION 5 | Helper function to sign the Hashi Corp PHP key. 6 | .EXAMPLE 7 | Confirm-TerraformHashicorpKey 8 | 9 | Runs gpg to sign a HasiCorp PGP key. 10 | .INPUTS 11 | None. You cannot pipe objects to Confirm-TerraformHashicorpKey. 12 | .OUTPUTS 13 | None. Confirm-TerraformHashicorpKey returns nothing. 14 | .LINK 15 | Online version: https://github.com/pearcec/Invoke-Terraform 16 | #> 17 | Function Confirm-TerraformHashicorpKey { 18 | & gpg --sign-key (Get-TerraformConfiguration).HashiCorpPGPKeyId 19 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Get-TerraformConfiguration.ps1: -------------------------------------------------------------------------------- 1 | function Get-TerraformConfiguration { 2 | Import-Configuration 3 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Get-TerraformStableBinary.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get stable path for terraform binary (ie. terraform.exe or terraform) 4 | .DESCRIPTION 5 | Get stable path for terraform binary (ie. terraform.exe or terraform) 6 | .EXAMPLE 7 | Get-TerraformStableBinary 8 | 9 | Returns stable path for terraform binary 10 | .INPUTS 11 | None. You cannot pipe objects to Set-TerraformStableBinary. 12 | .OUTPUTS 13 | Returns a path. 14 | .LINK 15 | Set-TerraformStableBinary 16 | .LINK 17 | Online version: https://github.com/pearcec/Invoke-Terraform 18 | #> 19 | function Get-TerraformStableBinary { 20 | 21 | $installPath = (Get-TerraformConfiguration).TFPath 22 | $binary = 'terraform' 23 | if ($isWindows) { 24 | $binary += '.exe' 25 | } 26 | $binPath = Join-Path -Path $installPath -ChildPath $binary 27 | 28 | if (Test-Path $binPath -PathType leaf ) { 29 | return $binPath 30 | } 31 | Write-Error @" 32 | Terraform static binary not set. Run either: 33 | - Set-TerraformStableBinary 34 | or: 35 | - Set-TerraformAutoStableBinary `$true 36 | - Set-TerraformVersion -TFVersion:[TFversion] 37 | or: 38 | - Set-TerraformAutoStableBinary `$true 39 | - Install-Terraform 40 | "@ 41 | throw '' 42 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Install-Terraform.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Install a version of terraform. 4 | .DESCRIPTION 5 | Install a version of terraform. 6 | .PARAMETER TFVersion 7 | The version of terraform to install. 8 | .PARAMETER SkipChecksum 9 | Skip release archive checksum verification. 10 | .PARAMETER SkipCodeSignature 11 | Skip code signature verifcation. 12 | .EXAMPLE 13 | Install-Terraform -TFVersion 0.14.7 14 | 15 | Installs terraform version 0.14.7 16 | .INPUTS 17 | None. You cannot pipe objects to Install-Terraform. 18 | .OUTPUTS 19 | None. Install-Terraform returns nothing. 20 | .LINK 21 | Uninstall-Terraform 22 | .LINK 23 | Online version: https://github.com/pearcec/Invoke-Terraform 24 | #> 25 | Function Install-Terraform { 26 | param( 27 | [string]$TFVersion, 28 | [switch]$SkipChecksum = $False, 29 | [switch]$SkipCodeSignature = $False 30 | ) 31 | 32 | if (-not $TFVersion) { 33 | $TFVersion = Get-TerraformLatestRelease 34 | } 35 | 36 | if (Test-TerraformPath -TFVersion $TFVersion) { 37 | Write-Verbose "Terraform $($TFversion) already installed." 38 | return 39 | } 40 | Write-Verbose "Installing terraform version $($TFVersion)" 41 | Install-TerraformBinary -TFVersion $TFVersion -SkipChecksum:$SkipChecksum -SkipCodeSignature:$SkipCodeSignature 42 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Invoke-Terraform.ps1: -------------------------------------------------------------------------------- 1 | 2 | 3 | Function Invoke-Terraform { 4 | <# 5 | .SYNOPSIS 6 | Run terraform version based on user preference. 7 | .DESCRIPTION 8 | Run terraform version based on user preference. 9 | Additional parameters are passed to the terraform binary. 10 | .PARAMETER TFVersion 11 | Override preferred version of terraform to run. 12 | .PARAMETER SkipCodeSignature 13 | Skip code signature verifcation. 14 | .EXAMPLE 15 | Invoke-Terraform -TFVersion 0.14.7 16 | 17 | Runs terraform version 0.14.7 18 | .EXAMPLE 19 | Invoke-Terraform 20 | 21 | Runs terraform version based on user preference or default preference. 22 | .INPUTS 23 | None. You cannot pipe objects to Invoke-Terraform. 24 | .OUTPUTS 25 | None. Invoke-Terraform returns nothing. 26 | .LINK 27 | Install-Terraform 28 | .LINK 29 | Online version: https://github.com/pearcec/Invoke-Terraform 30 | #> 31 | param( 32 | [string]$TFVersion, 33 | [switch]$SkipCodeSignature = $False 34 | ) 35 | 36 | # HACK: 37 | # 38 | # Due to positional parameters the first unnamed parameter 39 | # is passed to $TFVersion. This catches non version parameters 40 | # intended to pass to the terraform run. 41 | if (-not ($TFVersion -match '^\d\d?\.\d\d?\.\d\d?$')) { 42 | # Build $TFargs and null $TFVersion for default preference 43 | $TFargs = @($TFVersion) + $args 44 | $TFVersion = $null 45 | } else { 46 | $TFArgs = $args 47 | } 48 | 49 | $terraformVersionFile = Get-TerraformVersion -Path (Get-Item .).FullName 50 | if ($terraformVersionFile -and (-not $TFVersion)) { 51 | $TFVersion = Get-Content $terraformVersionFile 52 | # TODO regex validate the version 53 | Write-Verbose "Found .terraform-version $TFVersion" 54 | } 55 | 56 | # If Version still isn't set 57 | if (-not $TFVersion) { 58 | $TFVersion = (Get-TerraformConfiguration).TFVersion 59 | } 60 | 61 | if (-not (Test-TerraformPath -TFVersion $TFVersion)) { 62 | Write-Warning "Terraform version $($TFVersion) not found." 63 | 64 | if ((Get-TerraformConfiguration).AutoDownload) { 65 | Write-Verbose "Auto downloading terraform version $($TFVersion)" 66 | Install-Terraform -TFVersion $TFVersion 67 | } else { 68 | Write-Error @" 69 | Terraform version $($TFVersion) not installed. Run either: 70 | - Install-Terraform -TFVersion $($TFVersion) 71 | or: 72 | - Set-TerraformAutoDownload `$true 73 | "@ 74 | throw '' 75 | } 76 | } 77 | 78 | if (-not (Test-TerraformCodeSignature -TFVersion $TFVersion -SkipCodeSignature:$SkipCodeSignature)) { 79 | throw 'Unable to confirm Code Signature of terraform binary' 80 | } 81 | 82 | & (Get-TerraformPath -TFVersion $TFVersion) $TFargs 83 | } 84 | 85 | Set-Alias -Name terraform -Value Invoke-Terraform 86 | -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformAutoDownload.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Set auto download configuration. 4 | .DESCRIPTION 5 | Set auto download configuration. 6 | .PARAMETER AutoDownload 7 | Either true or false. 8 | .EXAMPLE 9 | Set-TerraformAutoDownload $true 10 | 11 | Sets auto download configuration to true 12 | .INPUTS 13 | None. You cannot pipe objects to Set-TerraformAutoDownload. 14 | .OUTPUTS 15 | None. Set-TerraformAutoDownload returns nothing. 16 | .LINK 17 | Get-TerraformConfiguration 18 | .LINK 19 | Online version: https://github.com/pearcec/Invoke-Terraform 20 | #> 21 | function Set-TerraformAutoDownload { 22 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 23 | param( 24 | [parameter(Mandatory)] 25 | [boolean]$AutoDownload 26 | ) 27 | begin { 28 | Write-Debug -Message 'Beginning' 29 | $configurationPath = Get-ConfigurationPath 30 | } 31 | 32 | process { 33 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting AutoDownload configuration to $($AutoDownload)")) { 34 | Write-Verbose "Setting AutoDownload configuration to $($AutoDownload)" 35 | Set-TerraformConfiguration @{ AutoDownload = $AutoDownload } -Confirm:$False 36 | } 37 | } 38 | end { 39 | Write-Debug -Message 'Ending' 40 | } 41 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformAutoStableBinary.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Set auto switch binary configuration. 4 | .DESCRIPTION 5 | Set auto switch binary configuration. 6 | .PARAMETER AutoStableBinary 7 | Either true or false. 8 | .EXAMPLE 9 | Set-TerraformAutoStableBinary $true 10 | 11 | Sets auto switch binary configuration to true 12 | .INPUTS 13 | None. You cannot pipe objects to Set-TerraformAutoStableBinary. 14 | .OUTPUTS 15 | None. Set-TerraformAutoStableBinary returns nothing. 16 | .LINK 17 | Get-TerraformConfiguration 18 | .LINK 19 | Online version: https://github.com/pearcec/Invoke-Terraform 20 | #> 21 | function Set-TerraformAutoStableBinary { 22 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 23 | param( 24 | [parameter(Mandatory)] 25 | [boolean]$AutoStableBinary 26 | ) 27 | begin { 28 | Write-Debug -Message 'Beginning' 29 | $configurationPath = Get-ConfigurationPath 30 | } 31 | 32 | process { 33 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting AutoStableBinary configuration to $($AutoStableBinary)")) { 34 | Write-Verbose "Setting AutoStableBinary configuration to $($AutoStableBinary)" 35 | Set-TerraformConfiguration @{ AutoStableBinary = $AutoStableBinary } -Confirm:$False 36 | } 37 | } 38 | end { 39 | Write-Debug -Message 'Ending' 40 | } 41 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformConfiguration.ps1: -------------------------------------------------------------------------------- 1 | function Set-TerraformConfiguration { 2 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 3 | param( 4 | [parameter(Mandatory)] 5 | [hashtable]$Configuration 6 | ) 7 | begin { 8 | Write-Debug -Message 'Beginning' 9 | $configurationPath = Get-ConfigurationPath 10 | } 11 | process { 12 | # Merge existing configuration with updates 13 | $existingConfiguration = Import-Configuration 14 | $existingConfiguration.keys | Where-Object { 15 | $_ -notin $Configuration.keys 16 | } | ForEach-Object { 17 | $Configuration.Add($_, $existingConfiguration.Item($_) ) 18 | } 19 | 20 | # Drop keys not defined by default configuration 21 | $remove = $Configuration.keys | Where-Object { 22 | $_ -notin $existingConfiguration.keys 23 | } 24 | $remove | ForEach-Object { 25 | $Configuration.Remove($_) 26 | } 27 | 28 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting Configuration configuration to $($Configuration | ConvertTo-Json -Depth 5)")) { 29 | Write-Verbose "Setting configuration to $($Configuration | ConvertTo-Json -Depth 5)" 30 | $Configuration | Export-Configuration 31 | } 32 | } 33 | 34 | end { 35 | Write-Debug -Message 'Ending' 36 | } 37 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformSquelchChecksumWarning.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Set squelch checksum warning configuration. 4 | .DESCRIPTION 5 | Set squelch checksum warning configuration. 6 | .PARAMETER SquelchChecksumWarning 7 | Either true or false. 8 | .EXAMPLE 9 | Set-TerraformSquelchChecksumWarning $true 10 | 11 | Set squelch checksum warning configuration to true 12 | .INPUTS 13 | None. You cannot pipe objects to Set-TerraformSquelchChecksumWarning. 14 | .OUTPUTS 15 | None. Set-TerraformSquelchChecksumWarningreturns nothing. 16 | .LINK 17 | Get-TerraformConfiguration 18 | .LINK 19 | Online version: https://github.com/pearcec/Invoke-Terraform 20 | #> 21 | function Set-TerraformSquelchChecksumWarning { 22 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 23 | param( 24 | [parameter(Mandatory)] 25 | [boolean]$SquelchChecksumWarning 26 | ) 27 | begin { 28 | Write-Debug -Message 'Beginning' 29 | $configurationPath = Get-ConfigurationPath 30 | } 31 | 32 | process { 33 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting SquelchChecksumWarning configuration to $($SquelchChecksumWarning)")) { 34 | Write-Verbose "Setting SquelchChecksumWarning configuration to $($SquelchChecksumWarning)" 35 | Set-TerraformConfiguration @{ SquelchChecksumWarning = $SquelchChecksumWarning } -Confirm:$False 36 | } 37 | } 38 | 39 | end { 40 | Write-Debug -Message 'Ending' 41 | } 42 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformStableBinary.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Set version for stable terraform binary (ie. terraform.exe or terraform) 4 | .DESCRIPTION 5 | Set version for stable terraform binary (ie. terraform.exe or terraform) 6 | .PARAMETER TFVersion 7 | The preferred version. 8 | .PARAMETER SkipChecksum 9 | Skip release archive checksum verification. 10 | .PARAMETER SkipCodeSignature 11 | Skip code signature verifcation. 12 | .EXAMPLE 13 | Set-TerraformStableBinary 14 | 15 | Sets the latest terraform version to the static name terraform.exe or terraform 16 | .EXAMPLE 17 | Set-TerraformStableBinary -TFVersion 0.14.7 18 | 19 | Sets terraform version 0.14.7 to the static name terraform.exe or terraform 20 | .INPUTS 21 | None. You cannot pipe objects to Set-TerraformStableBinary. 22 | .OUTPUTS 23 | None. Set-TerraformStableBinary returns nothing. 24 | .LINK 25 | Get-TerraformStableBinary 26 | .LINK 27 | Online version: https://github.com/pearcec/Invoke-Terraform 28 | #> 29 | function Set-TerraformStableBinary { 30 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 31 | param( 32 | [string]$TFVersion, 33 | [switch]$SkipChecksum = $False, 34 | [switch]$SkipCodeSignature = $False 35 | ) 36 | 37 | begin { 38 | Write-Debug -Message 'Beginning' 39 | if (-not $TFVersion) { 40 | $TFVersion = Get-TerraformLatestRelease 41 | } 42 | } 43 | 44 | process { 45 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting static terraform binary to TFVesion $($TFVersion)")) { 46 | if (-not (Test-TerraformPath -TFVersion $TFVersion)) { 47 | Write-Verbose "Installing terraform version $($TFVersion)" 48 | Install-TerraformBinary -TFVersion $TFVersion -SkipChecksum:$SkipChecksum -SkipCodeSignature:$SkipCodeSignature 49 | } 50 | Copy-TerraformBinary -TFVersion $TFVersion 51 | } 52 | } 53 | 54 | end { 55 | Write-Debug -Message 'Ending' 56 | } 57 | } -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Set-TerraformVersion.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Set configuration version for terraform. 4 | .DESCRIPTION 5 | Set configuration version for terraform. 6 | .PARAMETER TFVersion 7 | The preferred version. 8 | .EXAMPLE 9 | Set-TerraformVersion -TFVersion 0.14.7 10 | 11 | Sets configuration version for terraform to 0.14.7 12 | .INPUTS 13 | None. You cannot pipe objects to Set-TerraformVersion. 14 | .OUTPUTS 15 | None. Set-TerraformVersion returns nothing. 16 | .LINK 17 | Get-TerraformConfiguration 18 | .LINK 19 | Online version: https://github.com/pearcec/Invoke-Terraform 20 | #> 21 | Function Set-TerraformVersion { 22 | [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'High')] 23 | param( 24 | [parameter(Mandatory)] 25 | [string]$TFVersion 26 | ) 27 | begin { 28 | Write-Debug -Message 'Beginning' 29 | $configurationPath = Get-ConfigurationPath 30 | $AutoStableBinary = (Get-TerraformConfiguration).AutoStableBinary 31 | } 32 | 33 | process { 34 | if ($PSCmdlet.ShouldProcess($configurationPath, "Setting TFVesion configuration version to $($TFVersion)")) { 35 | Write-Verbose "Setting TFVersion configuration version to $($TFVersion)" 36 | Set-TerraformConfiguration @{ TFVersion = $TfVersion } -Confirm:$False 37 | } 38 | if ($AutoStableBinary) { 39 | Set-TerraformStableBinary -TFVersion $TFVersion -Confirm:$ConfirmPreference 40 | } 41 | } 42 | 43 | end { 44 | Write-Debug -Message 'Ending' 45 | } 46 | } 47 | 48 | Set-Alias -Name Switch-Terraform -Value Set-TerraformVersion -------------------------------------------------------------------------------- /Invoke-Terraform/Public/Uninstall-Terraform.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Uninstall a version of terraform. 4 | .DESCRIPTION 5 | Unnstall a version of terraform. 6 | .PARAMETER TFVersion 7 | The version of terraform to uninstall. 8 | .EXAMPLE 9 | Uninstall-Terraform -TFVersion 0.14.7 10 | 11 | Uninstalls terraform version 0.14.7 12 | .INPUTS 13 | None. You cannot pipe objects to Uninstall-Terraform. 14 | .OUTPUTS 15 | None. Uninstall-Terraform returns nothing. 16 | .LINK 17 | Install-Terraform 18 | .LINK 19 | Online version: https://github.com/pearcec/Invoke-Terraform 20 | #> 21 | Function Uninstall-Terraform { 22 | param( 23 | [parameter(Mandatory)] 24 | [string]$TFVersion 25 | ) 26 | 27 | if (Test-TerraformPath -TFVersion $TFVersion) { 28 | Write-Verbose "Uninstalling terraform version $($TFVersion)" 29 | Remove-Item (Get-TerraformPath -TFVersion $TFVersion) -Force 30 | } else { 31 | Write-Warning "Unable to uninstall terraform. Version ($TFVersion) not found." 32 | } 33 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Christian Pearce 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Invoke-Terraform 2 | 3 | A PowerShell module to run terraform. 4 | 5 | | GitHub Actions | PSGallery | License | 6 | | ---------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------ | 7 | | [![GitHub Actions Status][github-actions-badge]][github-actions-build] | [![PowerShell Gallery][psgallery-badge]][psgallery] | [![License][license-badge]][license] | 8 | 9 | ## Overview 10 | 11 | *Invoke-Terraform* is a PowerShell module that downloads, validates binary authenticity and runs multiple versions of terraform. It is cross-platform with user preferences. 12 | 13 | ## Installation 14 | 15 | To install the module from the [PowerShell Gallery](https://www.powershellgallery.com/): 16 | 17 | ```powershell 18 | Install-Module -Name Invoke-Terraform -Repository PSGallery 19 | ``` 20 | 21 | ## Usage 22 | 23 | ```powershell 24 | Install-Terraform -TFVersion 0.14.9 25 | 26 | Invoke-Terraform 27 | 28 | Invoke-Terraform -TFVersion 0.14.8 29 | 30 | terraform -TFVersion 0.14.8 -version 31 | ``` 32 | 33 | ## Commands 34 | | Command | Description | 35 | | ----------------------------------- | ------------------------------------------------------------------------------------------ | 36 | | Confirm-TerraformHashicorpKey | Confirm the HashiCorp Security Key in gpg. | 37 | | Get-TerraformConfiguration | Get Invoke-Terraform configurations. | 38 | | Get-TerraformStableBinary | Get the path for the current static installation of terraform binary. | 39 | | Install-Terraform | Install a version of terraform. | 40 | | Invoke-Terraform | Run terraform. | 41 | | Set-TerraformAutoDownload | Set Invoke-Terraform to automatically download terraform if needed. | 42 | | Set-TerraformAutoStableBinary | Set Set-TerraformVersion to automatically switch static installation of terraform binary. | 43 | | Set-TerraformConfiguration | Set Invoke-Terraform configurations. | 44 | | Set-TerraformStableBinary | Set version of static installation of terraform binary. | 45 | | Set-TerraformSquelchChecksumWarning | Squelch checksum warnings. | 46 | | Set-TerraformVersion | Change default version of terraform to invoke. | 47 | | Switch-Terraform | Set-TerraformVersion alias. | 48 | | Uninstall-Terraform | Uninstall a version of terraform. | 49 | | terraform | Invoke-Terraform alias. | 50 | 51 | ## User Preferences 52 | 53 | | Name | Description | 54 | | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- | 55 | | Path | Installation location for terraform binaries. | 56 | | TFVersion | Preferred version of terraform. | 57 | | ReleaseUrl | Defaults to https://releases.hashicorp.com/terraform | 58 | | AutoDownload | Automatically download terraform when invoking if the binary is not installed. Defaults to false. | 59 | | AutoStableBinary | Automatically switch the static binary to the TFVersion called with Set-TerraformVersion (ie Switch-Terraform). Defaults to false. | 60 | 61 | ## Verification 62 | 63 | HashiCorp provides a few methods of [verification](https://www.hashicorp.com/security) for code authenticity. *Invoke-Terraform* uses checksum verification with gpg on all platforms and code signing verification with MacOS (starting ?) and Windows (starting with version 0.12.24). 64 | 65 | The default behavior is to always run code signature verification every time terraform is run when supported and checksums when binaries are installed. By default HashiCorp PGP Key is import from keyserver.ubuntu.com. The following additional preferences may be used to validate the signatures provide by this module, and adjust the settings according to your 66 | security tolerance: 67 | 68 | | Name | Description | 69 | | -------------------------- | ------------------------------------------------------------------------------------------- | 70 | | HashiCorpPGPKeyId | 0x34365D9472D7468F | 71 | | HashiCorpTeamIdentifier | D38WU7D763 | 72 | | HashiCorpWindowsThumbprint | 35AB9FC834D217E9E7B1778FB1B97AF7C73792F2, '7868E4F55FD7B047CD8BF93FEA8C38509CFB5939' | 73 | | PGPKeyServer | keyserver.ubuntu.com | 74 | | SquelchChecksumWarning | Turn off warning from gpg when HashiCorp imported key has not be signed. Defaults to false. | 75 | | SkipChecksum | Turn off release archive checksum verification via gpg. Defaults to false. | 76 | | SkipCodeSignature | Turn off code signature verification. Defaults to false. | 77 | 78 | ## Other behavior 79 | 80 | By default *Invoke-Terraform* searches the current working directory for the file `.terraform-version`. This file contains the preferred version of terraform. Store this file with your terraform project to seamlessly invoke the required version of terraform. 81 | 82 | ## Best Practice 83 | 84 | ### $ENV:Path, $PATH 85 | 86 | It is recommended the `terraform` binary be removed from `$ENV:Path`. Even though the powershell alias overrides what is available in the `Path`, unexpected usage could occur if this module was not loaded. This eliminates the chance of running an unplanned version. 87 | 88 | ### VSCode 89 | 90 | If terraform is removed from your path as recommended, the [vscode-terraform](https://github.com/hashicorp/vscode-terraform) extension breaks. The `Set-TerraformStableBinary` has been added to provide a stable path name. Run `Get-TerraformStableBinary` to retrieve the path. Use the following example for vscode settings: 91 | 92 | ```json 93 | "terraform.languageServer": { 94 | "external": true, 95 | "pathToBinary": "", 96 | "args": [ 97 | "serve", 98 | "-tf-exec=C:/users/pearcec/Documents/PowerShell/Modules/Invoke-Terraform/bin/terraform.exe", 99 | ], 100 | "maxNumberOfProblems": 100, 101 | "trace.server": "off" 102 | } 103 | ``` 104 | 105 | [github-actions-badge]: https://github.com/pearcec/Invoke-Terraform/workflows/CI/badge.svg 106 | [github-actions-build]: https://github.com/pearcec/Invoke-Terraform/actions 107 | [psgallery-badge]: https://img.shields.io/powershellgallery/dt/invoke-terraform.svg 108 | [psgallery]: https://www.powershellgallery.com/packages/invoke-terraform 109 | [license-badge]: https://img.shields.io/github/license/pearcec/invoke-terraform.svg 110 | [license]: https://raw.githubusercontent.com/pearcec/Invoke-Terraform/main/LICENSE 111 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | [cmdletbinding(DefaultParameterSetName = 'Task')] 2 | param( 3 | # Build task(s) to execute 4 | [parameter(ParameterSetName = 'task', Position = 0)] 5 | [string[]]$Task = 'default', 6 | 7 | # Bootstrap dependencies 8 | [switch]$Bootstrap, 9 | 10 | # List available build tasks 11 | [parameter(ParameterSetName = 'Help')] 12 | [switch]$Help 13 | ) 14 | 15 | $ErrorActionPreference = 'Stop' 16 | 17 | # Bootstrap dependencies 18 | if ($Bootstrap.IsPresent) { 19 | Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null 20 | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted 21 | if (-not (Get-Module -Name PSDepend -ListAvailable)) { 22 | Install-Module -Name PSDepend -Repository PSGallery -Scope CurrentUser 23 | } 24 | Invoke-PSDepend -Path './requirements.psd1' -Install -Import -Force -WarningAction SilentlyContinue 25 | } 26 | 27 | # Execute psake task(s) 28 | $psakeFile = './psakeFile.ps1' 29 | if ($PSCmdlet.ParameterSetName -eq 'Help') { 30 | Get-PSakeScriptTasks -buildFile $psakeFile | 31 | Format-Table -Property Name, Description, Alias, DependsOn 32 | } else { 33 | Invoke-psake -buildFile $psakeFile -taskList $Task -nologo 34 | exit ( [int]( -not $psake.build_success ) ) 35 | } -------------------------------------------------------------------------------- /docs/en-US/Confirm-TerraformHashicorpKey.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Confirm-TerraformHashicorpKey 9 | 10 | ## SYNOPSIS 11 | Helper function to sign the Hashi Corp PHP key. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Confirm-TerraformHashicorpKey [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Helper function to sign the Hashi Corp PHP key. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Confirm-TerraformHashicorpKey 27 | ``` 28 | 29 | Runs gpg to sign a HasiCorp PGP key. 30 | 31 | ## PARAMETERS 32 | 33 | ### CommonParameters 34 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 35 | 36 | ## INPUTS 37 | 38 | ### None. You cannot pipe objects to Confirm-TerraformHashicorpKey. 39 | ## OUTPUTS 40 | 41 | ### None. Confirm-TerraformHashicorpKey returns nothing. 42 | ## NOTES 43 | 44 | ## RELATED LINKS 45 | 46 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 47 | 48 | -------------------------------------------------------------------------------- /docs/en-US/Get-TerraformBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-TerraformBinary 9 | 10 | ## SYNOPSIS 11 | Get stable path for terraform binary (ie. 12 | terraform.exe or terraform) 13 | 14 | ## SYNTAX 15 | 16 | ``` 17 | Get-TerraformBinary [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Get stable path for terraform binary (ie. 22 | terraform.exe or terraform) 23 | 24 | ## EXAMPLES 25 | 26 | ### EXAMPLE 1 27 | ``` 28 | Get-TerraformBinary 29 | ``` 30 | 31 | Returns stable path for terraform binary 32 | 33 | ## PARAMETERS 34 | 35 | ### CommonParameters 36 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 37 | 38 | ## INPUTS 39 | 40 | ### None. You cannot pipe objects to Set-TerraformBinary. 41 | ## OUTPUTS 42 | 43 | ### Returns a path. 44 | ## NOTES 45 | 46 | ## RELATED LINKS 47 | 48 | [Set-TerraformBinary]() 49 | 50 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 51 | 52 | -------------------------------------------------------------------------------- /docs/en-US/Get-TerraformConfiguration.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-TerraformConfiguration 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-TerraformConfiguration [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### CommonParameters 34 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 35 | 36 | ## INPUTS 37 | 38 | ### None 39 | 40 | ## OUTPUTS 41 | 42 | ### System.Object 43 | ## NOTES 44 | 45 | ## RELATED LINKS 46 | -------------------------------------------------------------------------------- /docs/en-US/Get-TerraformStableBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-TerraformStableBinary 9 | 10 | ## SYNOPSIS 11 | Get stable path for terraform binary (ie. 12 | terraform.exe or terraform) 13 | 14 | ## SYNTAX 15 | 16 | ``` 17 | Get-TerraformStableBinary [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Get stable path for terraform binary (ie. 22 | terraform.exe or terraform) 23 | 24 | ## EXAMPLES 25 | 26 | ### EXAMPLE 1 27 | ``` 28 | Get-TerraformStableBinary 29 | ``` 30 | 31 | Returns stable path for terraform binary 32 | 33 | ## PARAMETERS 34 | 35 | ### CommonParameters 36 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 37 | 38 | ## INPUTS 39 | 40 | ### None. You cannot pipe objects to Set-TerraformStableBinary. 41 | ## OUTPUTS 42 | 43 | ### Returns a path. 44 | ## NOTES 45 | 46 | ## RELATED LINKS 47 | 48 | [Set-TerraformStableBinary]() 49 | 50 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 51 | 52 | -------------------------------------------------------------------------------- /docs/en-US/Install-Terraform.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Install-Terraform 9 | 10 | ## SYNOPSIS 11 | Install a version of terraform. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Install-Terraform [[-TFVersion] ] [-SkipChecksum] [-SkipCodeSignature] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Install a version of terraform. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Install-Terraform -TFVersion 0.14.7 27 | ``` 28 | 29 | Installs terraform version 0.14.7 30 | 31 | ## PARAMETERS 32 | 33 | ### -TFVersion 34 | The version of terraform to install. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -SkipChecksum 49 | Skip release archive checksum verification. 50 | 51 | ```yaml 52 | Type: SwitchParameter 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: Named 58 | Default value: False 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -SkipCodeSignature 64 | Skip code signature verifcation. 65 | 66 | ```yaml 67 | Type: SwitchParameter 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: False 72 | Position: Named 73 | Default value: False 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### CommonParameters 79 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 80 | 81 | ## INPUTS 82 | 83 | ### None. You cannot pipe objects to Install-Terraform. 84 | ## OUTPUTS 85 | 86 | ### None. Install-Terraform returns nothing. 87 | ## NOTES 88 | 89 | ## RELATED LINKS 90 | 91 | [Uninstall-Terraform]() 92 | 93 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 94 | 95 | -------------------------------------------------------------------------------- /docs/en-US/Invoke-Terraform.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-Terraform 9 | 10 | ## SYNOPSIS 11 | Run terraform version based on user preference. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Invoke-Terraform [[-TFVersion] ] [-SkipCodeSignature] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Run terraform version based on user preference. 21 | Additional parameters are passed to the terraform binary. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Invoke-Terraform -TFVersion 0.14.7 28 | ``` 29 | 30 | Runs terraform version 0.14.7 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | Invoke-Terraform 35 | ``` 36 | 37 | Runs terraform version based on user preference or default preference. 38 | 39 | ## PARAMETERS 40 | 41 | ### -TFVersion 42 | Override preferred version of terraform to run. 43 | 44 | ```yaml 45 | Type: String 46 | Parameter Sets: (All) 47 | Aliases: 48 | 49 | Required: False 50 | Position: 1 51 | Default value: None 52 | Accept pipeline input: False 53 | Accept wildcard characters: False 54 | ``` 55 | 56 | ### -SkipCodeSignature 57 | Skip code signature verifcation. 58 | 59 | ```yaml 60 | Type: SwitchParameter 61 | Parameter Sets: (All) 62 | Aliases: 63 | 64 | Required: False 65 | Position: Named 66 | Default value: False 67 | Accept pipeline input: False 68 | Accept wildcard characters: False 69 | ``` 70 | 71 | ### CommonParameters 72 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 73 | 74 | ## INPUTS 75 | 76 | ### None. You cannot pipe objects to Invoke-Terraform. 77 | ## OUTPUTS 78 | 79 | ### None. Invoke-Terraform returns nothing. 80 | ## NOTES 81 | 82 | ## RELATED LINKS 83 | 84 | [Install-Terraform]() 85 | 86 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 87 | 88 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformAutoDownload.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformAutoDownload 9 | 10 | ## SYNOPSIS 11 | Set auto download configuration. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformAutoDownload [-AutoDownload] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set auto download configuration. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Set-TerraformAutoDownload $true 27 | ``` 28 | 29 | Sets auto download configuration to true 30 | 31 | ## PARAMETERS 32 | 33 | ### -AutoDownload 34 | Either true or false. 35 | 36 | ```yaml 37 | Type: Boolean 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: False 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -WhatIf 49 | Shows what would happen if the cmdlet runs. 50 | The cmdlet is not run. 51 | 52 | ```yaml 53 | Type: SwitchParameter 54 | Parameter Sets: (All) 55 | Aliases: wi 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Confirm 65 | Prompts you for confirmation before running the cmdlet. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: cf 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None. You cannot pipe objects to Set-TerraformAutoDownload. 85 | ## OUTPUTS 86 | 87 | ### None. Set-TerraformAutoDownload returns nothing. 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | 92 | [Get-TerraformConfiguration]() 93 | 94 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 95 | 96 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformAutoStableBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformAutoStableBinary 9 | 10 | ## SYNOPSIS 11 | Set auto switch binary configuration. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformAutoStableBinary [-AutoStableBinary] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set auto switch binary configuration. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Set-TerraformAutoStableBinary $true 27 | ``` 28 | 29 | Sets auto switch binary configuration to true 30 | 31 | ## PARAMETERS 32 | 33 | ### -AutoStableBinary 34 | Either true or false. 35 | 36 | ```yaml 37 | Type: Boolean 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: False 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -WhatIf 49 | Shows what would happen if the cmdlet runs. 50 | The cmdlet is not run. 51 | 52 | ```yaml 53 | Type: SwitchParameter 54 | Parameter Sets: (All) 55 | Aliases: wi 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Confirm 65 | Prompts you for confirmation before running the cmdlet. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: cf 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None. You cannot pipe objects to Set-TerraformAutoStableBinary. 85 | ## OUTPUTS 86 | 87 | ### None. Set-TerraformAutoStableBinary returns nothing. 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | 92 | [Get-TerraformConfiguration]() 93 | 94 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 95 | 96 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformAutoSwitchBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformAutoSwitchBinary 9 | 10 | ## SYNOPSIS 11 | Set auto auto switch binary configuration. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformAutoSwitchBinary [-AutoSwitchBinary] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set auto auto switch binary configuration. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Set-TerraformAutoSwitchBinary $true 27 | ``` 28 | 29 | Sets auto switch binary configuration to true 30 | 31 | ## PARAMETERS 32 | 33 | ### -AutoSwitchBinary 34 | Either true or false. 35 | 36 | ```yaml 37 | Type: Boolean 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: False 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -WhatIf 49 | Shows what would happen if the cmdlet runs. 50 | The cmdlet is not run. 51 | 52 | ```yaml 53 | Type: SwitchParameter 54 | Parameter Sets: (All) 55 | Aliases: wi 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Confirm 65 | Prompts you for confirmation before running the cmdlet. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: cf 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None. You cannot pipe objects to Set-TerraformAutoSwitchBinary. 85 | ## OUTPUTS 86 | 87 | ### None. Set-TerraformAutoSwitchBinary returns nothing. 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | 92 | [Get-TerraformConfiguration]() 93 | 94 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 95 | 96 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformBinary 9 | 10 | ## SYNOPSIS 11 | Set version for stable terraform binary (ie. 12 | terraform.exe or terraform) 13 | 14 | ## SYNTAX 15 | 16 | ``` 17 | Set-TerraformBinary [[-TFVersion] ] [-SkipChecksum] [-SkipCodeSignature] [-WhatIf] [-Confirm] 18 | [] 19 | ``` 20 | 21 | ## DESCRIPTION 22 | Set version for stable terraform binary (ie. 23 | terraform.exe or terraform) 24 | 25 | ## EXAMPLES 26 | 27 | ### EXAMPLE 1 28 | ``` 29 | Set-TerraformBinary 30 | ``` 31 | 32 | Sets the latest terraform version to the static name terraform.exe or terraform 33 | 34 | ### EXAMPLE 2 35 | ``` 36 | Set-TerraformBinary -TFVersion 0.14.7 37 | ``` 38 | 39 | Sets terraform version 0.14.7 to the static name terraform.exe or terraform 40 | 41 | ## PARAMETERS 42 | 43 | ### -TFVersion 44 | The preferred version. 45 | 46 | ```yaml 47 | Type: String 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: False 52 | Position: 1 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### -SkipChecksum 59 | Skip release archive checksum verification. 60 | 61 | ```yaml 62 | Type: SwitchParameter 63 | Parameter Sets: (All) 64 | Aliases: 65 | 66 | Required: False 67 | Position: Named 68 | Default value: False 69 | Accept pipeline input: False 70 | Accept wildcard characters: False 71 | ``` 72 | 73 | ### -SkipCodeSignature 74 | Skip code signature verifcation. 75 | 76 | ```yaml 77 | Type: SwitchParameter 78 | Parameter Sets: (All) 79 | Aliases: 80 | 81 | Required: False 82 | Position: Named 83 | Default value: False 84 | Accept pipeline input: False 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### -WhatIf 89 | Shows what would happen if the cmdlet runs. 90 | The cmdlet is not run. 91 | 92 | ```yaml 93 | Type: SwitchParameter 94 | Parameter Sets: (All) 95 | Aliases: wi 96 | 97 | Required: False 98 | Position: Named 99 | Default value: None 100 | Accept pipeline input: False 101 | Accept wildcard characters: False 102 | ``` 103 | 104 | ### -Confirm 105 | Prompts you for confirmation before running the cmdlet. 106 | 107 | ```yaml 108 | Type: SwitchParameter 109 | Parameter Sets: (All) 110 | Aliases: cf 111 | 112 | Required: False 113 | Position: Named 114 | Default value: None 115 | Accept pipeline input: False 116 | Accept wildcard characters: False 117 | ``` 118 | 119 | ### CommonParameters 120 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 121 | 122 | ## INPUTS 123 | 124 | ### None. You cannot pipe objects to Set-TerraformBinary. 125 | ## OUTPUTS 126 | 127 | ### None. Set-TerraformBinary returns nothing. 128 | ## NOTES 129 | 130 | ## RELATED LINKS 131 | 132 | [Get-TerraformBinary]() 133 | 134 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 135 | 136 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformConfiguration.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformConfiguration 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformConfiguration [-Configuration] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Configuration 34 | {{ Fill Configuration Description }} 35 | 36 | ```yaml 37 | Type: Hashtable 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Confirm 49 | Prompts you for confirmation before running the cmdlet. 50 | 51 | ```yaml 52 | Type: SwitchParameter 53 | Parameter Sets: (All) 54 | Aliases: cf 55 | 56 | Required: False 57 | Position: Named 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -WhatIf 64 | Shows what would happen if the cmdlet runs. 65 | The cmdlet is not run. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: wi 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None 85 | 86 | ## OUTPUTS 87 | 88 | ### System.Object 89 | ## NOTES 90 | 91 | ## RELATED LINKS 92 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformSquelchChecksumWarning.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformSquelchChecksumWarning 9 | 10 | ## SYNOPSIS 11 | Set squelch checksum warning configuration. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformSquelchChecksumWarning [-SquelchChecksumWarning] [-WhatIf] [-Confirm] 17 | [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Set squelch checksum warning configuration. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Set-TerraformSquelchChecksumWarning $true 28 | ``` 29 | 30 | Set squelch checksum warning configuration to true 31 | 32 | ## PARAMETERS 33 | 34 | ### -SquelchChecksumWarning 35 | {{ Fill SquelchChecksumWarning Description }} 36 | 37 | ```yaml 38 | Type: Boolean 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 1 44 | Default value: False 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -WhatIf 50 | Shows what would happen if the cmdlet runs. 51 | The cmdlet is not run. 52 | 53 | ```yaml 54 | Type: SwitchParameter 55 | Parameter Sets: (All) 56 | Aliases: wi 57 | 58 | Required: False 59 | Position: Named 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### -Confirm 66 | Prompts you for confirmation before running the cmdlet. 67 | 68 | ```yaml 69 | Type: SwitchParameter 70 | Parameter Sets: (All) 71 | Aliases: cf 72 | 73 | Required: False 74 | Position: Named 75 | Default value: None 76 | Accept pipeline input: False 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### CommonParameters 81 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 82 | 83 | ## INPUTS 84 | 85 | ### None. You cannot pipe objects to Set-TerraformSquelchChecksumWarning. 86 | ## OUTPUTS 87 | 88 | ### None. Set-TerraformSquelchChecksumWarningreturns nothing. 89 | ## NOTES 90 | 91 | ## RELATED LINKS 92 | 93 | [Get-TerraformConfiguration]() 94 | 95 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 96 | 97 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformStableBinary.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformStableBinary 9 | 10 | ## SYNOPSIS 11 | Set version for stable terraform binary (ie. 12 | terraform.exe or terraform) 13 | 14 | ## SYNTAX 15 | 16 | ``` 17 | Set-TerraformStableBinary [[-TFVersion] ] [-SkipChecksum] [-SkipCodeSignature] [-WhatIf] [-Confirm] 18 | [] 19 | ``` 20 | 21 | ## DESCRIPTION 22 | Set version for stable terraform binary (ie. 23 | terraform.exe or terraform) 24 | 25 | ## EXAMPLES 26 | 27 | ### EXAMPLE 1 28 | ``` 29 | Set-TerraformStableBinary 30 | ``` 31 | 32 | Sets the latest terraform version to the static name terraform.exe or terraform 33 | 34 | ### EXAMPLE 2 35 | ``` 36 | Set-TerraformStableBinary -TFVersion 0.14.7 37 | ``` 38 | 39 | Sets terraform version 0.14.7 to the static name terraform.exe or terraform 40 | 41 | ## PARAMETERS 42 | 43 | ### -TFVersion 44 | The preferred version. 45 | 46 | ```yaml 47 | Type: String 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: False 52 | Position: 1 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### -SkipChecksum 59 | Skip release archive checksum verification. 60 | 61 | ```yaml 62 | Type: SwitchParameter 63 | Parameter Sets: (All) 64 | Aliases: 65 | 66 | Required: False 67 | Position: Named 68 | Default value: False 69 | Accept pipeline input: False 70 | Accept wildcard characters: False 71 | ``` 72 | 73 | ### -SkipCodeSignature 74 | Skip code signature verifcation. 75 | 76 | ```yaml 77 | Type: SwitchParameter 78 | Parameter Sets: (All) 79 | Aliases: 80 | 81 | Required: False 82 | Position: Named 83 | Default value: False 84 | Accept pipeline input: False 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### -WhatIf 89 | Shows what would happen if the cmdlet runs. 90 | The cmdlet is not run. 91 | 92 | ```yaml 93 | Type: SwitchParameter 94 | Parameter Sets: (All) 95 | Aliases: wi 96 | 97 | Required: False 98 | Position: Named 99 | Default value: None 100 | Accept pipeline input: False 101 | Accept wildcard characters: False 102 | ``` 103 | 104 | ### -Confirm 105 | Prompts you for confirmation before running the cmdlet. 106 | 107 | ```yaml 108 | Type: SwitchParameter 109 | Parameter Sets: (All) 110 | Aliases: cf 111 | 112 | Required: False 113 | Position: Named 114 | Default value: None 115 | Accept pipeline input: False 116 | Accept wildcard characters: False 117 | ``` 118 | 119 | ### CommonParameters 120 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 121 | 122 | ## INPUTS 123 | 124 | ### None. You cannot pipe objects to Set-TerraformStableBinary. 125 | ## OUTPUTS 126 | 127 | ### None. Set-TerraformStableBinary returns nothing. 128 | ## NOTES 129 | 130 | ## RELATED LINKS 131 | 132 | [Get-TerraformStableBinary]() 133 | 134 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 135 | 136 | -------------------------------------------------------------------------------- /docs/en-US/Set-TerraformVersion.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-TerraformVersion 9 | 10 | ## SYNOPSIS 11 | Set configuration version for terraform. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-TerraformVersion [-TFVersion] [-WhatIf] [-Confirm] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Set configuration version for terraform. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Set-TerraformVersion -TFVersion 0.14.7 27 | ``` 28 | 29 | Sets configuration version for terraform to 0.14.7 30 | 31 | ## PARAMETERS 32 | 33 | ### -TFVersion 34 | The preferred version. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -WhatIf 49 | Shows what would happen if the cmdlet runs. 50 | The cmdlet is not run. 51 | 52 | ```yaml 53 | Type: SwitchParameter 54 | Parameter Sets: (All) 55 | Aliases: wi 56 | 57 | Required: False 58 | Position: Named 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Confirm 65 | Prompts you for confirmation before running the cmdlet. 66 | 67 | ```yaml 68 | Type: SwitchParameter 69 | Parameter Sets: (All) 70 | Aliases: cf 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### CommonParameters 80 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 81 | 82 | ## INPUTS 83 | 84 | ### None. You cannot pipe objects to Set-TerraformVersion. 85 | ## OUTPUTS 86 | 87 | ### None. Set-TerraformVersion returns nothing. 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | 92 | [Get-TerraformConfiguration]() 93 | 94 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 95 | 96 | -------------------------------------------------------------------------------- /docs/en-US/Uninstall-Terraform.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Invoke-Terraform-help.xml 3 | Module Name: Invoke-Terraform 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Uninstall-Terraform 9 | 10 | ## SYNOPSIS 11 | Uninstall a version of terraform. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Uninstall-Terraform [-TFVersion] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Unnstall a version of terraform. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Uninstall-Terraform -TFVersion 0.14.7 27 | ``` 28 | 29 | Uninstalls terraform version 0.14.7 30 | 31 | ## PARAMETERS 32 | 33 | ### -TFVersion 34 | The version of terraform to uninstall. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None. You cannot pipe objects to Uninstall-Terraform. 54 | ## OUTPUTS 55 | 56 | ### None. Uninstall-Terraform returns nothing. 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | 61 | [Install-Terraform]() 62 | 63 | [Online version: https://github.com/pearcec/Invoke-Terraform]() 64 | 65 | -------------------------------------------------------------------------------- /psakeFile.ps1: -------------------------------------------------------------------------------- 1 | Properties { 2 | $PSBPreference.Build.CompileModule = $true 3 | $PSBPreference.Test.ImportModule = $true 4 | # Broken? 5 | # $PSBPreference.Test.CodeCoverage.Enabled = $true 6 | $PSBPreference.Test.ScriptAnalysisEnabled = $true 7 | $PSBPreference.Test.OutputFile = "$($PSBPreference.Build.OutDir)/testResults.xml" 8 | } 9 | 10 | Task default -depends Test 11 | 12 | Task Test -FromModule PowerShellBuild -Version '0.6.1' 13 | -------------------------------------------------------------------------------- /requirements.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | PSDependOptions = @{ 3 | Target = 'CurrentUser' 4 | } 5 | Configuration = '1.3.1' 6 | Pester = @{ 7 | Parameters = @{ 8 | MinimumVersion = '5.1.1' 9 | SkipPublisherCheck = $true 10 | } 11 | } 12 | platyPS = '0.14.1' 13 | PowerShellBuild = @{ 14 | RequiredVersion = '0.6.1' 15 | } 16 | psake = '4.9.0' 17 | PSScriptAnalyzer = '1.19.1' 18 | } -------------------------------------------------------------------------------- /tests/Help.tests.ps1: -------------------------------------------------------------------------------- 1 | # Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1) 2 | 3 | Describe 'Help' { 4 | $testCases = Get-Command -Module $env:BHProjectName -CommandType Cmdlet, Function | ForEach-Object { 5 | @{ 6 | Name = $_.Name 7 | Command = $_ 8 | } 9 | } 10 | 11 | BeforeAll { 12 | $commonParameters = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 13 | 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable', 'Confirm', 'Whatif' 14 | } 15 | 16 | # No auto-generated help 17 | Context 'Auto-generation' { 18 | It 'Help for [] should not be auto-generated' -TestCases $testCases { 19 | param($Name, $Command) 20 | 21 | $help = Get-Help $Name -ErrorAction SilentlyContinue 22 | $help.Synopsis | Should -Not -BeLike '*`[``]*' 23 | } 24 | } 25 | 26 | 27 | # Should have a description for every function 28 | Context 'Help description' { 29 | It 'Help for [] has a description' -TestCases $testCases { 30 | param($Name, $Command) 31 | 32 | $help = Get-Help $Name -ErrorAction SilentlyContinue 33 | $help.Description | Should -Not -BeNullOrEmpty 34 | } 35 | } 36 | 37 | # Should be at least one example per command 38 | Context 'Examples' { 39 | It 'Help for [] has example code' -TestCases $testCases { 40 | param($Name, $Command) 41 | 42 | $help = Get-Help $Name -ErrorAction SilentlyContinue 43 | ($help.Examples.Example | Select-Object -First 1).Code | Should -Not -BeNullOrEmpty 44 | } 45 | } 46 | 47 | # Parameter help 48 | Context 'Parameter help' { 49 | It '[] has help for every parameter' -TestCases $testCases { 50 | param($Name, $Command) 51 | 52 | $help = Get-Help $Name -ErrorAction SilentlyContinue 53 | $parameters = $Command.ParameterSets.Parameters | 54 | Sort-Object -Property Name -Unique | 55 | Where-Object { $_.Name -notin $commonParameters } 56 | $parameterNames = $parameters.Name 57 | 58 | # Without the filter, WhatIf and Confirm parameters are still flagged in "finds help parameter in code" test 59 | $helpParameters = $help.Parameters.Parameter | 60 | Where-Object { $_.Name -notin $commonParameters } | 61 | Sort-Object -Property Name -Unique 62 | $helpParameterNames = $helpParameters.Name 63 | 64 | foreach ($parameter in $parameters) { 65 | $parameterName = $parameter.Name 66 | $parameterHelp = $help.parameters.parameter | Where-Object Name -EQ $parameterName 67 | $parameterHelp.Description.Text | Should -Not -BeNullOrEmpty 68 | 69 | $codeMandatory = $parameter.IsMandatory.toString() 70 | $parameterHelp.Required | Should -Be $codeMandatory 71 | 72 | $codeType = $parameter.ParameterType.Name 73 | # To avoid calling Trim method on a null object. 74 | $helpType = if ($parameterHelp.parameterValue) { $parameterHelp.parameterValue.Trim() } 75 | $helpType | Should -Be $codeType 76 | } 77 | } 78 | } 79 | 80 | # Links are valid 81 | Context 'Links' { 82 | It 'Help for [] has valid links' -TestCases $testCases { 83 | param($Name, $Command) 84 | 85 | $help = Get-Help $Name -ErrorAction SilentlyContinue 86 | $link = $help.relatedLinks.navigationLink.uri 87 | foreach ($link in $links) { 88 | $Results = Invoke-WebRequest -Uri $link -UseBasicParsing 89 | $Results.StatusCode | Should -Be '200' 90 | } 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /tests/Manifest.tests.ps1: -------------------------------------------------------------------------------- 1 | # Taken with love from @devblackops (https://raw.githubusercontent.com/devblackops/Terminal-Icons/master/tests/Manifest.tests.ps1) 2 | 3 | Describe 'Module manifest' { 4 | 5 | BeforeAll { 6 | $moduleName = $env:BHProjectName 7 | $manifest = Test-ModuleManifest $env:BHPSModuleManifest 8 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 9 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 10 | $outputModVerDir = [IO.Path]::Combine($outputModDir, $manifest.Version) 11 | $outputManifestPath = [IO.Path]::Combine($outputModVerDir, "$($moduleName).psd1") 12 | $changelogPath = [IO.Path]::Combine($env:BHProjectPath, 'CHANGELOG.md') 13 | } 14 | 15 | Context 'Validation' { 16 | 17 | $script:manifest = $null 18 | 19 | It 'has a valid manifest' { 20 | { 21 | $script:manifest = Test-ModuleManifest -Path $outputManifestPath -Verbose:$false -ErrorAction Stop -WarningAction SilentlyContinue 22 | } | Should -Not -Throw 23 | } 24 | 25 | It 'has a valid name in the manifest' { 26 | $script:manifest.Name | Should -Be $env:BHProjectName 27 | } 28 | 29 | It 'has a valid root module' { 30 | $script:manifest.RootModule | Should -Be "$($moduleName).psm1" 31 | } 32 | 33 | It 'has a valid version in the manifest' { 34 | $script:manifest.Version -as [Version] | Should -Not -BeNullOrEmpty 35 | } 36 | 37 | It 'has a valid description' { 38 | $script:manifest.Description | Should -Not -BeNullOrEmpty 39 | } 40 | 41 | It 'has a valid author' { 42 | $script:manifest.Author | Should -Not -BeNullOrEmpty 43 | } 44 | 45 | It 'has a valid guid' { 46 | { 47 | [guid]::Parse($script:manifest.Guid) 48 | } | Should -Not -Throw 49 | } 50 | 51 | It 'has a valid copyright' { 52 | $script:manifest.CopyRight | Should -Not -BeNullOrEmpty 53 | } 54 | 55 | $script:changelogVersion = $null 56 | It 'has a valid version in the changelog' { 57 | foreach ($line in (Get-Content $changelogPath)) { 58 | if ($line -match '^##\s\[(?(\d+\.){1,3}\d+)\]') { 59 | $script:changelogVersion = $matches.Version 60 | break 61 | } 62 | } 63 | $script:changelogVersion | Should -Not -BeNullOrEmpty 64 | $script:changelogVersion -as [Version] | Should -Not -BeNullOrEmpty 65 | } 66 | 67 | It 'changelog and manifest versions are the same' { 68 | $script:changelogVersion -as [Version] | Should -Be ( $script:manifest.Version -as [Version] ) 69 | } 70 | 71 | if (Get-Command git.exe -ErrorAction SilentlyContinue) { 72 | $script:tagVersion = $null 73 | It 'is tagged with a valid version' -Skip { 74 | $thisCommit = git.exe log --decorate --oneline HEAD~1..HEAD 75 | 76 | if ($thisCommit -match 'tag:\s*(\d+(?:\.\d+)*)') { 77 | $script:tagVersion = $matches[1] 78 | } 79 | 80 | $script:tagVersion | Should -Not -BeNullOrEmpty 81 | $script:tagVersion -as [Version] | Should -Not -BeNullOrEmpty 82 | } 83 | 84 | It 'all versions are the same' { 85 | $script:changelogVersion -as [Version] | Should -Be ( $script:manifest.Version -as [Version] ) 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /tests/unit/Get-TerraformConfiguration.tests.ps1: -------------------------------------------------------------------------------- 1 | 2 | Describe 'Get-TerraformConfiguration' { 3 | BeforeAll { 4 | $configuration = [IO.Path]::Combine($ENV:BHPSModulePath, 'Configuration.psd1') 5 | $defaultConfiguration = Import-Configuration -DefaultPath $configuration -CompanyName 'Invoke-Terraform' -Name 'Invoke-Terraform' 6 | $setting = Get-TerraformConfiguration 7 | } 8 | It 'has default TFPath' { 9 | $script:setting.TPath | Should -Be $script:defaultConfiguration.TFPath 10 | } 11 | It 'has default TFVersion' { 12 | $script:setting.TFVersion | Should -Be $script:defaultConfiguration.TFVersion 13 | } 14 | It 'has default ReleaseUrl' { 15 | $script:setting.ReleaseUrl | Should -Be $script:defaultConfiguration.ReleaseUrl 16 | } 17 | It 'has default AutoDownload' { 18 | $script:setting.AutoDownload | Should -Be $script:defaultConfiguration.AutoDownload 19 | } 20 | It 'has default AutoStableBinary' { 21 | $script:setting.AutoStableBinary | Should -Be $script:defaultConfiguration.AutoStableBinary 22 | } 23 | It 'has default HashiCorpPGPKeyId' { 24 | $script:setting.HashiCorpPGPKeyId | Should -Be $script:defaultConfiguration.HashiCorpPGPKeyId 25 | } 26 | It 'has default HashiCorpTeamIdentifier' { 27 | $script:setting.HashiCorpTeamIdentifier | Should -Be $script:defaultConfiguration.HashiCorpTeamIdentifier 28 | } 29 | It 'has default HashiCorpWindowsThumbprint' { 30 | $script:setting.HashiCorpWindowsThumbprint | Should -Be $script:defaultConfiguration.HashiCorpWindowsThumbprint 31 | } 32 | It 'has default PGPKeyServer' { 33 | $script:setting.PGPKeyServer | Should -Be $script:defaultConfiguration.PGPKeyServer 34 | } 35 | It 'has default SquelchChecksumWarning' { 36 | $script:setting.SquelchChecksumWarning | Should -Be $script:defaultConfiguration.SquelchChecksumWarning 37 | } 38 | It 'has default SkipChecksum' { 39 | $script:setting.SkipChecksum | Should -Be $script:defaultConfiguration.SkipChecksum 40 | } 41 | It 'has default SkipCodeSignature' { 42 | $script:setting.SkipCodeSignature | Should -Be $script:defaultConfiguration.SkipCodeSignature 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /tests/unit/Install-Terraform.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Install-Terraform' { 2 | BeforeAll { 3 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 4 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 5 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 6 | 7 | if (Test-Path $outputBinDir) { 8 | Remove-Item -Recurse $outputBinDir 9 | } 10 | New-Item $outputBinDir -ItemType directory 11 | } 12 | It 'has version passed 0.14.2' { 13 | Install-Terraform -TFVersion 0.14.2 14 | $testPath = [IO.Path]::Combine($outputBinDir, 'terraform_0.14.2*') 15 | $test = Test-Path $testPath 16 | $test | Should -BeTrue 17 | } 18 | It 'has latest release' { 19 | $headers = @{ 20 | Accept = 'application/vnd.github.v3+json' 21 | } 22 | 23 | $response = Invoke-RestMethod 'https://api.github.com/repos/hashicorp/terraform/releases/latest' -Method 'GET' -Headers $headers 24 | $latest = $response.name.substring(1) 25 | Install-Terraform 26 | $testPath = [IO.Path]::Combine($outputBinDir, "terraform_$($latest)*") 27 | $test = Test-Path $testPath 28 | $test | Should -BeTrue 29 | } 30 | } -------------------------------------------------------------------------------- /tests/unit/Invoke-Terraform.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Invoke-Terraform' { 2 | BeforeAll { 3 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 4 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 5 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 6 | 7 | if (Test-Path $outputBinDir) { 8 | Remove-Item -Recurse $outputBinDir 9 | } 10 | New-Item $outputBinDir -ItemType directory 11 | } 12 | It 'has version defined by configuration 0.14.5' { 13 | Set-TerraformVersion -TFVersion 0.14.5 -Confirm:$false 14 | Set-TerraformAutoDownload -AutoDownload:$true -Confirm:$false 15 | Invoke-Terraform -version | Out-File TestDrive:\version.txt 16 | (Get-Content TestDrive:\version.txt)[0] | Should -Match 0.14.5 17 | } 18 | It 'has version passed 0.14.6' { 19 | Set-TerraformVersion -TFVersion 0.14.5 -Confirm:$false 20 | Set-TerraformAutoDownload -AutoDownload:$true -Confirm:$false 21 | Invoke-Terraform 0.14.6 -version | Out-File TestDrive:\version-0.14.6.txt 22 | (Get-Content TestDrive:\version-0.14.6.txt)[0] | Should -Match 0.14.6 23 | } 24 | It 'has version 0.14.1 from .terraform-version' { 25 | Set-TerraformVersion -TFVersion 0.14.5 -Confirm:$false 26 | Set-TerraformAutoDownload -AutoDownload:$true -Confirm:$false 27 | $terraformVersionFile = [IO.Path]::Combine('..', '.terraform-version') 28 | '0.14.1' | Out-File -Path $terraformVersionFile 29 | Invoke-Terraform -version | Out-File TestDrive:\version-0.14.1.txt 30 | (Get-Content TestDrive:\version-0.14.1.txt)[0] | Should -Match 0.14.1 31 | Remove-Item -Force -Path $terraformVersionFile 32 | } 33 | It 'has version 1.0.0' { 34 | Set-TerraformVersion -TFVersion 1.0.0 -Confirm:$false 35 | Set-TerraformAutoDownload -AutoDownload:$true -Confirm:$false 36 | Set-TerraformVersion -TFVersion 0.14.1 -Confirm:$false 37 | Invoke-Terraform 1.0.0 -version | Out-File TestDrive:\version-1.0.0.txt 38 | (Get-Content TestDrive:\version-1.0.0.txt)[0] | Should -Match 'v1.0.0' 39 | Invoke-Terraform -TFVersion 1.0.0 -version | Out-File TestDrive:\version-1.0.0.txt 40 | (Get-Content TestDrive:\version-1.0.0.txt)[0] | Should -Match 'v1.0.0' 41 | } 42 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformAutoDownload.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Set-TerraformAutoDownload' { 2 | It 'has AutoDownload configuration set to true' { 3 | Set-TerraformAutoDownload -AutoDownload $true -Confirm:$false 4 | $setting = Get-TerraformConfiguration 5 | $setting.AutoDownload | Should -Be $true 6 | } 7 | 8 | It 'has AutoDownload configuration set to false' { 9 | Set-TerraformAutoDownload -AutoDownload $false -Confirm:$false 10 | $setting = Get-TerraformConfiguration 11 | $setting.AutoDownload | Should -Be $false 12 | } 13 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformAutoStableBinary.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Set-TerraformAutoStableBinary' { 2 | It 'has AutoStableBinary configuration set to true' { 3 | Set-TerraformAutoStableBinary -AutoStableBinary $true -Confirm:$false 4 | $setting = Get-TerraformConfiguration 5 | $setting.AutoStableBinary | Should -Be $true 6 | } 7 | 8 | It 'has AutoStableBinary configuration set to false' { 9 | Set-TerraformAutoStableBinary -AutoStableBinary $false -Confirm:$false 10 | $setting = Get-TerraformConfiguration 11 | $setting.AutoStableBinary | Should -Be $false 12 | } 13 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformConfiguration.tests.ps1: -------------------------------------------------------------------------------- 1 | # Only test configuration not covered by other tests 2 | Describe 'Set-TerraformVersion' { 3 | BeforeAll { 4 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 5 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 6 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 7 | 8 | if (Test-Path $outputBinDir) { 9 | Remove-Item -Recurse $outputBinDir 10 | } 11 | New-Item $outputBinDir -ItemType directory 12 | } 13 | It 'has Terraform version configuration set to 0.14.6' { 14 | Set-TerraformConfiguration -Configuration @{'TFVersion' = '0.14.6' } -Confirm:$false 15 | $setting = Get-TerraformConfiguration 16 | $setting.TFVersion | Should -Be '0.14.6' 17 | } 18 | It 'has not-existent set to null' { 19 | Set-TerraformConfiguration -Configuration @{'Fake' = 'fake' } -Confirm:$false 20 | $setting = Get-TerraformConfiguration 21 | $setting.Fake | Should -Be $null 22 | } 23 | It 'has string set for thumbprint' { 24 | Set-TerraformConfiguration -Configuration @{'HashiCorpWindowsThumbprint' = '35AB9FC834D217E9E7B1778FB1B97AF7C73792F2'} -Confirm:$false 25 | Install-Terraform -TFVersion 0.14.3 26 | $testPath = [IO.Path]::Combine($outputBinDir, 'terraform_0.14.3*') 27 | $test = Test-Path $testPath 28 | $test | Should -BeTrue 29 | } 30 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformSquelchChecksumWarning.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Set-TerraformSquelchChecksumWarning' { 2 | It 'has Squelch Checksum Warning configuration set to true' { 3 | Set-TerraformSquelchChecksumWarning -SquelchChecksumWarning $true -Confirm:$false 4 | $setting = Get-TerraformConfiguration 5 | $setting.SquelchChecksumWarning | Should -Be $true 6 | } 7 | 8 | It 'has Squelch Checksum Warning configuration set to false' { 9 | Set-TerraformSquelchChecksumWarning -SquelchChecksumWarning $false -Confirm:$false 10 | $setting = Get-TerraformConfiguration 11 | $setting.SquelchChecksumWarning | Should -Be $false 12 | } 13 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformStableBinary.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Set-TerraformStableBinary' { 2 | BeforeAll { 3 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 4 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 5 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 6 | 7 | if (Test-Path $outputBinDir) { 8 | Remove-Item -Recurse $outputBinDir 9 | } 10 | New-Item $outputBinDir -ItemType directory 11 | 12 | # Reset configuration 13 | $configuration = [IO.Path]::Combine($ENV:BHPSModulePath, 'Configuration.psd1') 14 | $defaultConfiguration = Import-Configuration -DefaultPath $configuration -CompanyName 'Invoke-Terraform' -Name 'Invoke-Terraform' 15 | Set-TerraformConfiguration -Configuration $defaultConfiguration -Confirm:$false 16 | } 17 | It 'has version passed 0.14.2' { 18 | Set-TerraformStableBinary -TFVersion 0.14.2 -Confirm:$false 19 | $testPathBin = Get-TerraformStableBinary 20 | $test = & $testPathBin -version | Select-String -Pattern ('Terraform v{0}' -f '0.14.2') -Quiet 21 | $test | Should -BeTrue 22 | } 23 | It 'has latest release' { 24 | $headers = @{ 25 | Accept = 'application/vnd.github.v3+json' 26 | } 27 | 28 | $response = Invoke-RestMethod 'https://api.github.com/repos/hashicorp/terraform/releases/latest' -Method 'GET' -Headers $headers 29 | $latest = $response.name.substring(1) 30 | Set-TerraformStableBinary -Confirm:$false 31 | $testPathBin = Get-TerraformStableBinary 32 | $test = & $testPathBin -version | Select-String -Pattern ('Terraform v{0}' -f $latest) -Quiet 33 | $test | Should -BeTrue 34 | } 35 | } -------------------------------------------------------------------------------- /tests/unit/Set-TerraformVersion.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Set-TerraformVersion' { 2 | BeforeAll { 3 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 4 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 5 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 6 | 7 | if (Test-Path $outputBinDir) { 8 | Remove-Item -Recurse $outputBinDir 9 | } 10 | New-Item $outputBinDir -ItemType directory 11 | } 12 | It 'has Terraform version configuration set to 0.14.8' { 13 | Set-TerraformVersion -TFVersion 0.14.8 -Confirm:$false 14 | $setting = Get-TerraformConfiguration 15 | $setting.TFVersion | Should -Be '0.14.8' 16 | } 17 | It 'has version passed 0.14.3' { 18 | Set-TerraformAutoStableBinary -AutoStableBinary:$true -Confirm:$false 19 | Set-TerraformVersion -TFVersion 0.14.3 -Confirm:$false 20 | $testPathBin = Get-TerraformStableBinary 21 | $test = & $testPathBin -version | Select-String -Pattern ('Terraform v{0}' -f '0.14.3') -Quiet 22 | $test | Should -BeTrue 23 | } 24 | } -------------------------------------------------------------------------------- /tests/unit/Uninstall-Terraform.tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Uninstall-Terraform' { 2 | BeforeAll { 3 | $outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output') 4 | $outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName) 5 | $outputBinDir = [IO.Path]::Combine($outputModDir, 'bin') 6 | 7 | if (Test-Path $outputBinDir) { 8 | Remove-Item -Recurse $outputBinDir 9 | } 10 | New-Item $outputBinDir -ItemType directory 11 | } 12 | It 'has version passed 0.14.3 removed' { 13 | Install-Terraform -TFVersion 0.14.3 14 | $testPath = [IO.Path]::Combine($outputBinDir, 'terraform_0.14.3*') 15 | $test = Test-Path $testPath 16 | $test | Should -BeTrue 17 | Uninstall-Terraform -TFVersion 0.14.3 18 | $test = Test-Path $testPath 19 | $test | Should -BeFalse 20 | } 21 | } --------------------------------------------------------------------------------