terratest icon indicating copy to clipboard operation
terratest copied to clipboard

TgPlanAllExitCode and TgApplyAll is work for current module , not plan and apply for nested dependency module

Open DiptiPrakash opened this issue 6 years ago • 5 comments

TgPlanAllExitCode and TgApplyAll is not plan/apply for parent module . i.e if i am running test on VCN module and compartment i put as mock_output . It is not planning and apply for compartment module . It is only plan for current directory means VCN .

Is there a way to fix this ?

The --non-interactive flag is set. To avoid accidentally affecting external dependencies with an xxx-all command, will not run this command against module /Users/dmaharan/Ddrive/demoRepo/terratestDevelop/cxu-tf-infra/dev/global/app/compartment, which is a dependency of module /Users/dmaharan/Ddrive/demoRepo/terratestDevelop/cxu-tf-infra/dev/iad/fabric/app/network/vcn. How to make here external dependency to true How we can add "terragrunt-include-external-dependencies" to TgApplyAll and TgdestroyAll

@yorinasub17 is there any solution for this ?

DiptiPrakash avatar Apr 22 '20 15:04 DiptiPrakash

Ideally you can run plan-all and apply-all on the root folder so that includes all the dependencies.

Otherwise, we need an enhancement to the terraform.Options struct to support the ability to pass in arbitrary extra args to the command. We are unlikely to get to this anytime soon, so if anyone in the community wants to contribute a PR that would be much appreciated!

yorinasub17 avatar May 21 '20 13:05 yorinasub17

@DiptiPrakash

Could please pass me snippet of code which helps me to set --terragrunt-include-external-dependencies flag to true

I am getting error due to that https://github.com/gruntwork-io/terragrunt/issues/1417

pandu-bhojaraj-mf avatar Nov 05 '20 07:11 pandu-bhojaraj-mf

hi @pandu-bhojaraj-mf, please try the following:

options := &Options{
	TerraformDir:    testFolder,
	TerraformBinary: "terragrunt",
	EnvVars: map[string]string{
		"TF_CLI_ARGS": "--terragrunt-include-external-dependencies",
	},
}
terraform.TgApplyAll(t, options)

Feel free to tweak it based on your use case. If Terragrunt doesn't parse TF_CLI_ARGS, then you could try to invoke a different method directly: RunTerraformCommandE(t, options, FormatArgs(options, "apply-all", "-input=false", "-lock=false", "-auto-approve", "--terragrunt-non-interactive", "--terragrunt-include-external-dependencies")...).

robmorgan avatar Nov 05 '20 08:11 robmorgan

Hi @robmorgan

Below code is not working

options := &Options{ TerraformDir: testFolder, TerraformBinary: "terragrunt", EnvVars: map[string]string{ "TF_CLI_ARGS": "--terragrunt-include-external-dependencies", }, } terraform.TgApplyAll(t, options)

pandu-bhojaraj-mf avatar Nov 05 '20 09:11 pandu-bhojaraj-mf

Both approached dint work

pandu-bhojaraj-mf avatar Nov 05 '20 09:11 pandu-bhojaraj-mf