UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

130 lines 5.89 kB
"use strict"; // *** 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 the k6 App on a Grafana Cloud instance 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 k6. * This resource cannot be imported but it can be used on an existing k6 App 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/k6/) * * Required access policy scopes: * * * stacks:read * * stacks:write * * subscriptions:read * * orgs:read * * stack-service-accounts:write * * ## 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: stacks:read|write|delete, stack-service-accounts:write * const cloudAccessPolicyToken = config.requireObject<any>("cloudAccessPolicyToken"); * const stackSlug = config.requireObject<any>("stackSlug"); * const cloudRegion = config.get("cloudRegion") || "us"; * const k6Stack = new grafana.cloud.Stack("k6_stack", { * name: stackSlug, * slug: stackSlug, * regionSlug: cloudRegion, * }); * // Step 2: Create a Service Account and a token to install the k6 App * const k6Sa = new grafana.cloud.StackServiceAccount("k6_sa", { * stackSlug: stackSlug, * name: `${stackSlug}-k6-app`, * role: "Admin", * isDisabled: false, * }); * const k6SaToken = new grafana.cloud.StackServiceAccountToken("k6_sa_token", { * stackSlug: stackSlug, * name: `${stackSlug}-k6-app-token`, * serviceAccountId: k6Sa.id, * }); * // Step 3: Install the k6 App on the stack * const k6Installation = new grafana.k6.Installation("k6_installation", { * cloudAccessPolicyToken: cloudAccessPolicyToken, * stackId: k6Stack.id, * grafanaSaToken: k6SaToken.key, * grafanaUser: "admin", * }); * const myK6Project = new grafana.k6.Project("my_k6_project", {name: "k6 Project created with TF"}); * ``` */ 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["cloudAccessPolicyToken"] = state?.cloudAccessPolicyToken; resourceInputs["grafanaSaToken"] = state?.grafanaSaToken; resourceInputs["grafanaUser"] = state?.grafanaUser; resourceInputs["k6AccessToken"] = state?.k6AccessToken; resourceInputs["k6ApiUrl"] = state?.k6ApiUrl; resourceInputs["k6Organization"] = state?.k6Organization; resourceInputs["stackId"] = state?.stackId; } else { const args = argsOrState; if (args?.cloudAccessPolicyToken === undefined && !opts.urn) { throw new Error("Missing required property 'cloudAccessPolicyToken'"); } if (args?.grafanaSaToken === undefined && !opts.urn) { throw new Error("Missing required property 'grafanaSaToken'"); } if (args?.grafanaUser === undefined && !opts.urn) { throw new Error("Missing required property 'grafanaUser'"); } if (args?.stackId === undefined && !opts.urn) { throw new Error("Missing required property 'stackId'"); } resourceInputs["cloudAccessPolicyToken"] = args?.cloudAccessPolicyToken ? pulumi.secret(args.cloudAccessPolicyToken) : undefined; resourceInputs["grafanaSaToken"] = args?.grafanaSaToken ? pulumi.secret(args.grafanaSaToken) : undefined; resourceInputs["grafanaUser"] = args?.grafanaUser; resourceInputs["k6ApiUrl"] = args?.k6ApiUrl; resourceInputs["stackId"] = args?.stackId; resourceInputs["k6AccessToken"] = undefined /*out*/; resourceInputs["k6Organization"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["cloudAccessPolicyToken", "grafanaSaToken", "k6AccessToken"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Installation.__pulumiType, name, resourceInputs, opts); } } exports.Installation = Installation; /** @internal */ Installation.__pulumiType = 'grafana:k6/installation:Installation'; //# sourceMappingURL=installation.js.map