Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
chore: add note re cloud block to allow CLI apply
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Sep 14, 2023
1 parent cb025ed commit 4f03544
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Now we'll write some terraform configuration. Configure the terraform backend an
```bash
cat > main.tf <<EOF
terraform {
backend "remote" {
cloud {
hostname = "localhost:8080"
organization = "default"
Expand Down
32 changes: 31 additions & 1 deletion internal/hcl_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestRewriteHCL(t *testing.T) {
func TestRewriteHCL_RemoveRemoteBackend(t *testing.T) {
got := `
terraform {
backend "remote" {
Expand Down Expand Up @@ -38,3 +38,33 @@ terraform {
require.NoError(t, err)
assert.Equal(t, want, string(f))
}

func TestRewriteHCL_RemoveCloudBlock(t *testing.T) {
got := `
terraform {
cloud {
hostname = "app.terraform.io"
organization = "automatize"
workspaces {
prefix = "etok-example-"
}
}
}
`
want := `
terraform {
}
`

modulePath := t.TempDir()
cfgFile := filepath.Join(modulePath, "config.tf")
require.NoError(t, os.WriteFile(cfgFile, []byte(got), 0o644))

err := RewriteHCL(modulePath, RemoveBackendBlock)
assert.NoError(t, err)

f, err := os.ReadFile(cfgFile)
require.NoError(t, err)
assert.Equal(t, want, string(f))
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<div class="form-checkbox">
<input type="checkbox" name="allow_cli_apply" id="allow-cli-apply" {{ checked .AllowCLIApply }}/>
<label for="allow-cli-apply">Allow apply from the CLI</label>
<span>Allow running <span class="bg-gray-200">terraform apply</span> from the command line. By default once a workspace is connected to a VCS repository it is only possible to trigger applies from VCS changes.</span>
<span>Allow running <span class="bg-gray-200">terraform apply</span> from the command line. By default once a workspace is connected to a VCS repository it is only possible to trigger applies from VCS changes. Note: this only works with the <a class="underline" href="https://developer.hashicorp.com/terraform/cli/cloud/settings#the-cloud-block">cloud block</a>; it does not work with the <a class="underline" href="https://developer.hashicorp.com/terraform/language/settings/backends/remote">remote backend</a>.</span>
</div>
{{ end }}

Expand Down
2 changes: 1 addition & 1 deletion internal/integration/lock_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestLockFile(t *testing.T) {
root := t.TempDir()
config := []byte(fmt.Sprintf(`
terraform {
backend "remote" {
cloud {
hostname = "%s"
organization = "%s"
Expand Down

0 comments on commit 4f03544

Please sign in to comment.