Answers: <p>The variable I ended up using was</p>
  <pre><code>${terraform.workspace}
  </code></pre>
  <p>You can find more information about it under &quot;Current Workspace Interpolation&quot;</p>
  <ul>
  <li><a href="https://www.terraform.io/language/state/workspaces#current-workspace-interpolation" rel="nofollow noreferrer">https://www.terraform.io/language/state/workspaces#current-workspace-interpolation</a></li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2022-08-03T17:56:28.283Z
Answers: 2022-08-03T17:56:28.283Z
Answers: Evan Carroll
Body: <p>When I run <code>terraform apply</code> in a new workspace, I get</p>
  <pre><code>openstack_networking_port_secgroup_associate_v2.network_project_k3s: Creation complete after 1s [id=4543b73b-541e-40c3-a311-5b1f553b9d58]
  ╷
  │ Error: Error trying to get network information from the Network API: More than one network found for name net_project
  │ 
  │   with openstack_compute_instance_v2.test-server,
  │   on main.tf line 137, in resource &quot;openstack_compute_instance_v2&quot; &quot;test-server&quot;:
  │  137: resource &quot;openstack_compute_instance_v2&quot; &quot;test-server&quot; {
  </code></pre>
  <p>I suppose I'm getting this because OpenStack's network names are globally unique. How can I incorporate the workspace name in the network name?</p>
  <pre><code>resource &quot;openstack_networking_network_v2&quot; &quot;net_project&quot; {
    name           = &quot;net_project_${WORKSPACE}&quot;
    admin_state_up = &quot;true&quot;
  }
  </code></pre>
  
Tags: <terraform><openstack>
Title: Variable for Terraform Workspace name?
UserDisplayName: Evan Carroll
ThreadText: # Variable for Terraform Workspace name?
  
  (Asked by: username_0 on 2022-08-03)
  
  When I run `terraform apply` in a new workspace, I get
  
  ```
  openstack_networking_port_secgroup_associate_v2.network_project_k3s: Creation complete after 1s [id=4543b73b-541e-40c3-a311-5b1f553b9d58]
  ╷
  │ Error: Error trying to get network information from the Network API: More than one network found for name net_project
  │ 
  │   with openstack_compute_instance_v2.test-server,
  │   on main.tf line 137, in resource "openstack_compute_instance_v2" "test-server":
  │  137: resource "openstack_compute_instance_v2" "test-server" {
  
  ```
  
  I suppose I'm getting this because OpenStack's network names are globally unique. How can I incorporate the workspace name in the network name?
  
  ```
  resource "openstack_networking_network_v2" "net_project" {
    name           = "net_project_${WORKSPACE}"
    admin_state_up = "true"
  }
  
  ```
  
  **Tags:** terraform, openstack
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-08-03. Score: 2 | Accepted answer
  
  The variable I ended up using was
  
  ```
  ${terraform.workspace}
  
  ```
  
  You can find more information about it under "Current Workspace Interpolation"
  
  * <https://www.terraform.io/language/state/workspaces#current-workspace-interpolation>
  
  
  ---
  
  