https://github.com/christosgalano/terraform-testing-example
An opinionated example of how to test Terraform configurations.
https://github.com/christosgalano/terraform-testing-example
ci-cd cloud devops iac terraform testing
Last synced: 9 months ago
JSON representation
An opinionated example of how to test Terraform configurations.
- Host: GitHub
- URL: https://github.com/christosgalano/terraform-testing-example
- Owner: christosgalano
- License: mit
- Created: 2024-05-20T07:01:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-22T21:02:59.000Z (over 1 year ago)
- Last Synced: 2024-12-31T15:12:53.270Z (over 1 year ago)
- Topics: ci-cd, cloud, devops, iac, terraform, testing
- Language: HCL
- Homepage:
- Size: 244 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# terraform-testing-example
An opinionated example of how to test Terraform configurations. It includes:
- **Terraform Configurations:** A simple architecture that creates an Azure Web App, Key Vault, and associated resources. This demonstrates how to structure and organize Terraform code.
- **Tests:** Contract and integration tests that ensure the Terraform code behaves as expected. These tests are located in the tests directory and provide examples of how to write and structure tests for Terraform code.
- **GitHub Workflows:** Automated workflows for continuous integration and deployment. These workflows, located in the .github/workflows directory, automate the process of scanning the code for issues, running the tests, and deploying the infrastructure.
- **Configuration Files:** These files configure various tools used in the repository, such as tflint, trivy, checkov, and terraform-docs. They demonstrate how to set up and configure these tools for use with Terraform.
This repository follows best practices for Terraform development and uses GitHub workflows for automation. It serves as a practical example of how to test and deploy Terraform code.


## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.8 |
| [azurerm](#requirement\_azurerm) | ~> 3.0 |
## Providers
| Name | Version |
|------|---------|
| [azurerm](#provider\_azurerm) | ~> 3.0 |
## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [azurerm_key_vault.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault) | resource |
| [azurerm_linux_web_app.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app) | resource |
| [azurerm_private_dns_zone.vault](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone) | resource |
| [azurerm_private_dns_zone_virtual_network_link.vault](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) | resource |
| [azurerm_private_endpoint.vault](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) | resource |
| [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_service_plan.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) | resource |
| [azurerm_subnet.app_service](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource |
| [azurerm_subnet.private_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource |
| [azurerm_virtual_network.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) | resource |
| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [app\_service\_delegated\_subnet](#input\_app\_service\_delegated\_subnet) | Configuration for the App Service delegated subnet. |
object({
name = string
address_prefix = string
}) | n/a | yes |
| [app\_service\_plan](#input\_app\_service\_plan) | Configuration for the app service plan. | object({
name = string
sku = string
}) | n/a | yes |
| [key\_vault](#input\_key\_vault) | Configuration for the key vault. | object({
name = string
sku = string
private_endpoint_name = string
dns_zone_name = optional(string, "privatelink.vaultcore.azure.net")
}) | n/a | yes |
| [location](#input\_location) | Location of the resources. | `string` | n/a | yes |
| [private\_endpoint\_subnet](#input\_private\_endpoint\_subnet) | Configuration for the private endpoint subnet. | object({
name = string
address_prefix = string
}) | n/a | yes |
| [resource\_group\_name](#input\_resource\_group\_name) | Name of the resource group. | `string` | n/a | yes |
| [virtual\_network](#input\_virtual\_network) | Configuration for the virtual network. | object({
name = string
address_space = list(string)
}) | n/a | yes |
| [web\_app](#input\_web\_app) | Configuration for the web app. | object({
name = string
docker_image_name = string
docker_registry_url = string
}) | n/a | yes |
## Outputs
| Name | Description |
|------|-------------|
| [app\_service\_plan\_id](#output\_app\_service\_plan\_id) | The ID of the app service plan. |
| [app\_service\_subnet\_id](#output\_app\_service\_subnet\_id) | The ID of the app service subnet. |
| [key\_vault\_id](#output\_key\_vault\_id) | The ID of the key vault. |
| [key\_vault\_uri](#output\_key\_vault\_uri) | The URI of the key vault. |
| [private\_dns\_zone\_vault\_id](#output\_private\_dns\_zone\_vault\_id) | The ID of the private DNS zone for the vault. |
| [private\_endpoint\_subnet\_id](#output\_private\_endpoint\_subnet\_id) | The ID of the private endpoint subnet. |
| [private\_endpoint\_vault\_id](#output\_private\_endpoint\_vault\_id) | The ID of the private endpoint for the vault. |
| [resource\_group\_id](#output\_resource\_group\_id) | The ID of the resource group. |
| [virtual\_network\_id](#output\_virtual\_network\_id) | The ID of the virtual network. |
| [web\_app\_hostname](#output\_web\_app\_hostname) | The hostname of the web app. |
| [web\_app\_id](#output\_web\_app\_id) | The ID of the web app. |