From 64e116704c2cd395f401a981201934a3a1476510 Mon Sep 17 00:00:00 2001 From: Jeffrey Held Date: Mon, 18 Dec 2023 11:02:43 +0100 Subject: [PATCH] feat(service): expose tech_emails Allow users to set `tech_emails` member of service. --- CHANGELOG.md | 1 + docs/data-sources/cassandra.md | 9 +++ docs/data-sources/clickhouse.md | 9 +++ docs/data-sources/flink.md | 9 +++ docs/data-sources/grafana.md | 9 +++ docs/data-sources/influxdb.md | 9 +++ docs/data-sources/kafka.md | 9 +++ docs/data-sources/kafka_connect.md | 9 +++ docs/data-sources/kafka_mirrormaker.md | 9 +++ docs/data-sources/m3aggregator.md | 9 +++ docs/data-sources/m3db.md | 9 +++ docs/data-sources/mysql.md | 9 +++ docs/data-sources/opensearch.md | 9 +++ docs/data-sources/pg.md | 9 +++ docs/data-sources/project.md | 2 +- docs/data-sources/redis.md | 9 +++ docs/resources/cassandra.md | 9 +++ docs/resources/clickhouse.md | 9 +++ docs/resources/flink.md | 9 +++ docs/resources/grafana.md | 9 +++ docs/resources/influxdb.md | 9 +++ docs/resources/kafka.md | 9 +++ docs/resources/kafka_connect.md | 9 +++ docs/resources/kafka_mirrormaker.md | 9 +++ docs/resources/m3aggregator.md | 9 +++ docs/resources/m3db.md | 9 +++ docs/resources/mysql.md | 9 +++ docs/resources/opensearch.md | 9 +++ docs/resources/pg.md | 9 +++ docs/resources/project.md | 2 +- docs/resources/redis.md | 9 +++ go.mod | 2 +- go.sum | 4 +- internal/schemautil/service.go | 54 +++++++++++++++ .../sdkprovider/service/project/project.go | 2 +- .../sdkprovider/service/redis/redis_test.go | 66 +++++++++++++++++++ 36 files changed, 379 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9223cb95b..52ea2dbf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ nav_order: 1 ## [4.9.4] - 2023-12-13 - Fix race issues with `aiven_mirrormaker_replication_flow` on create/update/delete operations +- Add `tech_emails` to services ## [4.9.3] - 2023-10-27 diff --git a/docs/data-sources/cassandra.md b/docs/data-sources/cassandra.md index 073b4a328..dc8dd04d1 100644 --- a/docs/data-sources/cassandra.md +++ b/docs/data-sources/cassandra.md @@ -54,6 +54,7 @@ data "aiven_cassandra" "bar" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -152,3 +153,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/clickhouse.md b/docs/data-sources/clickhouse.md index 15ccef3a8..e78cef54f 100644 --- a/docs/data-sources/clickhouse.md +++ b/docs/data-sources/clickhouse.md @@ -54,6 +54,7 @@ data "aiven_clickhouse" "clickhouse" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -154,3 +155,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/flink.md b/docs/data-sources/flink.md index 44f983543..7c3bc80f2 100644 --- a/docs/data-sources/flink.md +++ b/docs/data-sources/flink.md @@ -54,6 +54,7 @@ data "aiven_flink" "flink" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -129,3 +130,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/grafana.md b/docs/data-sources/grafana.md index 7ec170df4..7e1f7150f 100644 --- a/docs/data-sources/grafana.md +++ b/docs/data-sources/grafana.md @@ -54,6 +54,7 @@ data "aiven_grafana" "gr1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -286,3 +287,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/influxdb.md b/docs/data-sources/influxdb.md index 8829056a1..1a74bfe13 100644 --- a/docs/data-sources/influxdb.md +++ b/docs/data-sources/influxdb.md @@ -54,6 +54,7 @@ data "aiven_influxdb" "inf1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -163,3 +164,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/kafka.md b/docs/data-sources/kafka.md index 15ea5e5d0..f42e70681 100644 --- a/docs/data-sources/kafka.md +++ b/docs/data-sources/kafka.md @@ -56,6 +56,7 @@ data "aiven_kafka" "kafka1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -303,3 +304,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/kafka_connect.md b/docs/data-sources/kafka_connect.md index 1201ad188..dd260d041 100644 --- a/docs/data-sources/kafka_connect.md +++ b/docs/data-sources/kafka_connect.md @@ -54,6 +54,7 @@ data "aiven_kafka_connect" "kc1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -171,3 +172,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/kafka_mirrormaker.md b/docs/data-sources/kafka_mirrormaker.md index 000a2747b..2ae9c907b 100644 --- a/docs/data-sources/kafka_mirrormaker.md +++ b/docs/data-sources/kafka_mirrormaker.md @@ -54,6 +54,7 @@ data "aiven_kafka_mirrormaker" "mm1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -134,3 +135,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/m3aggregator.md b/docs/data-sources/m3aggregator.md index bc125393a..0c46c1b13 100644 --- a/docs/data-sources/m3aggregator.md +++ b/docs/data-sources/m3aggregator.md @@ -54,6 +54,7 @@ data "aiven_m3aggregator" "m3a" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -118,3 +119,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/m3db.md b/docs/data-sources/m3db.md index 547487733..9b8fcd9fe 100644 --- a/docs/data-sources/m3db.md +++ b/docs/data-sources/m3db.md @@ -54,6 +54,7 @@ data "aiven_m3db" "m3" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -248,3 +249,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/mysql.md b/docs/data-sources/mysql.md index 49dd01d30..1ae46358e 100644 --- a/docs/data-sources/mysql.md +++ b/docs/data-sources/mysql.md @@ -54,6 +54,7 @@ data "aiven_mysql" "mysql1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -212,3 +213,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/opensearch.md b/docs/data-sources/opensearch.md index 62dbc7aaf..bd8caccf2 100644 --- a/docs/data-sources/opensearch.md +++ b/docs/data-sources/opensearch.md @@ -54,6 +54,7 @@ data "aiven_opensearch" "os1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -311,3 +312,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/pg.md b/docs/data-sources/pg.md index ca4802be1..b17f5ee66 100644 --- a/docs/data-sources/pg.md +++ b/docs/data-sources/pg.md @@ -54,6 +54,7 @@ data "aiven_pg" "pg" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -295,3 +296,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 05ce80dec..dd403526c 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -39,7 +39,7 @@ data "aiven_project" "myproject" { - `parent_id` (String) An optional property to link a project to an already existing organization or account by using its ID. To set up proper dependencies please refer to this variable as a reference. - `payment_method` (String) The method of invoicing used for payments for this project, e.g. `card`. - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize projects. (see [below for nested schema](#nestedatt--tag)) -- `technical_emails` (Set of String) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is good practice to keep this up-to-date to be aware of any potential issues with your project. +- `technical_emails` (Set of String) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is a good practice to keep this up-to-date to be aware of any potential issues with your project. - `use_source_project_billing_group` (Boolean) Use the same billing group that is used in source project. diff --git a/docs/data-sources/redis.md b/docs/data-sources/redis.md index ca00860f4..f67b2e682 100644 --- a/docs/data-sources/redis.md +++ b/docs/data-sources/redis.md @@ -54,6 +54,7 @@ data "aiven_redis" "redis1" { - `state` (String) Service state. One of `POWEROFF`, `REBALANCING`, `REBUILDING` or `RUNNING` - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Set of Object) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedatt--tag)) +- `tech_emails` (Set of Object) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedatt--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. @@ -176,3 +177,11 @@ Read-Only: - `key` (String) - `value` (String) + + + +### Nested Schema for `tech_emails` + +Read-Only: + +- `email` (String) diff --git a/docs/resources/cassandra.md b/docs/resources/cassandra.md index e46ead0d4..b71f89b9d 100644 --- a/docs/resources/cassandra.md +++ b/docs/resources/cassandra.md @@ -52,6 +52,7 @@ resource "aiven_cassandra" "bar" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -151,6 +152,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/clickhouse.md b/docs/resources/clickhouse.md index dd357bea2..4d46b1192 100644 --- a/docs/resources/clickhouse.md +++ b/docs/resources/clickhouse.md @@ -44,6 +44,7 @@ resource "aiven_clickhouse" "clickhouse" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -145,6 +146,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/flink.md b/docs/resources/flink.md index 4a1cc6855..8cea6529d 100644 --- a/docs/resources/flink.md +++ b/docs/resources/flink.md @@ -49,6 +49,7 @@ resource "aiven_flink" "flink" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -131,6 +132,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/grafana.md b/docs/resources/grafana.md index 3ec4ee196..3ed9988f3 100644 --- a/docs/resources/grafana.md +++ b/docs/resources/grafana.md @@ -52,6 +52,7 @@ resource "aiven_grafana" "gr1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -303,6 +304,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/influxdb.md b/docs/resources/influxdb.md index 356bcd308..7728f926b 100644 --- a/docs/resources/influxdb.md +++ b/docs/resources/influxdb.md @@ -50,6 +50,7 @@ resource "aiven_influxdb" "inf1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -159,6 +160,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/kafka.md b/docs/resources/kafka.md index 0a288e91b..440ad336c 100644 --- a/docs/resources/kafka.md +++ b/docs/resources/kafka.md @@ -63,6 +63,7 @@ resource "aiven_kafka" "kafka1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -306,6 +307,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/kafka_connect.md b/docs/resources/kafka_connect.md index a81381601..22481c6cb 100644 --- a/docs/resources/kafka_connect.md +++ b/docs/resources/kafka_connect.md @@ -54,6 +54,7 @@ resource "aiven_kafka_connect" "kc1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -172,6 +173,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/kafka_mirrormaker.md b/docs/resources/kafka_mirrormaker.md index b2a090613..7e6e32076 100644 --- a/docs/resources/kafka_mirrormaker.md +++ b/docs/resources/kafka_mirrormaker.md @@ -52,6 +52,7 @@ resource "aiven_kafka_mirrormaker" "mm1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -133,6 +134,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/m3aggregator.md b/docs/resources/m3aggregator.md index e4a9e90e1..b66b85730 100644 --- a/docs/resources/m3aggregator.md +++ b/docs/resources/m3aggregator.md @@ -48,6 +48,7 @@ resource "aiven_m3aggregator" "m3a" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -113,6 +114,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/m3db.md b/docs/resources/m3db.md index a6ccff049..c5b1e075d 100644 --- a/docs/resources/m3db.md +++ b/docs/resources/m3db.md @@ -53,6 +53,7 @@ resource "aiven_m3db" "m3" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -254,6 +255,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/mysql.md b/docs/resources/mysql.md index 9e213dcc4..d602c1851 100644 --- a/docs/resources/mysql.md +++ b/docs/resources/mysql.md @@ -57,6 +57,7 @@ resource "aiven_mysql" "mysql1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -219,6 +220,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/opensearch.md b/docs/resources/opensearch.md index 22944ad6c..4c8147a7d 100644 --- a/docs/resources/opensearch.md +++ b/docs/resources/opensearch.md @@ -58,6 +58,7 @@ resource "aiven_opensearch" "os1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -324,6 +325,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/pg.md b/docs/resources/pg.md index f5e3d621e..1954a0a69 100644 --- a/docs/resources/pg.md +++ b/docs/resources/pg.md @@ -72,6 +72,7 @@ resource "aiven_pg" "pg" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -326,6 +327,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/docs/resources/project.md b/docs/resources/project.md index a8d5e17f9..4598d6958 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -36,7 +36,7 @@ resource "aiven_project" "myproject" { - `default_cloud` (String) Defines the default cloud provider and region where services are hosted. This can be changed freely after the project is created. This will not affect existing services. - `parent_id` (String) An optional property to link a project to an already existing organization or account by using its ID. To set up proper dependencies please refer to this variable as a reference. - `tag` (Block Set) Tags are key-value pairs that allow you to categorize projects. (see [below for nested schema](#nestedblock--tag)) -- `technical_emails` (Set of String) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is good practice to keep this up-to-date to be aware of any potential issues with your project. +- `technical_emails` (Set of String) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is a good practice to keep this up-to-date to be aware of any potential issues with your project. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `use_source_project_billing_group` (Boolean, Deprecated) Use the same billing group that is used in source project. diff --git a/docs/resources/redis.md b/docs/resources/redis.md index cca318af2..c309d0cb6 100644 --- a/docs/resources/redis.md +++ b/docs/resources/redis.md @@ -52,6 +52,7 @@ resource "aiven_redis" "redis1" { - `service_integrations` (Block List) Service integrations to specify when creating a service. Not applied after initial service creation (see [below for nested schema](#nestedblock--service_integrations)) - `static_ips` (Set of String) Static IPs that are going to be associated with this service. Please assign a value using the 'toset' function. Once a static ip resource is in the 'assigned' state it cannot be unbound from the node again - `tag` (Block Set) Tags are key-value pairs that allow you to categorize services. (see [below for nested schema](#nestedblock--tag)) +- `tech_emails` (Block Set) Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. (see [below for nested schema](#nestedblock--tech_emails)) - `termination_protection` (Boolean) Prevents the service from being deleted. It is recommended to set this to `true` for all production services to prevent unintentional service deletion. This does not shield against deleting databases or topics but for services with backups much of the content can at least be restored from backup in case accidental deletion is done. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -178,6 +179,14 @@ Required: - `value` (String) Service tag value + +### Nested Schema for `tech_emails` + +Required: + +- `email` (String) An email address to contact for technical issues + + ### Nested Schema for `timeouts` diff --git a/go.mod b/go.mod index ba9ded2a9..568847915 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/aiven/terraform-provider-aiven go 1.21 require ( - github.com/aiven/aiven-go-client/v2 v2.4.0 + github.com/aiven/aiven-go-client/v2 v2.4.1-0.20231215141434-4298c57c2db2 github.com/avast/retry-go v3.0.0+incompatible github.com/dave/jennifer v1.7.0 github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 36cb68fa7..900c3d459 100644 --- a/go.sum +++ b/go.sum @@ -197,8 +197,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjA github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/aiven/aiven-go-client/v2 v2.4.0 h1:vBBKgYEYyFZp/f+vcdxTkWnJ2b09Wlto3kwEzj5uvBQ= -github.com/aiven/aiven-go-client/v2 v2.4.0/go.mod h1:x0xhzxWEKAwKv0xY5FvECiI6tesWshcPHvjwl0B/1SU= +github.com/aiven/aiven-go-client/v2 v2.4.1-0.20231215141434-4298c57c2db2 h1:qZTblx9ilPcJ1AUI+koSNI0ThmBHXOm+KZj9AjP7jaQ= +github.com/aiven/aiven-go-client/v2 v2.4.1-0.20231215141434-4298c57c2db2/go.mod h1:x0xhzxWEKAwKv0xY5FvECiI6tesWshcPHvjwl0B/1SU= github.com/aiven/go-api-schemas v1.49.0 h1:9ccN0ZzrxZSo7Fc/Ejprv6pw6oKJdp8n28UnOEAke+s= github.com/aiven/go-api-schemas v1.49.0/go.mod h1:/bPxBUHza/2Aeer6hIIdB++GxKiw9K1KCBtRa2rtZ5I= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= diff --git a/internal/schemautil/service.go b/internal/schemautil/service.go index e3f2e2121..881c1e429 100644 --- a/internal/schemautil/service.go +++ b/internal/schemautil/service.go @@ -49,6 +49,16 @@ const ( ServiceTypeClickhouse = "clickhouse" ) +var TechEmailsResourceSchema = &schema.Resource{ + Schema: map[string]*schema.Schema{ + "email": { + Type: schema.TypeString, + Description: "An email address to contact for technical issues", + Required: true, + }, + }, +} + func ServiceCommonSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "project": CommonSchemaProjectReference, @@ -267,6 +277,12 @@ func ServiceCommonSchema() map[string]*schema.Schema { }, }, }, + "tech_emails": { + Type: schema.TypeSet, + Elem: TechEmailsResourceSchema, + Optional: true, + Description: "Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability.", + }, } } @@ -373,6 +389,10 @@ func ResourceServiceRead(ctx context.Context, d *schema.ResourceData, m interfac return diag.Errorf("unable to set tag's in schema: %s", err) } + if err := d.Set("tech_emails", getTechnicalEmailsForTerraform(d, "tech_emails", s)); err != nil { + return diag.Errorf("unable to set tech_emails in schema: %s", err) + } + return nil } @@ -429,6 +449,7 @@ func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, m interf DiskSpaceMB: diskSpace, UserConfig: cuc, StaticIPs: FlattenToString(d.Get("static_ips").(*schema.Set).List()), + TechnicalEmails: getContactEmailListForAPI(d, "tech_emails"), }, ) if err != nil { @@ -517,6 +538,7 @@ func ResourceServiceUpdate(ctx context.Context, d *schema.ResourceData, m interf DiskSpaceMB: diskSpace, Karapace: karapace, UserConfig: cuc, + TechnicalEmails: getContactEmailListForAPI(d, "tech_emails"), }, ); err != nil { return diag.Errorf("error updating (%s) service: %s", serviceName, err) @@ -572,6 +594,20 @@ func getDefaultDiskSpaceIfNotSet(ctx context.Context, d *schema.ResourceData, cl return diskSpace, nil } +func getTechnicalEmailsForTerraform(d *schema.ResourceData, field string, s *aiven.Service) *schema.Set { + _, existsBefore := d.GetOk(field) + if !existsBefore && len(s.TechnicalEmails) == 0 { + return nil + } + + techEmails := make([]interface{}, len(s.TechnicalEmails)) + for i, e := range s.TechnicalEmails { + techEmails[i] = map[string]interface{}{"email": e.Email} + } + + return schema.NewSet(schema.HashResource(TechEmailsResourceSchema), techEmails) +} + func ResourceServiceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { client := m.(*aiven.Client) @@ -657,6 +693,10 @@ func copyServicePropertiesFromAPIResponseToTerraform( return err } + if err := d.Set("tech_emails", getTechnicalEmailsForTerraform(d, "tech_emails", s)); err != nil { + return err + } + if s.ProjectVPCID != nil { if err := d.Set("project_vpc_id", BuildResourceID(project, *s.ProjectVPCID)); err != nil { return err @@ -864,3 +904,17 @@ func DatasourceServiceRead(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("common %s/%s not found", projectName, serviceName) } + +func getContactEmailListForAPI(d *schema.ResourceData, field string) *[]aiven.ContactEmail { + var results []aiven.ContactEmail + valuesInterface, ok := d.GetOk(field) + if ok && valuesInterface != nil { + for _, emailInterface := range valuesInterface.(*schema.Set).List() { + results = append(results, aiven.ContactEmail{Email: emailInterface.(map[string]interface{})["email"].(string)}) + } + } + if results == nil { + return &[]aiven.ContactEmail{} + } + return &results +} diff --git a/internal/sdkprovider/service/project/project.go b/internal/sdkprovider/service/project/project.go index ce96c27a5..e7404ca14 100644 --- a/internal/sdkprovider/service/project/project.go +++ b/internal/sdkprovider/service/project/project.go @@ -79,7 +79,7 @@ var aivenProjectSchema = map[string]*schema.Schema{ Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, - Description: "Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is good practice to keep this up-to-date to be aware of any potential issues with your project.", + Description: "Defines the email addresses that will receive alerts about upcoming maintenance updates or warnings about service instability. It is a good practice to keep this up-to-date to be aware of any potential issues with your project.", }, "default_cloud": { Type: schema.TypeString, diff --git a/internal/sdkprovider/service/redis/redis_test.go b/internal/sdkprovider/service/redis/redis_test.go index 8c117e883..8e11ad21a 100644 --- a/internal/sdkprovider/service/redis/redis_test.go +++ b/internal/sdkprovider/service/redis/redis_test.go @@ -27,6 +27,32 @@ func TestAccAiven_redis(t *testing.T) { Check: resource.ComposeTestCheckFunc( acc.TestAccCheckAivenServiceCommonAttributes("data.aiven_redis.common"), testAccCheckAivenServiceRedisAttributes("data.aiven_redis.common"), + resource.TestCheckResourceAttr(resourceName, "tag.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tech_emails.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tech_emails.0.email", "techsupport@company.com"), + resource.TestCheckResourceAttr(resourceName, "service_name", fmt.Sprintf("test-acc-sr-%s", rName)), + resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"), + resource.TestCheckResourceAttr(resourceName, "project", os.Getenv("AIVEN_PROJECT_NAME")), + resource.TestCheckResourceAttr(resourceName, "service_type", "redis"), + resource.TestCheckResourceAttr(resourceName, "cloud_name", "google-europe-west1"), + resource.TestCheckResourceAttr(resourceName, "maintenance_window_dow", "monday"), + resource.TestCheckResourceAttr(resourceName, "maintenance_window_time", "10:00:00"), + resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"), + resource.TestCheckResourceAttr(resourceName, "termination_protection", "false"), + resource.TestCheckResourceAttrSet(resourceName, "service_username"), + resource.TestCheckResourceAttrSet(resourceName, "service_password"), + resource.TestCheckResourceAttrSet(resourceName, "service_host"), + resource.TestCheckResourceAttrSet(resourceName, "service_port"), + resource.TestCheckResourceAttrSet(resourceName, "service_uri"), + ), + }, + { + Config: testAccRedisRemoveEmailsResource(rName), + Check: resource.ComposeTestCheckFunc( + acc.TestAccCheckAivenServiceCommonAttributes("data.aiven_redis.common"), + testAccCheckAivenServiceRedisAttributes("data.aiven_redis.common"), + resource.TestCheckResourceAttr(resourceName, "tag.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tech_emails.#", "0"), resource.TestCheckResourceAttr(resourceName, "service_name", fmt.Sprintf("test-acc-sr-%s", rName)), resource.TestCheckResourceAttr(resourceName, "state", "RUNNING"), resource.TestCheckResourceAttr(resourceName, "project", os.Getenv("AIVEN_PROJECT_NAME")), @@ -59,6 +85,46 @@ data "aiven_project" "foo" { project = "%s" } +resource "aiven_redis" "bar" { + project = data.aiven_project.foo.project + cloud_name = "google-europe-west1" + plan = "startup-4" + service_name = "test-acc-sr-%s" + maintenance_window_dow = "monday" + maintenance_window_time = "10:00:00" + + tag { + key = "test" + value = "val" + } + + tech_emails { + email = "techsupport@company.com" + } + + redis_user_config { + redis_maxmemory_policy = "allkeys-random" + + public_access { + redis = true + } + } +} + +data "aiven_redis" "common" { + service_name = aiven_redis.bar.service_name + project = data.aiven_project.foo.project + + depends_on = [aiven_redis.bar] +}`, os.Getenv("AIVEN_PROJECT_NAME"), name) +} + +func testAccRedisRemoveEmailsResource(name string) string { + return fmt.Sprintf(` +data "aiven_project" "foo" { + project = "%s" +} + resource "aiven_redis" "bar" { project = data.aiven_project.foo.project cloud_name = "google-europe-west1"