-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add README for provider-pinned-versions hook
- Loading branch information
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Provider Pinned Versions Hook | ||
|
||
This hook validates that all providers under the `required_providers` block of a Terraform configuration file have a pinned version. | ||
|
||
## Usage | ||
|
||
### cli | ||
|
||
```bash | ||
pre-commit run provider-pinned-versions --all-files | ||
``` | ||
|
||
### pre-commit config | ||
|
||
```yaml | ||
repos: | ||
- repo: https://github.com/open-turo/standards-terraform | ||
hooks: | ||
- id: provider-pinned-versions | ||
files: ^terraform.tf$ | ||
``` | ||
## Examples of supported configurations | ||
### Standard pinned version | ||
```hcl | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "3.40.0" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Pre-release version | ||
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "3.41.0-beta1" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Examples of unsupported configurations | ||
|
||
### Version constraints | ||
|
||
If the version contains any of the following constraint characters, `!~><`, the hook will fail. | ||
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 3.40.0" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 3.40.0" | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters