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

fix: Missing VCS property response in workspace API endpoint #1640

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

alfespa17
Copy link
Member

@alfespa17 alfespa17 commented Dec 19, 2024

Running an apply using the CLI driven workflow in a VCS workspaces

Fix #1639

Example

Using the following VCS repo with a github connection and running the apply
image

user@pop-os:~/git/simple-terraform$ terraform init

Initializing Terraform Cloud...
Initializing modules...
- time_module in module

Initializing provider plugins...
- Finding latest version of hashicorp/null...
- Finding latest version of hashicorp/time...
- Finding latest version of hashicorp/random...
- Installing hashicorp/null v3.2.3...
- Installed hashicorp/null v3.2.3 (signed by HashiCorp)
- Installing hashicorp/time v0.12.1...
- Installed hashicorp/time v0.12.1 (signed by HashiCorp)
- Installing hashicorp/random v3.6.3...
- Installed hashicorp/random v3.6.3 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform Cloud has been successfully initialized!

You may now begin working with Terraform Cloud. Try running "terraform plan" to
see any changes that are required for your infrastructure.

If you ever set or change modules or Terraform Settings, run "terraform init"
again to reinitialize your working directory.
user@pop-os:~/git/simple-terraform$ terraform apply
╷
│ Error: Apply not allowed for workspaces with a VCS connection
│ 
│ A workspace that is connected to a VCS requires the VCS-driven workflow to
│ ensure that the VCS remains the single source of truth.

@alfespa17 alfespa17 merged commit e90ad9e into main Dec 19, 2024
5 checks passed
@alfespa17 alfespa17 deleted the fix/missing-vcs-property branch December 19, 2024 22:33
@BenjaminDecreusefond
Copy link
Contributor

BenjaminDecreusefond commented Jan 28, 2025

Hi @alfespa17 !

This is kind of a breaking change for us since all our workspaces are in VCS including our staging environment and we are now unable to apply from CLI. Would it be possible to add a workaround for this ? For us recreating our 100+ workspaces is not really a solution :/

We are using VCS because we need to use that approach to compute our daily drift as the CLI-driven workspace does not have a connection with github so it is unable to determine drift between our master branch and the current state. This "bug" was kind of useful and we thought that was an intended behavior.

I think the terrakube implementation of CLI workspace and VCS workspace is a bit odd. In TFE both VCS and CLI interact with github and are able to read it, the main differences is that you cannot apply from CLI with a VCS workspace in TFE however, you can use the TFE CLI workspace which include a connection to github to apply from CLI. Computing drift from TFE CLI workspace is efficient since it is connected to github it is able to 'see' master branch.

For Terrakube it seems that the approach is a bit different and CLI workspace are not connected to github which make them difficult to use when computing drift detection as they seem to only compute drift between the tfstate and the cloud provider.

WDYT ?

stanleyz pushed a commit to stanleyz/terrakube that referenced this pull request Mar 11, 2025
…er#1640)

* fix: Missing VCS property response in workspace API endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VCS-Linked Workspaces Don't Block CLI-Driven Applies
2 participants