Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Terratest] terraform.InitAndValidate and ~.InitAndValidateE method occure Error #9

Open
unchaptered opened this issue Feb 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@unchaptered
Copy link
Owner

unchaptered commented Feb 10, 2024

Codes & Commit Id

PR : #8
Commit : 2fc8173

  • Terraform Codes
# main.tf
data "aws_acm_certificate" "datasource" {
  domain   = var.domain
  statuses = var.status # ["ISSUED"]
}

# variables.tf
variable "domain" {
  type = string
}
variable "status" {
  type    = list(string)
  default = ["ISSUED"]
}

# outputs.tf
output "arn" {
  value = data.aws_acm_certificate.datasource.arn
}
  • Terratest Codes
package main

import (
	"testing"

	"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestTerraformDataAwsAmi(t *testing.T) {
	t.Parallel()

	options := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
		TerraformDir: "../../../../data/aws/acm",
		Vars: map[string]interface{}{
			"domain": "example.com",
			"status": []string{"ISSUED"},
		},
		EnvVars: map[string]string{
			"AWS_DEFAULT_REGION": "us-east-1",
		},
	})

	defer terraform.Destroy(t, options)

	terraform.InitAndValidateE(t, options)
}

Expected Result

Success

Real Result

Failed

│ Error: Failed to parse command-line flags
│
│ flag provided but not defined: -var
╵
╷
│ Error: Too many command line arguments
│
│ Expected at most one positional argument.

Epxected Issue

In terraform, terraform validate don't required -var or -var-files.

But in terratest, terraform.InitAndValidate or terraform.InitAndValidateE needs vars.

But when I use vars: map[string]interface{} with terratest, terratest typed terraform validate -var ....


But, Terraform don't supports -v option in validate.

So, this implementation of terraform.InitAndValidate(E) can't executeed at any way.

@unchaptered unchaptered added the bug Something isn't working label Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant