Skip to content

Commit 621e72a

Browse files
authored
Added tags read/write to resources and read to data sources (#563)
* Added tags read/write to resources and read to data sources * Added documentation * Lower-case keys and values, no single-character keys/values
1 parent 757cfc2 commit 621e72a

17 files changed

+291
-28
lines changed

docs/data-sources/rediscloud_active_active_subscription_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ data "rediscloud_active_active_subscription_database" "example" {
5252
* `private_endpoint` - Private endpoint to access the database.
5353
* `latest_backup_statuses` A list of latest_backup_status objects, documented below.
5454
* `latest_import_status` - A latest_import_status object, documented below.`
55+
* `tags` - A string/string map of all Tags associated with this database.
5556

5657
The `latest_backup_status` object and `latest_import_status` block contains:
5758

docs/data-sources/rediscloud_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ data "rediscloud_database" "example" {
6363
* `enable_default_user` - When `true` enables connecting to the database with the default user. Default `true`.
6464
* `latest_backup_status` - A latest_backup_status object, documented below.
6565
* `latest_import_status` - A latest_import_status object, documented below.
66+
* `tags` - A string/string map of all Tags associated with this database.
6667

6768
The `alert` block supports:
6869

docs/data-sources/rediscloud_essentials_database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ data "rediscloud_essentials_database" "example" {
5959
* `modules` A list of database modules, documented below.
6060
* `latest_backup_status` - A latest_backup_status object, documented below.
6161
* `latest_import_status` - A latest_import_status object, documented below.
62+
* `tags` - A string/string map of all Tags associated with this database.
6263
* `memory_limit_in_gb` - **Only relevant with Pay-As-You-Go databases.** Maximum memory usage for this specific database.
6364
* `support_oss_cluster_api` - **Only relevant with Pay-As-You-Go databases.** Support Redis open-source (OSS) Cluster API.
6465
* `external_endpoint_for_oss_cluster_api` - **Only relevant with Pay-As-You-Go databases.** Should use the external endpoint for open-source (OSS) Cluster API.

docs/resources/rediscloud_active_active_subscription_database.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ resource "rediscloud_active_active_subscription_database" "database-resource" {
6969
value = 60
7070
}
7171
}
72+
73+
tags = {
74+
"environment" = "production"
75+
"cost_center" = "0700"
76+
}
7277
}
7378
7479
output "us-east-1-public-endpoints" {
@@ -101,7 +106,7 @@ The following arguments are supported:
101106
* `global_resp_version` - (Optional) Either 'resp2' or 'resp3'. Resp version for Crdb databases within the AA database. Must be compatible with Redis version.
102107
* `port` - (Optional) TCP port on which the database is available - must be between 10000 and 19999. **Modifying this attribute will force creation of a new resource.**
103108
* `override_region` - (Optional) Override region specific configuration, documented below
104-
109+
* `tags` - (Optional) A string/string map of tags to associate with this database. Note that all keys and values must be lowercase.
105110

106111
The `override_region` block supports:
107112

docs/resources/rediscloud_essentials_database.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ resource "rediscloud_essentials_database" "database-resource" {
4343
name = "throughput-higher-than"
4444
value = 80
4545
}
46+
47+
tags = {
48+
"env" = "dev"
49+
"priority" = "2"
50+
}
4651
}
4752
```
4853

@@ -64,6 +69,7 @@ The following arguments are supported:
6469
* `password` - (Optional) Password to access the database. If not specified, a random 32 character long alphanumeric password will be automatically generated.
6570
* `enable_default_user` - (Optional) When `true` enables connecting to the database with the default user. Default `true`.
6671
* `alert` - (Optional) A block defining Redis database alert. Can be specified multiple times. Documented below.
72+
* `tags` - (Optional) A string/string map of tags to associate with this database. Note that all keys and values must be lowercase.
6773
* `modules` - (Optional) A list of modules objects, documented below. **Modifying this attribute will force creation of a new resource.**
6874
* `enable_payg_features` - (Optional) Whether to enable features restricted to Pay-As-You-Go legacy databases. It is not supported for new databases. Default `false`.
6975
* `memory_limit_in_gb` - (Optional) **Only used with Pay-As-You-Go databases.** Maximum memory usage for the database.

docs/resources/rediscloud_subscription_database.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ resource "rediscloud_subscription_database" "database-resource" {
6767
name = "dataset-size"
6868
value = 40
6969
}
70+
71+
tags = {
72+
"market" = "emea"
73+
}
7074
}
7175
```
7276

@@ -105,7 +109,8 @@ The following arguments are supported:
105109
* `enable_tls` - (Optional) Use TLS for authentication. Default: ‘false’
106110
* `port` - (Optional) TCP port on which the database is available - must be between 10000 and 19999. **Modifying this attribute will force creation of a new resource.**
107111
* `remote_backup` (Optional) Specifies the backup options for the database, documented below
108-
* `enable_default_user` (Optional) When `true` enables connecting to the database with the default user. Default `true`.
112+
* `enable_default_user` (Optional) When `true` enables connecting to the database with the default user. Default `true`.
113+
* `tags` - (Optional) A string/string map of Tags to associate with this database. Note that all keys and values must be lowercase.
109114

110115
The `alert` block supports:
111116

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/RedisLabs/terraform-provider-rediscloud
33
go 1.22.4
44

55
require (
6-
github.com/RedisLabs/rediscloud-go-api v0.19.0
6+
github.com/RedisLabs/rediscloud-go-api v0.20.1
77
github.com/bflad/tfproviderlint v0.30.0
88
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
99
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
@@ -52,13 +52,13 @@ require (
5252
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
5353
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
5454
github.com/zclconf/go-cty v1.14.4 // indirect
55-
golang.org/x/crypto v0.25.0 // indirect
56-
golang.org/x/mod v0.19.0 // indirect
57-
golang.org/x/net v0.27.0 // indirect
58-
golang.org/x/sync v0.7.0 // indirect
59-
golang.org/x/sys v0.22.0 // indirect
60-
golang.org/x/text v0.16.0 // indirect
61-
golang.org/x/tools v0.23.0 // indirect
55+
golang.org/x/crypto v0.26.0 // indirect
56+
golang.org/x/mod v0.20.0 // indirect
57+
golang.org/x/net v0.28.0 // indirect
58+
golang.org/x/sync v0.8.0 // indirect
59+
golang.org/x/sys v0.23.0 // indirect
60+
golang.org/x/text v0.17.0 // indirect
61+
golang.org/x/tools v0.24.0 // indirect
6262
google.golang.org/appengine v1.6.8 // indirect
6363
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
6464
google.golang.org/grpc v1.63.2 // indirect

go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
44
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
55
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
66
github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
7-
github.com/RedisLabs/rediscloud-go-api v0.19.0 h1:ItgQzOwKT1kF+1buLS80kWLZsilW4DscB/WeuNQ8rbY=
8-
github.com/RedisLabs/rediscloud-go-api v0.19.0/go.mod h1:Euh81mfkoCDTH2gQT+rNnvI7rwCDe05zdvkxp9oKQsM=
7+
github.com/RedisLabs/rediscloud-go-api v0.20.1 h1:imYAb7qi7XCHHQ8IeBo4CUr8KWjiZ8Njj0P84YmqhSI=
8+
github.com/RedisLabs/rediscloud-go-api v0.20.1/go.mod h1:3/oVb71rv2OstFRYEc65QCIbfwnJTgZeQhtPCcdHook=
99
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
1010
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
1111
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
@@ -155,23 +155,23 @@ github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRK
155155
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
156156
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
157157
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
158-
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
159-
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
158+
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
159+
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
160160
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
161161
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
162-
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
163-
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
162+
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
163+
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
164164
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
165165
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
166166
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
167167
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
168-
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
169-
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
168+
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
169+
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
170170
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
171171
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
172172
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
173-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
174-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
173+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
174+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
175175
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
176176
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
177177
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -185,25 +185,25 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
185185
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
186186
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
187187
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
188-
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
189-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
188+
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
189+
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
190190
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
191191
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
192-
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
193-
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
192+
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
193+
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
194194
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
195195
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
196196
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
197197
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
198198
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
199-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
200-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
199+
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
200+
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
201201
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
202202
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
203203
golang.org/x/tools v0.0.0-20200214201135-548b770e2dfa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
204204
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
205-
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
206-
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
205+
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
206+
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
207207
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
208208
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
209209
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

provider/datasource_rediscloud_active_active_database.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ func dataSourceRedisCloudActiveActiveDatabase() *schema.Resource {
214214
},
215215
},
216216
},
217+
"tags": {
218+
Description: "Tags for database management",
219+
Type: schema.TypeMap,
220+
Elem: &schema.Schema{
221+
Type: schema.TypeString,
222+
},
223+
Computed: true,
224+
},
217225
},
218226
}
219227
}
@@ -341,6 +349,10 @@ func dataSourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema
341349
return diag.FromErr(err)
342350
}
343351

352+
if err := readTags(ctx, api, subId, dbId, d); err != nil {
353+
return diag.FromErr(err)
354+
}
355+
344356
return diags
345357
}
346358

provider/datasource_rediscloud_essentials_database.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,14 @@ func dataSourceRedisCloudEssentialsDatabase() *schema.Resource {
353353
Type: schema.TypeBool,
354354
Computed: true,
355355
},
356+
"tags": {
357+
Description: "Tags for database management",
358+
Type: schema.TypeMap,
359+
Elem: &schema.Schema{
360+
Type: schema.TypeString,
361+
},
362+
Computed: true,
363+
},
356364
},
357365
}
358366
}
@@ -546,6 +554,10 @@ func dataSourceRedisCloudEssentialsDatabaseRead(ctx context.Context, d *schema.R
546554
}
547555
}
548556

557+
if err := readFixedTags(ctx, api, subId, databaseId, d); err != nil {
558+
return diag.FromErr(err)
559+
}
560+
549561
return diags
550562
}
551563

0 commit comments

Comments
 (0)