Skip to content

Terraform stacks create returns exit code 0 on creating a stack by the same name as an existing stack #37698

@quixoticmonk

Description

@quixoticmonk

Terraform Version

terraform --version
Terraform v1.13.0
on darwin_arm64

Terraform Configuration Files

No specific configuration. The issue is on the terraform stacks subcommand.

❯ terraform stacks  create  -organization-name manu-project-name "Default Project" -stack-name "manuchn-stacks-2025"
Creating stack...
Stack: Created stack 'manuchn-stacks-2025'

❯ terraform stacks  create  -organization-name manu -project-name "Default Project" -stack-name "manuchn-stacks-2025"
Creating stack...
Stack: Failed creating stack 'manuchn-stacks-2025'

Error: invalid attribute

Validation failed: Name has already been taken
Stack: Created stack 'manuchn-stacks-2025'

❯ echo $?
0

Debug Output

TF_LOG=TRACE terraform stacks  create  -organization-name manu -project-name "Default Project" -stack-name "manuchn-stacks-2025"
2025-09-29T23:45:50.286-0400 [INFO]  Terraform version: 1.13.0
2025-09-29T23:45:50.286-0400 [DEBUG] using github.com/hashicorp/go-tfe v1.74.1
2025-09-29T23:45:50.286-0400 [DEBUG] using github.com/hashicorp/hcl/v2 v2.24.0
2025-09-29T23:45:50.286-0400 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-09-29T23:45:50.286-0400 [DEBUG] using github.com/zclconf/go-cty v1.16.3
2025-09-29T23:45:50.286-0400 [INFO]  Go runtime version: go1.24.5
2025-09-29T23:45:50.286-0400 [INFO]  CLI args: []string{"/opt/homebrew/Cellar/tfenv/3.0.0/versions/1.13.0/terraform", "stacks", "create", "-organization-name", "manu", "-project-name", "Default Project", "-stack-name", "manuchn-stacks-2025"}
2025-09-29T23:45:50.286-0400 [TRACE] Stdout is a terminal of width 161
2025-09-29T23:45:50.286-0400 [TRACE] Stderr is a terminal of width 161
2025-09-29T23:45:50.286-0400 [TRACE] Stdin is a terminal
2025-09-29T23:45:50.286-0400 [DEBUG] Attempting to open CLI config file: /Users/manuchn/.terraformrc
2025-09-29T23:45:50.286-0400 [INFO]  Loading CLI configuration from /Users/manuchn/.terraformrc
2025-09-29T23:45:50.286-0400 [INFO]  Loading CLI configuration from /Users/manuchn/.terraform.d/credentials.tfrc.json
2025-09-29T23:45:50.287-0400 [DEBUG] checking for credentials in "/Users/manuchn/.terraform.d/plugins"
2025-09-29T23:45:50.287-0400 [DEBUG] Explicit provider installation configuration is set
2025-09-29T23:45:50.287-0400 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes []
2025-09-29T23:45:50.287-0400 [INFO]  CLI command args: []string{"stacks", "create", "-organization-name", "manu", "-project-name", "Default Project", "-stack-name", "manuchn-stacks-2025"}
2025-09-29T23:45:50.287-0400 [TRACE] stacksplugin hostname not set, falling back to "app.terraform.io"
2025-09-29T23:45:50.287-0400 [DEBUG] Service discovery for app.terraform.io at https://app.terraform.io/.well-known/terraform.json
2025-09-29T23:45:50.492-0400 [TRACE] No stacksplugin cache path store at '.terraform/.stackspluginpath`, using default '/Users/manuchn/.terraform.d/stacksplugin'
2025-09-29T23:45:50.492-0400 [TRACE] stacksplugin cache directory found at "/Users/manuchn/.terraform.d/stacksplugin"
2025-09-29T23:45:50.492-0400 [TRACE] stacksplugin manifest cache found for host "app.terraform.io"
2025-09-29T23:45:50.493-0400 [DEBUG] performing request: method=GET url=https://app.terraform.io/stacksplugin.v1/manifest.json
2025-09-29T23:45:50.493-0400 [TRACE] HTTP client GET request to https://app.terraform.io/stacksplugin.v1/manifest.json
2025-09-29T23:45:50.703-0400 [TRACE] wrote stacksplugin manifest cache to "/Users/manuchn/.terraform.d/stacksplugin/app.terraform.io/manifest.json"
2025-09-29T23:45:50.703-0400 [TRACE] checking for stacksplugin archive for darwin_arm64. Supported architectures: [darwin_amd64 darwin_arm64 freebsd_386 freebsd_amd64 freebsd_amd linux_386 linux_amd64 linux_arm linux_arm64 netbsd_386 netbsd_amd64 netbsd_arm openbsd_386 openbsd_amd64 openbsd_arm solaris_amd64 windows_386 windows_amd64]
2025-09-29T23:45:50.704-0400 [TRACE] plugin "1.1.0" binary located at "/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks" (resolved from cache)
2025-09-29T23:45:50.704-0400 [DEBUG] created stacks logger: level=trace
2025-09-29T23:45:50.705-0400 [DEBUG] stacks: starting plugin: path=/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks args=["/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks"]
2025-09-29T23:45:50.710-0400 [DEBUG] stacks: plugin started: path=/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks pid=65766
2025-09-29T23:45:50.710-0400 [DEBUG] stacks: waiting for RPC address: plugin=/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks
2025-09-29T23:45:50.735-0400 [DEBUG] stacks: using plugin: version=1
2025-09-29T23:45:50.735-0400 [DEBUG] stacks.tfstacks: plugin address: address=/var/folders/xb/b1nrh4n54pv07flx5flrf1l40000gq/T/plugin656580597 network=unix timestamp=2025-09-29T23:45:50.735-0400
2025-09-29T23:45:50.737-0400 [TRACE] stacks.stdio: waiting for stdio data
2025-09-29T23:45:50.739-0400 [TRACE] stacks.tfstacks: Plugin Execute with args [create -organization-name manu -project-name Default Project -stack-name manuchn-stacks-2025]: timestamp=2025-09-29T23:45:50.739-0400
2025-09-29T23:45:50.965-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "Creating stack...": timestamp=2025-09-29T23:45:50.965-0400
2025-09-29T23:45:50.965-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "\n": timestamp=2025-09-29T23:45:50.965-0400
Creating stack...
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "\x1b[31mStack: \x1b[1mFailed creating stack 'manuchn-stacks-2025'\x1b[0m\n": timestamp=2025-09-29T23:45:51.301-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "\n": timestamp=2025-09-29T23:45:51.301-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stderr: "Error: invalid attribute\n\nValidation failed: Name has already been taken": timestamp=2025-09-29T23:45:51.301-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stderr: "\n": timestamp=2025-09-29T23:45:51.301-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "\x1b[1mStack: \x1b[1mCreated stack 'manuchn-stacks-2025'\x1b[0m": timestamp=2025-09-29T23:45:51.302-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: sending command response to stdout: "\n": timestamp=2025-09-29T23:45:51.302-0400
2025-09-29T23:45:51.302-0400 [TRACE] stacks.tfstacks: Plugin Execute sending ExitCode 0: timestamp=2025-09-29T23:45:51.302-0400
2025-09-29T23:45:51.302-0400 [INFO]  stacks.tfstacks: Context cancelled, initiating graceful shutdown: timestamp=2025-09-29T23:45:51.302-0400
Stack: Failed creating stack 'manuchn-stacks-2025'

Error: invalid attribute

Validation failed: Name has already been taken
Stack: Created stack 'manuchn-stacks-2025'
2025-09-29T23:45:51.302-0400 [TRACE] received exit code: 0
2025-09-29T23:45:51.307-0400 [DEBUG] stacks.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-09-29T23:45:51.310-0400 [INFO]  stacks: plugin process exited: plugin=/Users/manuchn/.terraform.d/stacksplugin/bin/darwin_arm64/tfstacks id=65766
2025-09-29T23:45:51.310-0400 [DEBUG] stacks: plugin exite

Expected Behavior

The second run of the command should fail as the name is already present in the current organization

Actual Behavior

The command fails per logs, but returns 0 as an exit code

Steps to Reproduce

  1. terraform stacks create -organization-name <your_org> -project-name "Default Project" -stack-name "manuchn-stacks-2025"
  2. terraform stacks create -organization-name <your_org> -project-name "Default Project" -stack-name "manuchn-stacks-2025"

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclicloudRelated to Terraform Cloud's integration with Terraformnewnew issue not yet triagedstacksRelating to the Stacks features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions