Skip to content

Support passing arbitrary extra args to underlying terraform/terragrunt command #699

@yorinasub17

Description

@yorinasub17

Currently there is no way to customize the terraform or terragrunt command you are running in each session when you go through the functions in terraform package, such as terraform.Apply or terraform.TgApplyAll if it isn't supported in terraform.Options. This is limiting if your code depends on flags like parallelism or terragrunt flags like --terragrunt-include-external-dependencies.

There should be a way that you can pass extra args to these functions that should be passed through to the underlying command.

One idea to make this work is to update the functions to take in a variadic arg as the last parameter that becomes extra args, e.g.:

terraform.Apply(t, options, "-auto-approve", "-refresh=false")

This does break down with commands like terraform.InitAndApply, where it isn't clear if the extra args should be passed to both init and apply, only init, or only apply.

Another approach is to support a new attribute on terraform.Options called ExtraCommandArgs that is a map between commands to args, e.g.:

ExtraCommandArgs: map[string][]string{
  "apply": []string{"-auto-approve", "-refresh=false"},
},

This has the advantage of being explicit on which args map to which commands, but have less control over the timing of when they are passed through.

Related: gruntwork-io/terragrunt#1418

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions