@pulumiverse/grafana
Version:
A Pulumi package for creating and managing grafana.
120 lines • 5.31 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.Installation = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Sets up Synthetic Monitoring on a Grafana cloud stack and generates a token.
* Once a Grafana Cloud stack is created, a user can either use this resource or go into the UI to install synthetic monitoring.
* This resource cannot be imported but it can be used on an existing Synthetic Monitoring installation without issues.
*
* **Note that this resource must be used on a provider configured with Grafana Cloud credentials.**
*
* * [Official documentation](https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/set-up/)
* * [API documentation](https://github.com/grafana/synthetic-monitoring-api-go-client/blob/main/docs/API.md#apiv1registerinstall)
*
* Required access policy scopes:
*
* * stacks:read
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as grafana from "@pulumiverse/grafana";
*
* const config = new pulumi.Config();
* // Cloud Access Policy token for Grafana Cloud with the following scopes: accesspolicies:read|write|delete, stacks:read|write|delete
* const cloudAccessPolicyToken = config.requireObject<any>("cloudAccessPolicyToken");
* const stackSlug = config.requireObject<any>("stackSlug");
* const cloudRegion = config.get("cloudRegion") || "prod-us-east-0";
* const smStack = new grafana.cloud.Stack("sm_stack", {
* name: stackSlug,
* slug: stackSlug,
* regionSlug: cloudRegion,
* });
* // Step 2: Install Synthetic Monitoring on the stack
* const smMetricsPublish = new grafana.cloud.AccessPolicy("sm_metrics_publish", {
* region: cloudRegion,
* name: "metric-publisher-for-sm",
* scopes: [
* "metrics:write",
* "stacks:read",
* "logs:write",
* "traces:write",
* ],
* realms: [{
* type: "stack",
* identifier: smStack.id,
* }],
* });
* const smMetricsPublishAccessPolicyToken = new grafana.cloud.AccessPolicyToken("sm_metrics_publish", {
* region: cloudRegion,
* accessPolicyId: smMetricsPublish.policyId,
* name: "metric-publisher-for-sm",
* });
* const smStackInstallation = new grafana.syntheticmonitoring.Installation("sm_stack", {
* stackId: smStack.id,
* metricsPublisherKey: smMetricsPublishAccessPolicyToken.token,
* });
* const main = grafana.syntheticMonitoring.getProbes({});
* ```
*/
class Installation extends pulumi.CustomResource {
/**
* Get an existing Installation 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 Installation(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Installation. 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'] === Installation.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["metricsPublisherKey"] = state?.metricsPublisherKey;
resourceInputs["smAccessToken"] = state?.smAccessToken;
resourceInputs["stackId"] = state?.stackId;
resourceInputs["stackSmApiUrl"] = state?.stackSmApiUrl;
}
else {
const args = argsOrState;
if (args?.metricsPublisherKey === undefined && !opts.urn) {
throw new Error("Missing required property 'metricsPublisherKey'");
}
if (args?.stackId === undefined && !opts.urn) {
throw new Error("Missing required property 'stackId'");
}
resourceInputs["metricsPublisherKey"] = args?.metricsPublisherKey ? pulumi.secret(args.metricsPublisherKey) : undefined;
resourceInputs["stackId"] = args?.stackId;
resourceInputs["stackSmApiUrl"] = args?.stackSmApiUrl;
resourceInputs["smAccessToken"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["metricsPublisherKey"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Installation.__pulumiType, name, resourceInputs, opts);
}
}
exports.Installation = Installation;
/** @internal */
Installation.__pulumiType = 'grafana:syntheticMonitoring/installation:Installation';
//# sourceMappingURL=installation.js.map