Skip to content

Commit 3af84a8

Browse files
Namespace Tagging support (#319)
* init * undo resource * stash * update: tags per namespace * refresh state in update method * fix: typo * update * some stuff * resource test * update * timeouts fix * try * s * more * examples * more * fix: comments
1 parent 1d84a8c commit 3af84a8

File tree

13 files changed

+639
-5
lines changed

13 files changed

+639
-5
lines changed

docs/data-sources/namespace.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ output "namespace" {
6262
- `custom_search_attributes` (Map of String) The custom search attributes to use for the namespace.
6363
- `last_modified_time` (String) The date and time when the namespace was last modified. Will not be set if the namespace has never been modified.
6464
- `private_connectivities` (Attributes List) The private connectivities for the namespace, if any. (see [below for nested schema](#nestedatt--private_connectivities))
65+
- `tags` (Map of String) The tags for the namespace.
6566

6667
### Read-Only
6768

docs/data-sources/namespaces.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Optional:
5252
- `custom_search_attributes` (Map of String) The custom search attributes to use for the namespace.
5353
- `last_modified_time` (String) The date and time when the namespace was last modified. Will not be set if the namespace has never been modified.
5454
- `private_connectivities` (Attributes List) The private connectivities for the namespace, if any. (see [below for nested schema](#nestedatt--namespaces--private_connectivities))
55+
- `tags` (Map of String) The tags for the namespace.
5556

5657
Read-Only:
5758

docs/resources/namespace_tags.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "temporalcloud_namespace_tags Resource - terraform-provider-temporalcloud"
4+
subcategory: ""
5+
description: |-
6+
Manages the complete set of tags for a Temporal Cloud namespace.
7+
---
8+
9+
# temporalcloud_namespace_tags (Resource)
10+
11+
Manages the complete set of tags for a Temporal Cloud namespace.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
temporalcloud = {
19+
source = "temporalio/temporalcloud"
20+
}
21+
}
22+
}
23+
24+
provider "temporalcloud" {
25+
26+
}
27+
28+
// Create a namespace first
29+
resource "temporalcloud_namespace" "example" {
30+
name = "example-namespace"
31+
regions = ["aws-us-west-2"]
32+
api_key_auth = true
33+
retention_days = 14
34+
}
35+
36+
// Basic namespace tags example, with a custom timeout
37+
resource "temporalcloud_namespace_tags" "example" {
38+
namespace_id = temporalcloud_namespace.example.id
39+
tags = {
40+
"environment" = "production"
41+
"team" = "backend"
42+
"project" = "temporal-workflows"
43+
}
44+
timeouts {
45+
create = "10m"
46+
delete = "5m"
47+
}
48+
}
49+
```
50+
51+
<!-- schema generated by tfplugindocs -->
52+
## Schema
53+
54+
### Required
55+
56+
- `namespace_id` (String) The ID of the namespace to manage tags for.
57+
- `tags` (Map of String) A map of tag keys to tag values.
58+
59+
### Optional
60+
61+
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
62+
63+
### Read-Only
64+
65+
- `id` (String) The ID of this namespace tags resource.
66+
67+
<a id="nestedblock--timeouts"></a>
68+
### Nested Schema for `timeouts`
69+
70+
Optional:
71+
72+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
73+
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
74+
75+
## Import
76+
77+
Import is supported using the following syntax:
78+
79+
```shell
80+
# Namespace Tags can be imported to incorporate existing Namespace Tags into your Terraform pipeline.
81+
# To import Namespace Tags, you need:
82+
# - a resource configuration in your Terraform configuration file/module to accept the imported Namespace Tags. In the example below, the placeholder is "temporalcloud_namespace_tags" "tags_import"
83+
# - the Namespace ID, which includes the Namespace Name and Account ID available at the top of the Namespace's page in the Temporal Cloud UI. In the example below, this is namespaceid.acctid
84+
# The import ID format is: namespaceid.acctid/tags
85+
86+
terraform import temporalcloud_namespace_tags.tags_import namespaceid.acctid/tags
87+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Namespace Tags can be imported to incorporate existing Namespace Tags into your Terraform pipeline.
2+
# To import Namespace Tags, you need:
3+
# - a resource configuration in your Terraform configuration file/module to accept the imported Namespace Tags. In the example below, the placeholder is "temporalcloud_namespace_tags" "tags_import"
4+
# - the Namespace ID, which includes the Namespace Name and Account ID available at the top of the Namespace's page in the Temporal Cloud UI. In the example below, this is namespaceid.acctid
5+
# The import ID format is: namespaceid.acctid/tags
6+
7+
terraform import temporalcloud_namespace_tags.tags_import namespaceid.acctid/tags
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
terraform {
2+
required_providers {
3+
temporalcloud = {
4+
source = "temporalio/temporalcloud"
5+
}
6+
}
7+
}
8+
9+
provider "temporalcloud" {
10+
11+
}
12+
13+
// Create a namespace first
14+
resource "temporalcloud_namespace" "example" {
15+
name = "example-namespace"
16+
regions = ["aws-us-west-2"]
17+
api_key_auth = true
18+
retention_days = 14
19+
}
20+
21+
// Basic namespace tags example, with a custom timeout
22+
resource "temporalcloud_namespace_tags" "example" {
23+
namespace_id = temporalcloud_namespace.example.id
24+
tags = {
25+
"environment" = "production"
26+
"team" = "backend"
27+
"project" = "temporal-workflows"
28+
}
29+
timeouts {
30+
create = "10m"
31+
delete = "5m"
32+
}
33+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/hashicorp/terraform-plugin-testing v1.13.1
1616
github.com/jpillora/maplock v0.0.0-20160420012925-5c725ac6e22a
1717
go.temporal.io/api v1.50.0
18-
go.temporal.io/cloud-sdk v0.4.1
18+
go.temporal.io/cloud-sdk v0.5.0
1919
go.temporal.io/sdk v1.35.0
2020
google.golang.org/grpc v1.73.0
2121
google.golang.org/protobuf v1.36.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt
238238
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
239239
go.temporal.io/api v1.50.0 h1:7s8Cn+fKfNx9G0v2Ge9We6X2WiCA3JvJ9JryeNbx1Bc=
240240
go.temporal.io/api v1.50.0/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM=
241-
go.temporal.io/cloud-sdk v0.4.1 h1:hvf6Hqto+1lwlfpvSLOKO/0ATpoYC8Cfh1w0gjWo39A=
242-
go.temporal.io/cloud-sdk v0.4.1/go.mod h1:AueDDyuayosk+zalfrnuftRqnRQTHwD0HYwNgEQc0YE=
241+
go.temporal.io/cloud-sdk v0.5.0 h1:6PdA6D8I/PiFLLpYwinre7ffPTct49zhapMAN5rJjmw=
242+
go.temporal.io/cloud-sdk v0.5.0/go.mod h1:AueDDyuayosk+zalfrnuftRqnRQTHwD0HYwNgEQc0YE=
243243
go.temporal.io/sdk v1.35.0 h1:lRNAQ5As9rLgYa7HBvnmKyzxLcdElTuoFJ0FXM/AsLQ=
244244
go.temporal.io/sdk v1.35.0/go.mod h1:1q5MuLc2MEJ4lneZTHJzpVebW2oZnyxoIOWX3oFVebw=
245245
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

internal/provider/group_access_resource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/temporalio/terraform-provider-temporalcloud/internal/provider/enums"
4545
internaltypes "github.com/temporalio/terraform-provider-temporalcloud/internal/types"
4646
cloudservicev1 "go.temporal.io/cloud-sdk/api/cloudservice/v1"
47-
"go.temporal.io/cloud-sdk/api/identity/v1"
4847
identityv1 "go.temporal.io/cloud-sdk/api/identity/v1"
4948
)
5049

@@ -357,7 +356,7 @@ func (r *groupAccessResource) ImportState(ctx context.Context, req resource.Impo
357356
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
358357
}
359358

360-
func updateGroupAccessModel(ctx context.Context, state *groupAccessResourceModel, group *identity.UserGroup) diag.Diagnostics {
359+
func updateGroupAccessModel(ctx context.Context, state *groupAccessResourceModel, group *identityv1.UserGroup) diag.Diagnostics {
361360
var diags diag.Diagnostics
362361

363362
if group == nil {

0 commit comments

Comments
 (0)