0

I have a terragrunt script which is working fine after running terragrunt apply-all command line but same thing i am not able to do/invoke form Go script. using TgApplyAll function

Below is my Go script Working terragrunt script is kept in D:\vertica-terragrunt-US-286094-Modules\with-infra location and it is working fine with manual terragrunt apply-all command but from Go script i am getting error

enter image description here

Getting error as below

''' github.com/gruntwork-io/terratest/modules/terraform.TgInvalidBinary.Error(...) c:/go/pkg/mod/github.com/gruntwork-io/terratest@v0.30.15/modules/terraform/errors.go:12

Detailed error func (err TgInvalidBinary) Error() string { return fmt.Sprintf("terragrunt must be set as TerraformBinary to use this function. [ TerraformBinary : %s ]", err) } '''

I used same code which i used to call terraform code from terratest Go script for calling terragrunt code also but it is not working

Can anyone help me / direct me to location like how to invoke working terragrunt code from terratest Go script ?

kostix
  • 51,517
  • 14
  • 93
  • 176
  • Please copy-and-paste the text currently displayed in the image and remove it. [More on formatting posts on SO](https://stackoverflow.com/editing-help). – kostix Oct 29 '20 at 09:46
  • On a side note, have you really "set terragrunt as TerraformBinary to use that function" as the error message suggests? – kostix Oct 29 '20 at 09:48
  • @kostix I am not getting how to set "set terragrunt as TerraformBinary" example code is not available for that anywhere ... So struggling hard... – Sanjay Gayakwad Oct 29 '20 at 09:56
  • A couple notes: 1. There's no such thing as a "go [script](https://en.wikipedia.org/wiki/Scripting_language)". 2. [Don't paste images of code](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). – Jonathan Hall Oct 29 '20 at 11:07
  • [This one](https://www.bountysource.com/issues/88422750-terragrunt-fails-to-copy-files-if-an-ssh-agent-is-running-on-my-system) looks like what you need. Also [this](https://groups.google.com/g/golang-nuts/c/so01nDZLnIQ/m/h50TyvKLAwAJ). – kostix Oct 29 '20 at 13:49

1 Answers1

1

Hello You need to set TerraformBinary to terragrunt in the terraform options like this :

terraformOptions := &terraform.Options{

    TerraformDir: "D:/vertica-terragrunt-US-286094-Modules/with-infra",
    TerraformBinary : "terragrunt",
}

because the default binary is terraform and TgInvalidBinary occurs when a terragrunt function is called and the TerraformBinary is set to a value other than terragrunt.

here's a ref

https://godoc.org/github.com/gruntwork-io/terratest/modules/terraform#TgInvalidBinary

https://github.com/gruntwork-io/terratest/blob/master/modules/terraform/cmd.go

Montassar Bouajina
  • 1,482
  • 1
  • 8
  • 20