@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
192 lines • 8.06 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseLogsinkOpensearch = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a DigitalOcean database logsink resource allowing you to forward logs from a managed database cluster to an external OpenSearch cluster or Elasticsearch endpoint.
*
* This resource is compatible with both OpenSearch and Elasticsearch endpoints due to API compatibility. You can use this resource to connect to either service.
*
* This resource supports the following DigitalOcean managed database engines:
*
* * PostgreSQL
* * MySQL
* * Kafka
* * Valkey
*
* **Note**: MongoDB databases use a different log forwarding mechanism and require Datadog logsinks (not currently available in this provider).
*
* ## Example Usage
*
* ### Basic OpenSearch configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const postgres_example = new digitalocean.DatabaseCluster("postgres-example", {
* name: "example-postgres-cluster",
* engine: "pg",
* version: "15",
* size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
* region: digitalocean.Region.NYC1,
* nodeCount: 1,
* });
* const example = new digitalocean.DatabaseLogsinkOpensearch("example", {
* clusterId: postgres_example.id,
* name: "opensearch-logs",
* endpoint: "https://opensearch.example.com:9200",
* indexPrefix: "db-logs",
* indexDaysMax: 7,
* });
* ```
*
* ### OpenSearch with authentication and CA certificate
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* import * as std from "@pulumi/std";
*
* const example_secure = new digitalocean.DatabaseLogsinkOpensearch("example-secure", {
* clusterId: postgres_example.id,
* name: "opensearch-secure",
* endpoint: "https://user:password@opensearch.example.com:9200",
* indexPrefix: "secure-logs",
* indexDaysMax: 14,
* caCert: std.file({
* input: "/path/to/ca.pem",
* }).then(invoke => invoke.result),
* timeoutSeconds: 30,
* });
* ```
*
* ### Elasticsearch endpoint configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const elasticsearch = new digitalocean.DatabaseLogsinkOpensearch("elasticsearch", {
* clusterId: postgres_example.id,
* name: "elasticsearch-logs",
* endpoint: "https://elasticsearch.example.com:9243",
* indexPrefix: "es-logs",
* indexDaysMax: 30,
* });
* ```
*
* ### MySQL to OpenSearch configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
*
* const mysql_example = new digitalocean.DatabaseCluster("mysql-example", {
* name: "example-mysql-cluster",
* engine: "mysql",
* version: "8",
* size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
* region: digitalocean.Region.NYC1,
* nodeCount: 1,
* });
* const mysql = new digitalocean.DatabaseLogsinkOpensearch("mysql", {
* clusterId: mysql_example.id,
* name: "mysql-logs",
* endpoint: "https://opensearch.example.com:9200",
* indexPrefix: "mysql-logs",
* indexDaysMax: 7,
* });
* ```
*
* ## Important Notes
*
* ### Elasticsearch Compatibility
* This resource works with both OpenSearch and Elasticsearch endpoints due to their API compatibility. Use the same resource type regardless of whether you're connecting to OpenSearch or Elasticsearch.
*
* ### Managed OpenSearch with Trusted Sources
* When forwarding logs to a DigitalOcean Managed OpenSearch cluster with trusted sources enabled, you must manually allow-list the IP addresses of your database cluster nodes.
*
* ### Authentication
* Include authentication credentials directly in the endpoint URL using the format `https://username:password@host:port`. Alternatively, configure authentication on your OpenSearch/Elasticsearch cluster to accept connections from your database cluster's IP addresses.
*
* ## Import
*
* Database logsink OpenSearch resources can be imported using the composite ID format `cluster_id,logsink_id`. For example:
*
* ```sh
* $ pulumi import digitalocean:index/databaseLogsinkOpensearch:DatabaseLogsinkOpensearch example 245bcfd0-7f31-4ce6-a2bc-475a116cca97,f38db7c8-1f31-4ce6-a2bc-475a116cca97
* ```
*
* **Note**: The cluster ID and logsink ID must be separated by a comma.
*/
class DatabaseLogsinkOpensearch extends pulumi.CustomResource {
/**
* Get an existing DatabaseLogsinkOpensearch resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new DatabaseLogsinkOpensearch(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of DatabaseLogsinkOpensearch. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === DatabaseLogsinkOpensearch.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["caCert"] = state?.caCert;
resourceInputs["clusterId"] = state?.clusterId;
resourceInputs["endpoint"] = state?.endpoint;
resourceInputs["indexDaysMax"] = state?.indexDaysMax;
resourceInputs["indexPrefix"] = state?.indexPrefix;
resourceInputs["logsinkId"] = state?.logsinkId;
resourceInputs["name"] = state?.name;
resourceInputs["timeoutSeconds"] = state?.timeoutSeconds;
}
else {
const args = argsOrState;
if (args?.clusterId === undefined && !opts.urn) {
throw new Error("Missing required property 'clusterId'");
}
if (args?.endpoint === undefined && !opts.urn) {
throw new Error("Missing required property 'endpoint'");
}
if (args?.indexPrefix === undefined && !opts.urn) {
throw new Error("Missing required property 'indexPrefix'");
}
resourceInputs["caCert"] = args?.caCert ? pulumi.secret(args.caCert) : undefined;
resourceInputs["clusterId"] = args?.clusterId;
resourceInputs["endpoint"] = args?.endpoint;
resourceInputs["indexDaysMax"] = args?.indexDaysMax;
resourceInputs["indexPrefix"] = args?.indexPrefix;
resourceInputs["name"] = args?.name;
resourceInputs["timeoutSeconds"] = args?.timeoutSeconds;
resourceInputs["logsinkId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["caCert"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(DatabaseLogsinkOpensearch.__pulumiType, name, resourceInputs, opts);
}
}
exports.DatabaseLogsinkOpensearch = DatabaseLogsinkOpensearch;
/** @internal */
DatabaseLogsinkOpensearch.__pulumiType = 'digitalocean:index/databaseLogsinkOpensearch:DatabaseLogsinkOpensearch';
//# sourceMappingURL=databaseLogsinkOpensearch.js.map