@@ -110,19 +110,31 @@ import, create, update, and delete Namespaces with Terraform.
110110You must use an Identity with Temporal Cloud Namespace management privileges. This includes the Account Owner, Global
111111Admin, or Developer Account Role.
112112
113+ For more detailed examples on how to manage Namespaces via Terraform, check the [ Terraform Registry documention for Namspaces] ( https://registry.terraform.io/providers/temporalio/temporalcloud/latest/docs/resources/namespace ) .
114+
113115** How do I create a Namespace with Terraform?**
114116
1151171 . Create a Terraform configuration file (` terraform.tf ` ) to define a Namespace.
116118
117- ``` yml
118- terraform { required_providers { temporalcloud = { source = "temporalio/temporalcloud" } } }
119+ ``` hcl
120+ terraform {
121+ required_providers {
122+ temporalcloud = {
123+ source = "temporalio/temporalcloud"
124+ }
125+ }
126+ }
119127
120128 provider "temporalcloud" {
121129
122130 }
123131
124- resource "temporalcloud_namespace" "namespace" { name = "terraform" regions =
125- ["aws-us-east-1"] accepted_client_ca = base64encode(file("ca.pem")) retention_days = 14 }
132+ resource "temporalcloud_namespace" "namespace" {
133+ name = "terraform"
134+ regions = ["aws-us-east-1"]
135+ accepted_client_ca = base64encode(file("ca.pem"))
136+ retention_days = 14
137+ }
126138 ```
127139
128140 In this example, you create a Temporal Cloud Namespace named ` terraform ` , specifying the AWS region ` aws-us-east-1 ` ,
@@ -187,15 +199,26 @@ apply the change without any additional steps required by you.
187199
1882001 . Set the retention period to 30 days.
189201
190- ``` yml
191- terraform { required_providers { temporalcloud = { source = "temporalio/temporalcloud" version = ">= 0.0.6" } } }
202+ ``` hcl
203+ terraform {
204+ required_providers {
205+ temporalcloud = {
206+ source = "temporalio/temporalcloud"
207+ version = ">= 0.0.6"
208+ }
209+ }
210+ }
192211
193212 provider "temporalcloud" {
194213
195214 }
196215
197- resource "temporalcloud_namespace" "namespace" { name = "terraform" regions =
198- ["aws-us-east-1"] accepted_client_ca = base64encode(file("ca.pem")) retention_days = 30 }
216+ resource "temporalcloud_namespace" "namespace" {
217+ name = "terraform"
218+ regions = ["aws-us-east-1"]
219+ accepted_client_ca = base64encode(file("ca.pem"))
220+ retention_days = 30
221+ }
199222 ```
200223
2012241 . Apply your configuration. When prompted, answer yes to continue:
@@ -538,24 +561,48 @@ Cautions about Temporal User management:
538561
539562:::
540563
564+ For more detailed examples on how to manage Namespaces via Terraform, check the Terraform Registry documention for [ provisioning a Temporal Cloud user] ( https://registry.terraform.io/providers/temporalio/temporalcloud/latest/docs/resources/user ) .
565+
541566** How do I create a Temporal Cloud User with Terraform?**
542567
5435681 . Add a Terraform User resources configuration to your Terraform file.
544569
545- ``` yml
546- terraform { required_providers { temporalcloud = { source = "temporalio/temporalcloud" } } }
570+ ``` hcl
571+ terraform {
572+ required_providers {
573+ temporalcloud = {
574+ source = "temporalio/temporalcloud"
575+ }
576+ }
577+ }
547578
548579 provider "temporalcloud" {
549580
550581 }
551582
552- resource "temporalcloud_namespace" "namespace" { name = "terraform" regions =
553- ["aws-us-east-1"] accepted_client_ca = base64encode(file("ca.pem")) retention_days = 14 }
583+ resource "temporalcloud_namespace" "namespace" {
584+ name = "terraform"
585+ regions = ["aws-us-east-1"]
586+ accepted_client_ca = base64encode(file("ca.pem"))
587+ retention_days = 14
588+ }
589+
590+ # Global admins automatically have access to all namespaces.
591+ resource "temporalcloud_user" "global_admin" {
592+ 593+ account_access = "Admin"
594+ }
554595
555- resource "temporalcloud_user" "global_admin" { email = <admin-email> account_access = "Admin" }
596+ # Developers can be granted explicit namespace permissions.
597+ resource "temporalcloud_user" "namespace_admin" {
598+ 599+ account_access = "Developer"
556600
557- resource "temporalcloud_user" "namespace_admin" { email = <developer-email> account_access = "Developer"
558- namespace_accesses = [ { namespace_id = temporalcloud_namespace.namespace.id permission = "Write" } ] }
601+ namespace_accesses = [{
602+ namespace_id = temporalcloud_namespace.namespace.id
603+ permission = "Write"
604+ }]
605+ }
559606 ```
560607
561608 Replace the email and domain values with your Temporal Cloud User email and domain.
@@ -584,26 +631,42 @@ To delete a User with Terraform, remove the Terraform User resources configurati
584631
5856321 . Remove the Terraform User resources configuration from your Terraform file.
586633
587- ``` yml
588- terraform { required_providers { temporalcloud = { source = "temporalio/temporalcloud" version = ">= 0.0.6" } } }
634+ ``` hcl
635+ terraform {
636+ required_providers {
637+ temporalcloud = {
638+ source = "temporalio/temporalcloud"
639+ version = ">= 0.0.6"
640+ }
641+ }
642+ }
589643
590644 provider "temporalcloud" {
591645
592646 }
593647
594- resource "temporalcloud_namespace" "namespace" { name = "terraform" regions =
595- ["aws-us-east-1"] accepted_client_ca = base64encode(file("ca.pem")) retention_days = 14 }
648+ resource "temporalcloud_namespace" "namespace" {
649+ name = "terraform"
650+ regions = ["aws-us-east-1"]
651+ accepted_client_ca = base64encode(file("ca.pem"))
652+ retention_days = 14
653+ }
596654
597- resource "temporalcloud_user" "global_admin" { email = <admin-email> account_access = "Admin" }
655+ # This user will be deleted after running `terraform apply`
656+ resource "temporalcloud_user" "global_admin" {
657+ 658+ account_access = "Admin"
659+ }
660+ # The following user resource has been removed (or commented out),
661+ # so Terraform will delete it.
598662 # resource "temporalcloud_user" "namespace_admin" {
599- # email = < developer-email>
663+ # email = " developer@example.com"
600664 # account_access = "Developer"
601- # namespace_accesses = [
602- # {
603- # namespace_id = temporalcloud_namespace.namespace.id
604- # permission = "Write"
605- # }
606- # ]
665+ #
666+ # namespace_accesses = [{
667+ # namespace_id = temporalcloud_namespace.namespace.id
668+ # permission = "Write"
669+ # }]
607670 # }
608671 ```
609672
@@ -629,13 +692,11 @@ using the `terraform import` command.
629692 resource "temporalcloud_user" "user" { }
630693 ```
631694
632- ````
633- 1. Run the `terraform import` command and pass in the User ID
634- Your User ID is available using the Temporal Cloud CLI `tcld u l` command.
695+ 1 . Run the ` terraform import ` command and pass in the User ID. Your User ID is available using the Temporal Cloud CLI ` tcld u l ` command.
635696
636697 ``` bash
637698 terraform import temporalcloud_user.user 72360058153949edb2f1d47019c1e85f
638- ` ```
699+ ```
639700
640701The User is now a part of the Terraform state and all changes to the User should be managed by Terraform.
641702
@@ -671,21 +732,34 @@ process of securely accessing the API Key Token in the Create section of this gu
671732
672733** How do I create a Temporal Cloud API Key with Terraform?**
673734
735+ From the example in the [ Terraform Registry] ( https://registry.terraform.io/providers/temporalio/temporalcloud/latest/docs/resources/apikey ) :
6747361 . Add a Terraform API Key resources configuration to your Terraform file.
675737
676- ``` yml
677- terraform { required_providers { temporalcloud = { source = "temporalio/temporalcloud" } } }
738+ ``` hcl
739+ terraform {
740+ required_providers {
741+ temporalcloud = {
742+ source = "temporalio/temporalcloud"
743+ }
744+ }
745+ }
678746
679747 provider "temporalcloud" {
680748
681749 }
682750
683- resource "temporalcloud_service_account" "global_service_account" { name = "admin" account_access = "Admin"
751+ resource "temporalcloud_service_account" "global_service_account" {
752+ name = "admin"
753+ account_access = "Admin"
684754 }
685755
686- resource "temporalcloud_apikey" "global_apikey" { display_name = "admin" owner_type = "service-account"
687- owner_id = temporalcloud_service_account.global_service_account.id expiry_time = "2024-11-01T00:00:00Z"
688- disabled = false }
756+ resource "temporalcloud_apikey" "global_apikey" {
757+ display_name = "admin"
758+ owner_type = "service-account"
759+ owner_id = temporalcloud_service_account.global_service_account.id
760+ expiry_time = "2024-11-01T00:00:00Z"
761+ disabled = false
762+ }
689763 ```
690764
691765 Make sure to:
@@ -695,8 +769,11 @@ process of securely accessing the API Key Token in the Create section of this gu
695769
6967701 . Create an output.tf file and add the following code to output the API Key Token.
697771
698- ``` yml
699- output "apikey_token" { value = temporalcloud_apikey.global_apikey.token sensitive = true }
772+ ``` hcl
773+ output "apikey_token" {
774+ value = temporalcloud_apikey.global_apikey.token
775+ sensitive = true
776+ }
700777 ```
701778
7027791 . Apply your configuration. When prompted, answer yes to continue:
@@ -781,10 +858,12 @@ Terraform Data Sources
781858
782859For example, to retrieve a list of regions available for your account, you can use the regions data_source
783860
784- ``` yml
861+ ``` hcl
785862data "temporalcloud_regions" "regions" {}
786863
787- output "regions" { value = data.temporalcloud_regions.regions.regions }
864+ output "regions" {
865+ value = data.temporalcloud_regions.regions.regions
866+ }
788867```
789868
790869## Community Involvement
0 commit comments