{"id":15873545,"url":"https://github.com/tombuildsstuff/terraform-configuration-tester","last_synced_at":"2025-03-16T04:30:41.182Z","repository":{"id":57493796,"uuid":"175480889","full_name":"tombuildsstuff/terraform-configuration-tester","owner":"tombuildsstuff","description":"a suite of helpers for testing Terraform Configuration Examples","archived":false,"fork":false,"pushed_at":"2019-03-13T18:53:33.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T05:01:54.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tombuildsstuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-13T18:53:16.000Z","updated_at":"2019-04-22T19:29:43.000Z","dependencies_parsed_at":"2022-08-30T04:01:53.241Z","dependency_job_id":null,"html_url":"https://github.com/tombuildsstuff/terraform-configuration-tester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombuildsstuff%2Fterraform-configuration-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombuildsstuff%2Fterraform-configuration-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombuildsstuff%2Fterraform-configuration-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombuildsstuff%2Fterraform-configuration-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tombuildsstuff","download_url":"https://codeload.github.com/tombuildsstuff/terraform-configuration-tester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243802941,"owners_count":20350316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T01:03:58.610Z","updated_at":"2025-03-16T04:30:40.769Z","avatar_url":"https://github.com/tombuildsstuff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Terraform Provider Example Tester\n\nThis library provides several helpers to allow for testing Examples of a Terraform Provider.\n\nFor each Directory found containing examples (requirements below) - this Test Helper does the following:\n\n* Parses the `variables.tf` file within the directory and then either Generates or passes through a value from an Env. Variable\n* Downloads Terraform Core from releases.hashicorp.com\n* Writes out a `test.tf` which contains the following:\n\n```hcl\nterraform {\n  required_version = \"=0.11.13\"\n}\n\nprovider \"azurerm\" {\n  version = \"=1.23.0\"\n}\n```\n\n* Writes out a `test.tfvars` containing the values for each variable listed above\n* Runs: `terraform init`, `terraform validate`, `terraform apply` and then `terraform destroy`\n\nThe intention is that this is used in an Acceptance Test to validate each example - see below for an example of this.\n\n---\n\nIn order to be useful, this Tester makes several assumptions about the directory structure of each example:\n\n* `main.tf` - which contains (at least some) Terraform Configuration.\n* `variables.tf` - contains all of the variables required for the example.\n\nIn addition - tests can be skipped by placing a `.skip-test` file in the directory.\n\n### Using this library\n\nGiven an examples folder which contains one or more Terraform Configurations - an Acceptance Test similar to below can be used:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/tombuildsstuff/terraform-configuration-tester/runner\"\n\t\"github.com/tombuildsstuff/terraform-configuration-tester/locator\"\n)\n\nfunc TestRunExamples(t *testing.T) {\n\tif os.Getenv(\"TF_EXAMPLE_TEST\") == \"\" {\n\t\tlog.Printf(\"`TF_EXAMPLE_TEST` is not set - skipping\")\n\t\tt.Skip()\n\t}\n\n\texamplesDirectory := \"./examples\"\n\tdirectories := locator.DiscoverExamples(examplesDirectory)\n\n\tinput := runner.TestRunInput{\n\t\tProviderVersion:  \"1.23.0\",\n\t\tProviderName:     \"azurerm\",\n\t\tTerraformVersion: \"0.11.13\",\n\t\tAvailableVariables: []runner.AvailableVariable{\n\t\t\t{\n\t\t\t\tName:     \"prefix\",\n\t\t\t\tGenerate: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:       \"location\",\n\t\t\t\tEnvKeyName: \"ARM_LOCATION\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:       \"alt_location\",\n\t\t\t\tEnvKeyName: \"ARM_LOCATION_ALT\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:       \"kubernetes_client_id\",\n\t\t\t\tEnvKeyName: \"ARM_CLIENT_ID\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:       \"kubernetes_client_secret\",\n\t\t\t\tEnvKeyName: \"ARM_CLIENT_SECRET\",\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, directoryPath := range directories {\n\t\tshortDirName := strings.Replace(directoryPath, examplesDirectory, \"\", -1)\n\t\ttestName := fmt.Sprintf(\"examples%s\", shortDirName)\n\t\tt.Run(testName, func(t *testing.T) {\n\t\t\tif err := input.Run(directoryPath); err != nil {\n\t\t\t\tt.Fatalf(\"Error running %q: %s\", shortDirName, err)\n\t\t\t}\n\t\t})\n\t}\n}\n```\n\n### Requirements\n\n- Go\n- `unzip` available on your PATH\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftombuildsstuff%2Fterraform-configuration-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftombuildsstuff%2Fterraform-configuration-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftombuildsstuff%2Fterraform-configuration-tester/lists"}