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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace name isn't detected for Terraform Cloud in subfolders #3252

Closed
mprokopov opened this issue Mar 21, 2023 · 1 comment 路 Fixed by #4363
Closed

Workspace name isn't detected for Terraform Cloud in subfolders #3252

mprokopov opened this issue Mar 21, 2023 · 1 comment 路 Fixed by #4363
Assignees
Labels
bug Something isn't working
Milestone

Comments

@mprokopov
Copy link

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

Workspace name isn't detected for Terraform Cloud in subfolders.

It works only for the root of the repository.

Reproduction Steps

  1. Setup Terraform Cloud account and sync the state of the module in arbitrary subfolder

Example: example1/terraform.tf

terraform {
  required_version = ">=1.2"

  cloud {
    organization = "example-org"
    workspaces {
      name = "example"
    }
  }
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 3"
    }
  }
}
  1. Push the module example1 to the GitHub repository

  2. Atlantis will use default workspace and doesn't detect name example name for the workspace from the example1/terraform.tf.

running "/usr/local/bin/terraform workspace new default" in "/home/atlantis/.atlantis/repos/xxxxxx/atlantis-example/9/default/example1": exit status 1: default workspace not supported
You can create a new workspace with the "workspace new" command.

Logs

2023-03-20 17:38:21 | {"level":"debug","ts":"2023-03-20T16:38:21.101Z","caller":"events/project_finder.go:106","msg":"no Terraform Cloud workspace explicitly configured in Terraform codes. Use default workspace (\"default\")","json":{"repo":"xxxx/atlantis-example","pull":"9"}}

Additional Context

Related to the implementation #2432, it works only for the root of the repository, but not for the subfolders.

Here is a line with the issue

pWorkspace, err := p.ProjectFinder.DetermineWorkspaceFromHCL(ctx.Log, repoDir)

repoDir is always the same for all projects.

@mprokopov mprokopov added the bug Something isn't working label Mar 21, 2023
mprokopov added a commit to mprokopov/atlantis that referenced this issue Mar 21, 2023
* Bugfix: Workspace detection for Terraform Cloud doesn't work for subfolders

DetermineWorkspaceFromHCL supplied repoDir parameter therefore it
doesn't work for subfolders.
@sudermanjr
Copy link

Stated workaround in the linked PR does work - setting the workspace name explicitly in the atlantis.yaml file.

@GenPage GenPage added this to the v0.28.0 milestone Mar 5, 2024
@GenPage GenPage self-assigned this Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants