{"id":13505783,"url":"https://github.com/bsnape/rspec-terraform","last_synced_at":"2026-02-11T23:30:32.899Z","repository":{"id":36788186,"uuid":"41094961","full_name":"bsnape/rspec-terraform","owner":"bsnape","description":"RSpec tests for your Terraform modules","archived":false,"fork":false,"pushed_at":"2015-09-10T17:41:11.000Z","size":196,"stargazers_count":92,"open_issues_count":2,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-01T03:32:57.141Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsnape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-20T12:39:46.000Z","updated_at":"2024-10-22T04:25:32.000Z","dependencies_parsed_at":"2022-07-12T04:16:29.558Z","dependency_job_id":null,"html_url":"https://github.com/bsnape/rspec-terraform","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/bsnape%2Frspec-terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsnape%2Frspec-terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsnape%2Frspec-terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsnape%2Frspec-terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsnape","download_url":"https://codeload.github.com/bsnape/rspec-terraform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"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-08-01T00:01:13.629Z","updated_at":"2026-02-11T23:30:32.846Z","avatar_url":"https://github.com/bsnape.png","language":"Ruby","funding_links":[],"categories":["Testing"],"sub_categories":["Miscellaneous","Community providers"],"readme":"# Rspec-Terraform\n\n* [Motivation](#motivation)\n  * [Looking Ahead](#looking-ahead)\n* [Usage](#usage)\n  * [Setup](#setup)\n  * [Matchers](#matchers)\n* [Contributing](#contributing)\n\n## Motivation\n\n[Terraform](https://github.com/hashicorp/terraform) is an awesome way of provisioning your infrastructure. However, like\nwith any new tool, the ecosystem surrounding it is very immature. This can cause problems when sharing code or coming up\nagainst the rough edges of a tool in active development.\n\nThe creation of `rspec-terraform` was initially intended to smooth the creation and sharing of common Terraform\nmodules. Some sort of basic testing would ensure a stable and clearly defined interface for each module.\n\n### Looking Ahead\n\nEventually, a two-tiered approach to testing would be ideal.\n \nProvisioning non-trivial infrastructure should involve the use of many Terraform modules (rather than defining\neverything yourself). Taking AWS as an example, this might include VPCs, ASGs, SGs, public/private subnets etc. Each of\nthese modules should be unit tested using `rspec-terraform` so that the interfaces they expose are well-defined.\n\nAssembling many individual modules into a cohesive platform should also - ideally - be tested. It's unclear at this\nstage how this might look and is yet to be implemented. Something similar to\n[`serverspec`](https://github.com/mizzy/serverspec) may work.\n\n## Usage\n\nAs [outlined above](#motivation), only simple unit-test type operations are currently supported.\n\n### Setup\n\nYou will need Ruby and bundler installed.\n\nCreate a `Gemfile` at the root of your Terraform module and add the following:\n\n```ruby\nsource 'https://rubygems.org'\n\ngem 'rspec-terraform'\n```\n\nThen install the gem:\n\n```bash\nbundle\n```\n\n### Matchers\n\n**N.B.** You must set the provider for each test. This is best done in the opening `describe` block:\n\n```ruby\ndescribe 'tf-aws-vpc', provider: :aws do\n  ...\nend\n```\n\nAt present, only the `AWS` provider is available.\n\nThe matchers currently implemented are:\n\n1. `require_variables`\n\n ```ruby\n it 'expects the correct variables to be provided' do\n  expected_variables = %w(vpccidr ec2nameserver region account envname domain)\n  expect('terraform plan').to require_variables expected_variables\n end\n ```\n2. `create_a_plan`\n\n ```ruby\n it 'creates a plan' do\n   expect('terraform plan -var-file example_variables/test_values.tfvars').to create_a_plan\n end\n ```\n\n## Contributing\n\n1. Fork it ( https://github.com/bsnape/rspec-terraform/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsnape%2Frspec-terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsnape%2Frspec-terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsnape%2Frspec-terraform/lists"}