Skip to content

Commit

Permalink
refactor(aiven_service_integration_endpoint): new user configs
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Feb 27, 2024
1 parent 7d5dd47 commit ece182a
Show file tree
Hide file tree
Showing 20 changed files with 725 additions and 63 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nav_order: 1
<!-- TODO: uncomment when dragonfly is supported -->
<!-- - Dragonfly support -->

- Use new user config generator to generate service integration configs
- Use new user config generator to generate service integration and service integration endpoint configs
- Fix `aiven_kafka_schema` version update
- Add `external_aws_cloudwatch_logs`, `external_elasticsearch_logs_user_config`, `external_opensearch_logs_user_config`,
`prometheus_user_config` service integration configs
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/service_integration_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data "aiven_service_integration_endpoint" "myendpoint" {

- `datadog_user_config` (List of Object) Datadog user configurable settings (see [below for nested schema](#nestedatt--datadog_user_config))
- `endpoint_config` (Map of String) Integration endpoint specific backend configuration
- `endpoint_type` (String) Type of the service integration endpoint. Possible values: `datadog`, `prometheus`, `rsyslog`, `external_elasticsearch_logs`, `external_opensearch_logs`, `external_aws_cloudwatch_logs`, `external_google_cloud_logging`, `external_kafka`, `jolokia`, `external_schema_registry`, `external_aws_cloudwatch_metrics`, `external_google_cloud_bigquery`, `external_postgresql`
- `endpoint_type` (String) Type of the service integration endpoint. Possible values: `autoscaler`, `datadog`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_aws_s3`, `external_clickhouse`, `external_elasticsearch_logs`, `external_google_cloud_bigquery`, `external_google_cloud_logging`, `external_kafka`, `external_mysql`, `external_opensearch_logs`, `external_postgresql`, `external_redis`, `external_schema_registry`, `jolokia`, `prometheus`, `rsyslog`
- `external_aws_cloudwatch_logs_user_config` (List of Object) ExternalAwsCloudwatchLogs user configurable settings (see [below for nested schema](#nestedatt--external_aws_cloudwatch_logs_user_config))
- `external_aws_cloudwatch_metrics_user_config` (List of Object) ExternalAwsCloudwatchMetrics user configurable settings (see [below for nested schema](#nestedatt--external_aws_cloudwatch_metrics_user_config))
- `external_elasticsearch_logs_user_config` (List of Object) ExternalElasticsearchLogs user configurable settings (see [below for nested schema](#nestedatt--external_elasticsearch_logs_user_config))
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/service_integration_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Service Integration Endpoint resource allows the creation and management of
### Required

- `endpoint_name` (String) Name of the service integration endpoint
- `endpoint_type` (String) Type of the service integration endpoint. Possible values: `datadog`, `prometheus`, `rsyslog`, `external_elasticsearch_logs`, `external_opensearch_logs`, `external_aws_cloudwatch_logs`, `external_google_cloud_logging`, `external_kafka`, `jolokia`, `external_schema_registry`, `external_aws_cloudwatch_metrics`, `external_google_cloud_bigquery`, `external_postgresql`
- `endpoint_type` (String) Type of the service integration endpoint. Possible values: `autoscaler`, `datadog`, `external_aws_cloudwatch_logs`, `external_aws_cloudwatch_metrics`, `external_aws_s3`, `external_clickhouse`, `external_elasticsearch_logs`, `external_google_cloud_bigquery`, `external_google_cloud_logging`, `external_kafka`, `external_mysql`, `external_opensearch_logs`, `external_postgresql`, `external_redis`, `external_schema_registry`, `jolokia`, `prometheus`, `rsyslog`
- `project` (String) Project the service integration endpoint belongs to

### Optional
Expand Down Expand Up @@ -52,7 +52,7 @@ Required:

Optional:

- `datadog_tags` (Block List, Max: 32) Custom tags provided by user. (see [below for nested schema](#nestedblock--datadog_user_config--datadog_tags))
- `datadog_tags` (Block List, Max: 32) Custom tags provided by user (see [below for nested schema](#nestedblock--datadog_user_config--datadog_tags))
- `disable_consumer_stats` (Boolean) Disable consumer group metrics.
- `kafka_consumer_check_instances` (Number) Number of separate instances to fetch kafka consumer statistics with.
- `kafka_consumer_stats_timeout` (Number) Number of seconds that datadog will wait to get consumer statistics from brokers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/aiven/aiven-go-client/v2"
codegenintegrations "github.com/aiven/go-client-codegen/handler/serviceintegration"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand All @@ -13,66 +14,51 @@ import (
"github.com/aiven/terraform-provider-aiven/internal/schemautil"
"github.com/aiven/terraform-provider-aiven/internal/schemautil/userconfig"
"github.com/aiven/terraform-provider-aiven/internal/schemautil/userconfig/apiconvert"
"github.com/aiven/terraform-provider-aiven/internal/schemautil/userconfig/dist"
"github.com/aiven/terraform-provider-aiven/internal/schemautil/userconfig/stateupgrader"
"github.com/aiven/terraform-provider-aiven/internal/sdkprovider/userconfig/serviceintegrationendpoint"
)

var integrationEndpointTypes = []string{
"datadog",
"prometheus",
"rsyslog",
"external_elasticsearch_logs",
"external_opensearch_logs",
"external_aws_cloudwatch_logs",
"external_google_cloud_logging",
"external_kafka",
"jolokia",
"external_schema_registry",
"external_aws_cloudwatch_metrics",
"external_google_cloud_bigquery",
"external_postgresql",
}
func aivenServiceIntegrationEndpointSchema() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"project": {
Description: "Project the service integration endpoint belongs to",
ForceNew: true,
Required: true,
Type: schema.TypeString,
},
"endpoint_name": {
ForceNew: true,
Description: "Name of the service integration endpoint",
Required: true,
Type: schema.TypeString,
},
"endpoint_type": {
Description: "Type of the service integration endpoint. Possible values: " +
schemautil.JoinQuoted(codegenintegrations.EndpointTypeChoices(), ", ", "`"),
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(codegenintegrations.EndpointTypeChoices(), false),
},
"endpoint_config": {
Description: "Integration endpoint specific backend configuration",
Computed: true,
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
},
}

var aivenServiceIntegrationEndpointSchema = map[string]*schema.Schema{
"project": {
Description: "Project the service integration endpoint belongs to",
ForceNew: true,
Required: true,
Type: schema.TypeString,
},
"endpoint_name": {
ForceNew: true,
Description: "Name of the service integration endpoint",
Required: true,
Type: schema.TypeString,
},
"endpoint_type": {
Description: "Type of the service integration endpoint. Possible values: " +
schemautil.JoinQuoted(integrationEndpointTypes, ", ", "`"),
ForceNew: true,
Required: true,
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(integrationEndpointTypes, false),
},
"endpoint_config": {
Description: "Integration endpoint specific backend configuration",
Computed: true,
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeString},
},
"datadog_user_config": dist.IntegrationEndpointTypeDatadog(),
"prometheus_user_config": dist.IntegrationEndpointTypePrometheus(),
"rsyslog_user_config": dist.IntegrationEndpointTypeRsyslog(),
"external_elasticsearch_logs_user_config": dist.IntegrationEndpointTypeExternalElasticsearchLogs(),
"external_opensearch_logs_user_config": dist.IntegrationEndpointTypeExternalOpensearchLogs(),
"external_aws_cloudwatch_logs_user_config": dist.IntegrationEndpointTypeExternalAwsCloudwatchLogs(),
"external_google_cloud_logging_user_config": dist.IntegrationEndpointTypeExternalGoogleCloudLogging(),
"external_kafka_user_config": dist.IntegrationEndpointTypeExternalKafka(),
"jolokia_user_config": dist.IntegrationEndpointTypeJolokia(),
"external_schema_registry_user_config": dist.IntegrationEndpointTypeExternalSchemaRegistry(),
"external_aws_cloudwatch_metrics_user_config": dist.IntegrationEndpointTypeExternalAwsCloudwatchMetrics(),
"external_google_cloud_bigquery": dist.IntegrationEndpointTypeExternalGoogleCloudBigquery(),
"external_postgresql": dist.IntegrationEndpointTypeExternalPostgresql(),
// Adds user configs
for _, k := range serviceintegrationendpoint.UserConfigTypes() {
key := k + "_user_config"
switch k {
case "external_google_cloud_bigquery", "external_postgresql":
// legacy fields
key = k
}
s[key] = serviceintegrationendpoint.GetUserConfig(k)
}
return s
}

func ResourceServiceIntegrationEndpoint() *schema.Resource {
Expand All @@ -87,7 +73,7 @@ func ResourceServiceIntegrationEndpoint() *schema.Resource {
},
Timeouts: schemautil.DefaultResourceTimeouts(),

Schema: aivenServiceIntegrationEndpointSchema,
Schema: aivenServiceIntegrationEndpointSchema(),
SchemaVersion: 1,
StateUpgraders: stateupgrader.ServiceIntegrationEndpoint(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func DatasourceServiceIntegrationEndpoint() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceServiceIntegrationEndpointRead,
Description: "The Service Integration Endpoint data source provides information about the existing Aiven Service Integration Endpoint.",
Schema: schemautil.ResourceSchemaAsDatasourceSchema(aivenServiceIntegrationEndpointSchema,
Schema: schemautil.ResourceSchemaAsDatasourceSchema(aivenServiceIntegrationEndpointSchema(),
"project", "endpoint_name"),
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ece182a

Please sign in to comment.