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

Expose PARALLELISM parameter as environment variable #27765

Closed
spuder opened this issue Feb 12, 2021 · 3 comments
Closed

Expose PARALLELISM parameter as environment variable #27765

spuder opened this issue Feb 12, 2021 · 3 comments
Labels
enhancement new new issue not yet triaged

Comments

@spuder
Copy link
Contributor

spuder commented Feb 12, 2021

Feature Request

Terraform should support environment variables like TF_parallelism to supplement command line arguments.

Current mechanism

terraform apply -parallelism=1

Purposed mechanism

export TF_parallelism=1
terraform apply

Terraform currently supports a variety of parameters and environment variables.

Parameters

https://www.terraform.io/docs/cli/commands/apply.html

-backup=path
-compact-warnings
-lock=true
-lock-timeout=0s
....
-parallelism=n
....

Environment Variables

https://www.terraform.io/docs/cli/config/environment-variables.html
https://github.com/hashicorp/terraform/blob/4d65cbdedf425b0a5a90737100b265e207002c85/website/docs/cli/config/environment-variables.html.md

TF_LOG
TF_LOG_PATH
TF_INPUT
TF_VAR_name
TF_CLI_ARGS
TF_CLI_ARGS_name
TF_DATA_DIR
TF_WORKSPACE
TF_IN_AUTOMATION
TF_REGISTRY_CLIENT_TIMEOUT
TF_CLI_CONFIG_FILE
TF_IGNORE

Justification

Some plugins for terraform require parallelism be reduced down from the default of 10 to 1. (Specifically jfrog/artifactory).

It is currently not possible to set the parallelism to a value other than 10 when using an automated pipeline (such as with gitlabs native terraform support)

Possible workarounds

  1. Fork the official gitlab terraform docker container and change parallelism

Resources

atlassian/terraform-provider-artifactory#75 (comment)

https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html

https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml

https://gitlab.com/gitlab-org/terraform-images/-/blob/master/Dockerfile

@spuder spuder added enhancement new new issue not yet triaged labels Feb 12, 2021
@apparentlymart
Copy link
Member

Hi @spuder! Thanks for sharing this use-case.

The environment variables of the form TF_CLI_ARGS_name are designed to allow you to set any command line option using an environment variable, so I think what you want to achieve here is already possible with an invocation like this:

export TF_CLI_ARGS_apply="-parallelism=1"
terraform apply

Could you give that a try at let me know if it meets your need? Thanks!

@apparentlymart apparentlymart added the waiting-response An issue/pull request is waiting for a response from the community label Feb 13, 2021
@spuder
Copy link
Contributor Author

spuder commented Feb 14, 2021

Thank you for the quick reply. I overlooked TF_CLI_ARGS_apply which does appear to do precisely what I need. Thank you.

@spuder spuder closed this as completed Feb 14, 2021
@ghost ghost removed waiting-response An issue/pull request is waiting for a response from the community labels Feb 14, 2021
@ghost
Copy link

ghost commented Mar 17, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants