@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
170 lines • 7.18 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.DataSource = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* * [Official documentation](https://grafana.com/docs/grafana/latest/datasources/)
* * [HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/api-legacy/data_source/)
*
* The required arguments for this resource vary depending on the type of data
* source selected (via the 'type' argument).
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as grafana from "@pulumiverse/grafana";
*
* const arbitrary_data = new grafana.oss.DataSource("arbitrary-data", {
* type: "stackdriver",
* name: "sd-arbitrary-data",
* jsonDataEncoded: JSON.stringify({
* tokenUri: "https://oauth2.googleapis.com/token",
* authenticationType: "jwt",
* defaultProject: "default-project",
* clientEmail: "client-email@default-project.iam.gserviceaccount.com",
* }),
* secureJsonDataEncoded: JSON.stringify({
* privateKey: `-----BEGIN PRIVATE KEY-----
* private-key
* -----END PRIVATE KEY-----
* `,
* }),
* });
* const influxdb = new grafana.oss.DataSource("influxdb", {
* type: "influxdb",
* name: "myapp-metrics",
* url: "http://influxdb.example.net:8086/",
* basicAuthEnabled: true,
* basicAuthUsername: "username",
* databaseName: "dbname",
* jsonDataEncoded: JSON.stringify({
* authType: "default",
* basicAuthPassword: "mypassword",
* }),
* });
* const cloudwatch = new grafana.oss.DataSource("cloudwatch", {
* type: "cloudwatch",
* name: "cw-example",
* jsonDataEncoded: JSON.stringify({
* defaultRegion: "us-east-1",
* authType: "keys",
* }),
* secureJsonDataEncoded: JSON.stringify({
* accessKey: "123",
* secretKey: "456",
* }),
* });
* const cloudwatchAssumeARN = new grafana.oss.DataSource("cloudwatch_assumeARN", {
* type: "cloudwatch",
* name: "cw-assumeARN-example",
* jsonDataEncoded: JSON.stringify({
* defaultRegion: "us-east-1",
* authType: "grafana_assume_role",
* assumeRoleArn: "arn:aws:iam::123456789012:root",
* }),
* });
* const prometheus = new grafana.oss.DataSource("prometheus", {
* type: "prometheus",
* name: "mimir",
* url: "https://my-instances.com",
* basicAuthEnabled: true,
* basicAuthUsername: "username",
* jsonDataEncoded: JSON.stringify({
* httpMethod: "POST",
* prometheusType: "Mimir",
* prometheusVersion: "2.4.0",
* }),
* secureJsonDataEncoded: JSON.stringify({
* basicAuthPassword: "password",
* }),
* });
* ```
*
* ## Import
*
* ```sh
* terraform import grafana_data_source.name "{{ uid }}"
* terraform import grafana_data_source.name "{{ orgID }}:{{ uid }}"
* ```
*/
class DataSource extends pulumi.CustomResource {
/**
* Get an existing DataSource 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 DataSource(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of DataSource. 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'] === DataSource.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["accessMode"] = state?.accessMode;
resourceInputs["basicAuthEnabled"] = state?.basicAuthEnabled;
resourceInputs["basicAuthUsername"] = state?.basicAuthUsername;
resourceInputs["databaseName"] = state?.databaseName;
resourceInputs["httpHeaders"] = state?.httpHeaders;
resourceInputs["isDefault"] = state?.isDefault;
resourceInputs["jsonDataEncoded"] = state?.jsonDataEncoded;
resourceInputs["name"] = state?.name;
resourceInputs["orgId"] = state?.orgId;
resourceInputs["privateDataSourceConnectNetworkId"] = state?.privateDataSourceConnectNetworkId;
resourceInputs["secureJsonDataEncoded"] = state?.secureJsonDataEncoded;
resourceInputs["type"] = state?.type;
resourceInputs["uid"] = state?.uid;
resourceInputs["url"] = state?.url;
resourceInputs["username"] = state?.username;
}
else {
const args = argsOrState;
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["accessMode"] = args?.accessMode;
resourceInputs["basicAuthEnabled"] = args?.basicAuthEnabled;
resourceInputs["basicAuthUsername"] = args?.basicAuthUsername;
resourceInputs["databaseName"] = args?.databaseName;
resourceInputs["httpHeaders"] = args?.httpHeaders ? pulumi.secret(args.httpHeaders) : undefined;
resourceInputs["isDefault"] = args?.isDefault;
resourceInputs["jsonDataEncoded"] = args?.jsonDataEncoded;
resourceInputs["name"] = args?.name;
resourceInputs["orgId"] = args?.orgId;
resourceInputs["privateDataSourceConnectNetworkId"] = args?.privateDataSourceConnectNetworkId;
resourceInputs["secureJsonDataEncoded"] = args?.secureJsonDataEncoded ? pulumi.secret(args.secureJsonDataEncoded) : undefined;
resourceInputs["type"] = args?.type;
resourceInputs["uid"] = args?.uid;
resourceInputs["url"] = args?.url;
resourceInputs["username"] = args?.username;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "grafana:index/dataSource:DataSource" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
const secretOpts = { additionalSecretOutputs: ["httpHeaders", "secureJsonDataEncoded"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(DataSource.__pulumiType, name, resourceInputs, opts);
}
}
exports.DataSource = DataSource;
/** @internal */
DataSource.__pulumiType = 'grafana:oss/dataSource:DataSource';
//# sourceMappingURL=dataSource.js.map