Skip to content

Commit

Permalink
feat(opensearch): security plugin (#1341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel authored Sep 6, 2023
1 parent a868405 commit 9434916
Show file tree
Hide file tree
Showing 15 changed files with 633 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ nav_order: 1
- Fix service IP filters normalization
- Fix improper omitting in `ToAPI`
- Fix Kafka Topic perfomance
- Add OpenSearch Security Plugin support (`aiven_opensearch_security_plugin_config` resource)

## [4.8.1] - 2023-08-23

Expand Down
36 changes: 36 additions & 0 deletions docs/data-sources/opensearch_security_plugin_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "aiven_opensearch_security_plugin_config Data Source - terraform-provider-aiven"
subcategory: ""
description: |-
The OpenSearch Security Plugin Config data source provides information about an existing Aiven OpenSearch Security Plugin Config.
---

# aiven_opensearch_security_plugin_config (Data Source)

The OpenSearch Security Plugin Config data source provides information about an existing Aiven OpenSearch Security Plugin Config.

## Example Usage

```terraform
data "aiven_opensearch_security_plugin_config" "os-sec-config" {
project = aiven_project.os-project.project
service_name = aiven_opensearch.os.service_name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `project` (String) Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. This property cannot be changed, doing so forces recreation of the resource.
- `service_name` (String) Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. This property cannot be changed, doing so forces recreation of the resource.

### Read-Only

- `admin_enabled` (Boolean) Whether the os-sec-admin user is enabled. This indicates whether the user management with the security plugin is enabled. This is always true when the os-sec-admin password was set at least once.
- `admin_password` (String, Sensitive) The password for the os-sec-admin user.
- `available` (Boolean) Whether the security plugin is available. This is always true for recently created services.
- `enabled` (Boolean) Whether the security plugin is enabled. This is always true for recently created services.
- `id` (String) The ID of this resource.
6 changes: 3 additions & 3 deletions docs/resources/opensearch_acl_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
page_title: "aiven_opensearch_acl_config Resource - terraform-provider-aiven"
subcategory: ""
description: |-
The OpenSearch resource allows the creation and management of Aiven OpenSearch services.
The OpenSearch ACL Config resource allows the creation and management of Aiven OpenSearch ACLs.
---

# aiven_opensearch_acl_config (Resource)

The OpenSearch resource allows the creation and management of Aiven OpenSearch services.
The OpenSearch ACL Config resource allows the creation and management of Aiven OpenSearch ACLs.

## Example Usage

```terraform
data "aiven_project" "foo" {
project = "example_project"
project = "example_project"
}
resource "aiven_opensearch" "bar" {
Expand Down
79 changes: 79 additions & 0 deletions docs/resources/opensearch_security_plugin_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "aiven_opensearch_security_plugin_config Resource - terraform-provider-aiven"
subcategory: ""
description: |-
The OpenSearch Security Plugin Config resource allows the creation and management of AivenOpenSearch Security Plugin config.
---

# aiven_opensearch_security_plugin_config (Resource)

The OpenSearch Security Plugin Config resource allows the creation and management of AivenOpenSearch Security Plugin config.

## Example Usage

```terraform
data "aiven_project" "foo" {
project = "example_project"
}
resource "aiven_opensearch" "bar" {
project = data.aiven_project.foo.project
cloud_name = "google-europe-west1"
plan = "startup-4"
service_name = "example_service_name"
maintenance_window_dow = "monday"
maintenance_window_time = "10:00:00"
}
resource "aiven_opensearch_user" "foo" {
service_name = aiven_opensearch.bar.service_name
project = data.aiven_project.foo.project
username = "user-example"
}
resource "aiven_opensearch_security_config" "foo" {
project = data.aiven_project.foo.project
service_name = aiven_opensearch.bar.service_name
admin_password = "ThisIsATest123^=^"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `admin_password` (String, Sensitive) The password for the os-sec-admin user.
- `project` (String) Identifies the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. This property cannot be changed, doing so forces recreation of the resource.
- `service_name` (String) Specifies the name of the service that this resource belongs to. To set up proper dependencies please refer to this variable as a reference. This property cannot be changed, doing so forces recreation of the resource.

### Optional

- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `admin_enabled` (Boolean) Whether the os-sec-admin user is enabled. This indicates whether the user management with the security plugin is enabled. This is always true when the os-sec-admin password was set at least once.
- `available` (Boolean) Whether the security plugin is available. This is always true for recently created services.
- `enabled` (Boolean) Whether the security plugin is enabled. This is always true for recently created services.
- `id` (String) The ID of this resource.

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `default` (String)
- `delete` (String)
- `read` (String)
- `update` (String)

## Import

Import is supported using the following syntax:

```shell
terraform import aiven_opensearch_security_plugin_config.foo project/service_name
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "aiven_opensearch_security_plugin_config" "os-sec-config" {
project = aiven_project.os-project.project
service_name = aiven_opensearch.os.service_name
}
2 changes: 1 addition & 1 deletion examples/resources/aiven_opensearch_acl_config/resource.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "aiven_project" "foo" {
project = "example_project"
project = "example_project"
}

resource "aiven_opensearch" "bar" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import aiven_opensearch_security_plugin_config.foo project/service_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data "aiven_project" "foo" {
project = "example_project"
}

resource "aiven_opensearch" "bar" {
project = data.aiven_project.foo.project
cloud_name = "google-europe-west1"
plan = "startup-4"
service_name = "example_service_name"
maintenance_window_dow = "monday"
maintenance_window_time = "10:00:00"
}

resource "aiven_opensearch_user" "foo" {
service_name = aiven_opensearch.bar.service_name
project = data.aiven_project.foo.project
username = "user-example"
}

resource "aiven_opensearch_security_config" "foo" {
project = data.aiven_project.foo.project
service_name = aiven_opensearch.bar.service_name
admin_password = "ThisIsATest123^=^"
}
14 changes: 14 additions & 0 deletions internal/schemautil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/aiven/aiven-go-client"
"github.com/docker/go-units"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
)

// ResourceStateOrResourceDiff either *schema.ResourceState or *schema.ResourceDiff
Expand Down Expand Up @@ -178,3 +179,16 @@ func DetermineMixedOrganizationConstraintIDToStore(

return r.Account.OrganizationId, nil
}

// StringToDiagWarning is a function that converts a string to a diag warning.
func StringToDiagWarning(msg string) diag.Diagnostics {
return diag.Diagnostics{{
Severity: diag.Warning,
Summary: msg,
}}
}

// ErrorToDiagWarning is a function that converts an error to a diag warning.
func ErrorToDiagWarning(err error) diag.Diagnostics {
return StringToDiagWarning(err.Error())
}
18 changes: 10 additions & 8 deletions internal/sdkprovider/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ func Provider(version string) *schema.Provider {
"aiven_flink_application_version": flink.DatasourceFlinkApplicationVersion(),

// opensearch
"aiven_opensearch": opensearch.DatasourceOpenSearch(),
"aiven_opensearch_user": opensearch.DatasourceOpenSearchUser(),
"aiven_opensearch_acl_config": opensearch.DatasourceOpenSearchACLConfig(),
"aiven_opensearch_acl_rule": opensearch.DatasourceOpenSearchACLRule(),
"aiven_opensearch": opensearch.DatasourceOpenSearch(),
"aiven_opensearch_user": opensearch.DatasourceOpenSearchUser(),
"aiven_opensearch_acl_config": opensearch.DatasourceOpenSearchACLConfig(),
"aiven_opensearch_acl_rule": opensearch.DatasourceOpenSearchACLRule(),
"aiven_opensearch_security_plugin_config": opensearch.DatasourceOpenSearchSecurityPluginConfig(),

// kafka
"aiven_kafka": kafka.DatasourceKafka(),
Expand Down Expand Up @@ -217,10 +218,11 @@ func Provider(version string) *schema.Provider {
"aiven_flink_application_deployment": flink.ResourceFlinkApplicationDeployment(),

// opensearch
"aiven_opensearch": opensearch.ResourceOpenSearch(),
"aiven_opensearch_user": opensearch.ResourceOpenSearchUser(),
"aiven_opensearch_acl_config": opensearch.ResourceOpenSearchACLConfig(),
"aiven_opensearch_acl_rule": opensearch.ResourceOpenSearchACLRule(),
"aiven_opensearch": opensearch.ResourceOpenSearch(),
"aiven_opensearch_user": opensearch.ResourceOpenSearchUser(),
"aiven_opensearch_acl_config": opensearch.ResourceOpenSearchACLConfig(),
"aiven_opensearch_acl_rule": opensearch.ResourceOpenSearchACLRule(),
"aiven_opensearch_security_plugin_config": opensearch.ResourceOpenSearchSecurityPluginConfig(),

// kafka
"aiven_kafka": kafka.ResourceKafka(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package opensearch implements the Aiven OpenSearch service.
package opensearch

import (
Expand Down Expand Up @@ -30,7 +31,7 @@ var aivenOpenSearchACLConfigSchema = map[string]*schema.Schema{

func ResourceOpenSearchACLConfig() *schema.Resource {
return &schema.Resource{
Description: "The OpenSearch resource allows the creation and management of Aiven OpenSearch services.",
Description: "The OpenSearch ACL Config resource allows the creation and management of Aiven OpenSearch ACLs.",
CreateContext: resourceOpenSearchACLConfigUpdate,
ReadContext: resourceOpenSearchACLConfigRead,
UpdateContext: resourceOpenSearchACLConfigUpdate,
Expand Down
Loading

0 comments on commit 9434916

Please sign in to comment.