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

Feature request: Support workspaces in Terraform #4440

Closed
tam116 opened this issue Nov 23, 2022 · 3 comments
Closed

Feature request: Support workspaces in Terraform #4440

tam116 opened this issue Nov 23, 2022 · 3 comments
Labels
area/terraform terraform support issue stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature Feature request

Comments

@tam116
Copy link
Contributor

tam116 commented Nov 23, 2022

Currently sam build with the terraform hook use the default workspace. I use workspaces when developing terraform modules to test changes without affecting production infrastructure.

I typically use a pattern where I use the workspace value as the key for selecting value from other map variables. A short example is below.
locals {
Environment = terraform.workspace
log_level = {
"prod" = "INFO"
"dev" = "DEBUG"
}
module "interfolio_uploader_lambda" {
source = "terraform-aws-modules/lambda/aws"
environment_variables = {
"LOG_LEVEL" : local.log_level[local.Environment]
}
... other config ...
}

Proposal

I see a couple of ways to solve this:

  1. Guess the environment by looking at the .terraform/environment file inside the root module directory. It would require that the user has already run terraform init and terraform workspace select/new <environment>
  2. Pass the value of the sam CLI --config-env flag to the terraform hook
@tam116 tam116 added stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. type/feature Feature request labels Nov 23, 2022
@moelasmar moelasmar added the area/terraform terraform support issue label Nov 23, 2022
@moelasmar
Copy link
Contributor

Thanks @tam116 for raising this feature request.
This issue is similar to the issue #4439 you raised, and the workaround I can suggest on you is also to use the Terraform environment variable https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_workspace to customize your workspace. Could you please try this workaround, and let us know if you face any issues.

We will add this request to the task we are planning to work on to allow customizing the Terraform workspace using SAM CLI arguments/options.

@moelasmar moelasmar added stage/pm-review Waiting for review by our Product Manager, please don't work on this yet and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Nov 23, 2022
@moelasmar
Copy link
Contributor

I will close this feature request as it is duplicate for issue #4439, Please keep an eye on the other issue for updates.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/terraform terraform support issue stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants