Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hashicorp/terraform-provider-assert
Offers functions to validate and assert values within Terraform configurations, simplifying variable validation and custom conditions.
https://github.com/hashicorp/terraform-provider-assert
assert golang provider terraform test
Last synced: 3 months ago
JSON representation
Offers functions to validate and assert values within Terraform configurations, simplifying variable validation and custom conditions.
- Host: GitHub
- URL: https://github.com/hashicorp/terraform-provider-assert
- Owner: hashicorp
- License: mpl-2.0
- Created: 2024-03-12T22:18:50.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-25T12:28:06.000Z (4 months ago)
- Last Synced: 2024-09-27T12:41:52.673Z (4 months ago)
- Topics: assert, golang, provider, terraform, test
- Language: Go
- Homepage: https://registry.terraform.io/providers/hashicorp/assert/latest/docs
- Size: 9.83 MB
- Stars: 33
- Watchers: 10
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome-repositories - hashicorp/terraform-provider-assert - Offers functions to validate and assert values within Terraform configurations, simplifying variable validation and custom conditions. (Go)
README
# Terraform Provider: Assert
The [Assert Terraform provider]((https://registry.terraform.io/providers/hashicorp/assert/latest/docs)) is intended for use when writing [Terraform Tests](https://developer.hashicorp.com/terraform/language/tests), [Variable Validation](https://developer.hashicorp.com/terraform/language/values/variables#custom-validation-rules), [Preconditions and Postconditions](https://developer.hashicorp.com/terraform/language/expressions/custom-conditions#preconditions-and-postconditions), or [Continuous Validation](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/health#continuous-validation). It serves as a way to verify that the values in your Terraform configuration meet specific criteria. The provider only contains functions to assert values, and does not manage any resources.
* [Terraform Registry](https://registry.terraform.io/providers/hashicorp/assert/latest/docs)
* [Contributor Guide](https://hashicorp.github.io/terraform-provider-assert/)To use provider functions, declare the provider as a required provider in your Terraform configuration:
```hcl
terraform {
required_providers {
assert = {
source = "hashicorp/assert"
}
}
}
```## Continuous Validation
Simplify continuous validation checks that run as part of your Terraform workflow:
```hcl
data "http" "terraform_io" {
url = "https://www.terraform.io"
}check "health_check" {
assert {
condition = provider::assert::http_success(data.http.terraform_io.status_code)
error_message = "${data.http.terraform_io.url} returned an unhealthy status code"
}
}
```## Terraform Test
Test assertions in your Terraform configuration should be simple and easy to read:
```hcl
run "ebs_volume_size" {
command = plan
assert {
condition = provider::assert::between(1, 100, aws_ebs_volume.example.size)
error_message = "EBS volume size must be between 1 and 100 GiB"
}
}
```## Variable Validation
Write simple validation rules for your Terraform variables:
```hcl
variable "ebs_volume_size" {
type = number
validation {
condition = provider::assert::between(1, 100, var.ebs_volume_size)
error_message = "EBS volume size must be between 1 and 100 GiB"
}
}
```## License
[Mozilla Public License v2.0](./LICENSE)