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

Add the ability to specify terraform-pipeline starting execution workspace directory #309

Closed
vincentclee opened this issue Nov 10, 2020 · 6 comments · Fixed by #398
Closed

Comments

@vincentclee
Copy link
Contributor

Currently, we have the TerraformDirectoryPlugin which allows terraform-pipeline to do this:

TerraformDirectoryPlugin.withDirectory("app1/terraform").init()
terraform <command> app1/terraform
...

What i would like terraform-pipeline to support:

TerraformStartingDirectoryPlugin.withDirectory("appQ/terraform").init()

cd appQ/terraform
terraform <command> .

This is important with monolithic pipeline repo's where the .terraform-version flat file is only read from the root of the project tree when using the TerraformDirectoryPlugin.

@kmanning
Copy link
Collaborator

Seems like a good UseCase. In thinking through this, we'll have to be careful about how other TerraformCommandPlugins interact with this new UseCase. Lots of plugins decorate the front of the command (eg: awssume/parameter-store-exec), and the command itself is treated as a single shell step. What you're looking for is a separate shell step.

@kmanning
Copy link
Collaborator

kmanning commented Nov 10, 2020

I don't know that TerraformDirectoryPlugin is so inappropriately named for this UseCase. I wonder if it could offer both behaviors with the same plugin?

TerraformDirectoryPlugin.withDirectory("app1/terraform").init()

vs

TerraformDirectoryPlugin.withStartDirectory("app1/terraform").init()

or something like

TerraformDirectoryPlugin.withDirectory("app1/terraform").withCdCommand().init()

I hate the name withCdCommand, but something that toggles one or the other behavior off and on.

@vincentclee
Copy link
Contributor Author

I like option one.
Extend TerraformDirectoryPlugin to support the withStartDirectory method

@kmanning
Copy link
Collaborator

Note: Change in terraform 0.14 and 0.15 related to subdirectories. https://www.terraform.io/docs/cli/commands/plan.html#passing-a-different-configuration-directory

@vincentclee
Copy link
Contributor Author

This is officially needed on terraform 0.15 and later.

@kdibenedetto
Copy link

Yeah, I went to use tf 1.0.1 and was hit with this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants