# How do you create unique namespaces from Terraform?

**URL:** <https://forums.suse.com/t/how-do-you-create-unique-namespaces-from-terraform/15749>\
**Category:** SUSE Rancher Prime\
**Created:** [November 6, 2019, 2:49pm UTC](https://forums.suse.com/t/how-do-you-create-unique-namespaces-from-terraform/15749 "2019-11-06T14:49:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntkach](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/ntkach/32/5242_2.png) [@ntkach](https://forums.suse.com/u/ntkach)\
**Post date:** [November 6, 2019, 2:49pm UTC](https://forums.suse.com/t/how-do-you-create-unique-namespaces-from-terraform/15749/1 "2019-11-06T14:49:44Z")

</div>

Has anyone managed to use terraform to create rancher2\_namespace resources which have a unique name in the cluster? I’ve got the terraform that can create a rancher2\_namespace within a given cluster+project, but the thing is that by itself that’s a problem since a namespace name has to be unique across the entire cluster. The kubernetes\_namespace resource can make a unique name, but it doesn’t have a way to attach it to a specific project (even the Default project).

We have a cluster qs that has two projects on it, Dev and QA. We’ve got a workload/service called foo that gets deployed (separately) to Dev and to QA. So, a typical “dev” deploy of foo and a “qa” deploy of foo where each probably has different settings and is meant to only be usable in that project. Obviously we can’t just make a namespace ‘foo’ in each project since it has to be unique across the cluster.

I get in this case that we could make the name something like `name = "foo-${var.env}"`. I’d like to keep the namespace independent of the exact project name though so we don’t have to keep the two in sync. Basically looking for kubernetes\_namespace (with its generate\_name setting), but a thing you can assign into a cluster and a project in Rancher 2.
