Questions tagged [terratest]

Terratest is a library that makes it easier to write automated tests for your infrastructure code.

It provides a variety of helper functions and patterns for common infrastructure testing tasks.

Please see the following for more info:

62 questions
4
votes
2 answers

List all namespaces in k8s in Go

Can anyone tell me how to list all namespaces in k8s using Go? I have been referencing this link but couldn't find anything that can list all namespaces. Link: https://pkg.go.dev/github.com/gruntwork-io/terratest/modules/k8s I don't see any…
TechGirl
  • 123
  • 1
  • 7
4
votes
1 answer

Azure pipeline - terratest - ERROR: Please run 'az login' to setup account

i'm facing a (it seams) recurent pbm in Azure Pipeline to run terratest. While resources are well created the destroyed, when I call an azure.ResourceGroupExists function (or whatever else azure.xxx function) i have the following error : --- FAIL:…
3
votes
1 answer

Terratest throws error on assertions on errors

Hello I have the following test func badTags(t *testing.T){ terraformOptions := &terraform.Options{ TerraformDir: "../bad_values", } tags := terraform.Output(t, terraformOptions, "test_required_tags") assert.Error(t, tags) } Note…
user_mda
  • 18,148
  • 27
  • 82
  • 145
3
votes
2 answers

Terratest - Use mock AWS services

I am trying to do AWS resource provisioning through terraform and planning to have a CICD pipeline with terratest unit test cases for the terraform code. My problem is I have CloudFront in my infrastructure and it takes about 20 mins for the…
2
votes
1 answer

Azure bicep testing with terratest fails

I' having this kind of issue: This is my test case to test against azure resource created or no. package test import ( "testing" "github.com/gruntwork-io/terratest/modules/azure" "github.com/stretchr/testify/assert" ) func…
Hayk Mkhitaryan
  • 388
  • 9
  • 26
2
votes
1 answer

Issue installing Terratest using Go Task's Yaml Azure pipeline - issue triggering terratest tests in sub-folder

I'm facing this issue while installing terratest by azure yaml pipeline : C:\hostedtoolcache\windows\go\1.17.1\x64\bin\go.exe install -v github.com/gruntwork-io/terratest@v0.40.6 go: downloading github.com/gruntwork-io/terratest v0.40.6 go install:…
2
votes
2 answers

How to convert the string representation of a Terraform set of strings to a slice of strings

I've a terratest where I get an output from terraform like so s := "[a b]". The terraform output's value = toset([resource.name]), it's a set of strings. Apparently fmt.Printf("%T", s) returns string. I need to iterate to perform further…
2
votes
0 answers

Using terratest with a separate backend.hcl file

I am using terratest successfully, but since switching to a remote backend, where the details are defined in a separate backend.hcl file, I am running into trouble. The situation: my main.tf starts like this: terraform { required_version = "~>…
Isaac
  • 810
  • 2
  • 13
  • 31
2
votes
0 answers

Azure Keyvault purging issues

I have a simple regression test for my Terraform infrastructure. This Terraform infrastructure consists of many resources including an Azure Keyvault. As it becomes the default for Azure Keyvault to have soft-delete enabled it will results in issues…
1
vote
1 answer

is there a way to fire multiple IP addresses using http_helper.HttpGetWithRetry in terratest?

I am testing creation of multiple AWS instances with proper subnet and rules by firing multiple IP addresses for testing AWS infrastructure using below terratest code but it is only taking first IP and hitting it 4 times. Once it gets time out…
NIRAJ BAIS
  • 41
  • 4
1
vote
0 answers

terratest receive error (variable of type *string) as type string in argument while read the cloudwatch log stream

I'm very new to golang, so I'm trying to follow: terratest_code-base while buidling my test to read the cw log stream. terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ // The path to where our Terraform…
change198
  • 1,647
  • 3
  • 21
  • 60
1
vote
1 answer

How to mock Terraform functions

I'm studying Terraform and as a test lover I'm using Terratest to test it out but, I'm not being able to mock Terraform's functions such as timestamp(). Tried some stuffs such as use the library monkey for mocking but so far, none of my approches…
lucAlucard
  • 91
  • 1
  • 2
1
vote
0 answers

Terratest (Go) specific way to apply the referenced "-out=" from the Terraform plan?

https://learn.microsoft.com/en-us/azure/developer/terraform/test-modules-using-terratest#unit-test Following along with the above link (code shown below). I am able to get a Terraform Plan with the out being specified as a certain name, but what if…
aseb
  • 274
  • 2
  • 11
1
vote
1 answer

how to filter pods against multiple label selectors with terratest?

I have a code that uses k8s module of terratest to list pods based on label selector. pods, err := k8s.ListPodsE( t, k8soptions, filter, ) where the filter is initialized with a string labelSelector like this, filter :=…
1
vote
1 answer

Build constraints exclude all Go files (macOS with Go 1.18.3)

I am new to Go and terratest. I have the following terratest package main import ( "regexp" "testing" "github.com/gruntwork-io/terratest/modules/terraform" "github.com/stretchr/testify/assert" ) func TestS3Creation(t *testing.T)…
Georgios F.
  • 417
  • 5
  • 15
1
2 3 4 5