1. Packages
  2. Grafana Cloud
  3. API Docs
  4. k6
  5. Installation
Grafana v0.19.2 published on Friday, Jul 18, 2025 by pulumiverse

grafana.k6.Installation

Explore with Pulumi AI

grafana logo
Grafana v0.19.2 published on Friday, Jul 18, 2025 by pulumiverse

    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.

    Required access policy scopes:

    • stacks:read
    • stacks:write
    • subscriptions:read
    • orgs:read

    Example Usage

    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"});
    
    import pulumi
    import pulumiverse_grafana as grafana
    
    config = pulumi.Config()
    # Cloud Access Policy token for Grafana Cloud with the following scopes: stacks:read|write|delete, stack-service-accounts:write
    cloud_access_policy_token = config.require_object("cloudAccessPolicyToken")
    stack_slug = config.require_object("stackSlug")
    cloud_region = config.get("cloudRegion")
    if cloud_region is None:
        cloud_region = "us"
    k6_stack = grafana.cloud.Stack("k6_stack",
        name=stack_slug,
        slug=stack_slug,
        region_slug=cloud_region)
    # Step 2: Create a Service Account and a token to install the k6 App
    k6_sa = grafana.cloud.StackServiceAccount("k6_sa",
        stack_slug=stack_slug,
        name=f"{stack_slug}-k6-app",
        role="Admin",
        is_disabled=False)
    k6_sa_token = grafana.cloud.StackServiceAccountToken("k6_sa_token",
        stack_slug=stack_slug,
        name=f"{stack_slug}-k6-app-token",
        service_account_id=k6_sa.id)
    # Step 3: Install the k6 App on the stack
    k6_installation = grafana.k6.Installation("k6_installation",
        cloud_access_policy_token=cloud_access_policy_token,
        stack_id=k6_stack.id,
        grafana_sa_token=k6_sa_token.key,
        grafana_user="admin")
    my_k6_project = grafana.k6.Project("my_k6_project", name="k6 Project created with TF")
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/cloud"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/k6"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		// Cloud Access Policy token for Grafana Cloud with the following scopes: stacks:read|write|delete, stack-service-accounts:write
    		cloudAccessPolicyToken := cfg.RequireObject("cloudAccessPolicyToken")
    		stackSlug := cfg.RequireObject("stackSlug")
    		cloudRegion := "us"
    		if param := cfg.Get("cloudRegion"); param != "" {
    			cloudRegion = param
    		}
    		k6Stack, err := cloud.NewStack(ctx, "k6_stack", &cloud.StackArgs{
    			Name:       pulumi.Any(stackSlug),
    			Slug:       pulumi.Any(stackSlug),
    			RegionSlug: pulumi.String(cloudRegion),
    		})
    		if err != nil {
    			return err
    		}
    		// Step 2: Create a Service Account and a token to install the k6 App
    		k6Sa, err := cloud.NewStackServiceAccount(ctx, "k6_sa", &cloud.StackServiceAccountArgs{
    			StackSlug:  pulumi.Any(stackSlug),
    			Name:       pulumi.Sprintf("%v-k6-app", stackSlug),
    			Role:       pulumi.String("Admin"),
    			IsDisabled: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		k6SaToken, err := cloud.NewStackServiceAccountToken(ctx, "k6_sa_token", &cloud.StackServiceAccountTokenArgs{
    			StackSlug:        pulumi.Any(stackSlug),
    			Name:             pulumi.Sprintf("%v-k6-app-token", stackSlug),
    			ServiceAccountId: k6Sa.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// Step 3: Install the k6 App on the stack
    		_, err = k6.NewInstallation(ctx, "k6_installation", &k6.InstallationArgs{
    			CloudAccessPolicyToken: pulumi.Any(cloudAccessPolicyToken),
    			StackId:                k6Stack.ID(),
    			GrafanaSaToken:         k6SaToken.Key,
    			GrafanaUser:            pulumi.String("admin"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = k6.NewProject(ctx, "my_k6_project", &k6.ProjectArgs{
    			Name: pulumi.String("k6 Project created with TF"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        // Cloud Access Policy token for Grafana Cloud with the following scopes: stacks:read|write|delete, stack-service-accounts:write
        var cloudAccessPolicyToken = config.RequireObject<dynamic>("cloudAccessPolicyToken");
        var stackSlug = config.RequireObject<dynamic>("stackSlug");
        var cloudRegion = config.Get("cloudRegion") ?? "us";
        var k6Stack = new Grafana.Cloud.Stack("k6_stack", new()
        {
            Name = stackSlug,
            Slug = stackSlug,
            RegionSlug = cloudRegion,
        });
    
        // Step 2: Create a Service Account and a token to install the k6 App
        var k6Sa = new Grafana.Cloud.StackServiceAccount("k6_sa", new()
        {
            StackSlug = stackSlug,
            Name = $"{stackSlug}-k6-app",
            Role = "Admin",
            IsDisabled = false,
        });
    
        var k6SaToken = new Grafana.Cloud.StackServiceAccountToken("k6_sa_token", new()
        {
            StackSlug = stackSlug,
            Name = $"{stackSlug}-k6-app-token",
            ServiceAccountId = k6Sa.Id,
        });
    
        // Step 3: Install the k6 App on the stack
        var k6Installation = new Grafana.K6.Installation("k6_installation", new()
        {
            CloudAccessPolicyToken = cloudAccessPolicyToken,
            StackId = k6Stack.Id,
            GrafanaSaToken = k6SaToken.Key,
            GrafanaUser = "admin",
        });
    
        var myK6Project = new Grafana.K6.Project("my_k6_project", new()
        {
            Name = "k6 Project created with TF",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.cloud.Stack;
    import com.pulumi.grafana.cloud.StackArgs;
    import com.pulumi.grafana.cloud.StackServiceAccount;
    import com.pulumi.grafana.cloud.StackServiceAccountArgs;
    import com.pulumi.grafana.cloud.StackServiceAccountToken;
    import com.pulumi.grafana.cloud.StackServiceAccountTokenArgs;
    import com.pulumi.grafana.k6.Installation;
    import com.pulumi.grafana.k6.InstallationArgs;
    import com.pulumi.grafana.k6.Project;
    import com.pulumi.grafana.k6.ProjectArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var config = ctx.config();
            final var cloudAccessPolicyToken = config.get("cloudAccessPolicyToken");
            final var stackSlug = config.get("stackSlug");
            final var cloudRegion = config.get("cloudRegion").orElse("us");
            var k6Stack = new Stack("k6Stack", StackArgs.builder()
                .name(stackSlug)
                .slug(stackSlug)
                .regionSlug(cloudRegion)
                .build());
    
            // Step 2: Create a Service Account and a token to install the k6 App
            var k6Sa = new StackServiceAccount("k6Sa", StackServiceAccountArgs.builder()
                .stackSlug(stackSlug)
                .name(String.format("%s-k6-app", stackSlug))
                .role("Admin")
                .isDisabled(false)
                .build());
    
            var k6SaToken = new StackServiceAccountToken("k6SaToken", StackServiceAccountTokenArgs.builder()
                .stackSlug(stackSlug)
                .name(String.format("%s-k6-app-token", stackSlug))
                .serviceAccountId(k6Sa.id())
                .build());
    
            // Step 3: Install the k6 App on the stack
            var k6Installation = new Installation("k6Installation", InstallationArgs.builder()
                .cloudAccessPolicyToken(cloudAccessPolicyToken)
                .stackId(k6Stack.id())
                .grafanaSaToken(k6SaToken.key())
                .grafanaUser("admin")
                .build());
    
            var myK6Project = new Project("myK6Project", ProjectArgs.builder()
                .name("k6 Project created with TF")
                .build());
    
        }
    }
    
    configuration:
      cloudAccessPolicyToken:
        type: dynamic
      stackSlug:
        type: dynamic
      cloudRegion:
        type: string
        default: us
    resources:
      k6Stack:
        type: grafana:cloud:Stack
        name: k6_stack
        properties:
          name: ${stackSlug}
          slug: ${stackSlug}
          regionSlug: ${cloudRegion}
      # Step 2: Create a Service Account and a token to install the k6 App
      k6Sa:
        type: grafana:cloud:StackServiceAccount
        name: k6_sa
        properties:
          stackSlug: ${stackSlug}
          name: ${stackSlug}-k6-app
          role: Admin
          isDisabled: false
      k6SaToken:
        type: grafana:cloud:StackServiceAccountToken
        name: k6_sa_token
        properties:
          stackSlug: ${stackSlug}
          name: ${stackSlug}-k6-app-token
          serviceAccountId: ${k6Sa.id}
      # Step 3: Install the k6 App on the stack
      k6Installation:
        type: grafana:k6:Installation
        name: k6_installation
        properties:
          cloudAccessPolicyToken: ${cloudAccessPolicyToken}
          stackId: ${k6Stack.id}
          grafanaSaToken: ${k6SaToken.key}
          grafanaUser: admin
      myK6Project:
        type: grafana:k6:Project
        name: my_k6_project
        properties:
          name: k6 Project created with TF
    

    Create Installation Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Installation(name: string, args: InstallationArgs, opts?: CustomResourceOptions);
    @overload
    def Installation(resource_name: str,
                     args: InstallationArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def Installation(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     cloud_access_policy_token: Optional[str] = None,
                     grafana_sa_token: Optional[str] = None,
                     grafana_user: Optional[str] = None,
                     stack_id: Optional[str] = None)
    func NewInstallation(ctx *Context, name string, args InstallationArgs, opts ...ResourceOption) (*Installation, error)
    public Installation(string name, InstallationArgs args, CustomResourceOptions? opts = null)
    public Installation(String name, InstallationArgs args)
    public Installation(String name, InstallationArgs args, CustomResourceOptions options)
    
    type: grafana:k6:Installation
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args InstallationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args InstallationArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args InstallationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InstallationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InstallationArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var installationResource = new Grafana.K6.Installation("installationResource", new()
    {
        CloudAccessPolicyToken = "string",
        GrafanaSaToken = "string",
        GrafanaUser = "string",
        StackId = "string",
    });
    
    example, err := k6.NewInstallation(ctx, "installationResource", &k6.InstallationArgs{
    	CloudAccessPolicyToken: pulumi.String("string"),
    	GrafanaSaToken:         pulumi.String("string"),
    	GrafanaUser:            pulumi.String("string"),
    	StackId:                pulumi.String("string"),
    })
    
    var installationResource = new com.pulumi.grafana.k6.Installation("installationResource", com.pulumi.grafana.k6.InstallationArgs.builder()
        .cloudAccessPolicyToken("string")
        .grafanaSaToken("string")
        .grafanaUser("string")
        .stackId("string")
        .build());
    
    installation_resource = grafana.k6.Installation("installationResource",
        cloud_access_policy_token="string",
        grafana_sa_token="string",
        grafana_user="string",
        stack_id="string")
    
    const installationResource = new grafana.k6.Installation("installationResource", {
        cloudAccessPolicyToken: "string",
        grafanaSaToken: "string",
        grafanaUser: "string",
        stackId: "string",
    });
    
    type: grafana:k6:Installation
    properties:
        cloudAccessPolicyToken: string
        grafanaSaToken: string
        grafanaUser: string
        stackId: string
    

    Installation Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Installation resource accepts the following input properties:

    CloudAccessPolicyToken string
    The Grafana Cloud access policy.
    GrafanaSaToken string
    The service account token.
    GrafanaUser string
    The user to use for the installation.
    StackId string
    The identifier of the stack to install k6 on.
    CloudAccessPolicyToken string
    The Grafana Cloud access policy.
    GrafanaSaToken string
    The service account token.
    GrafanaUser string
    The user to use for the installation.
    StackId string
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken String
    The Grafana Cloud access policy.
    grafanaSaToken String
    The service account token.
    grafanaUser String
    The user to use for the installation.
    stackId String
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken string
    The Grafana Cloud access policy.
    grafanaSaToken string
    The service account token.
    grafanaUser string
    The user to use for the installation.
    stackId string
    The identifier of the stack to install k6 on.
    cloud_access_policy_token str
    The Grafana Cloud access policy.
    grafana_sa_token str
    The service account token.
    grafana_user str
    The user to use for the installation.
    stack_id str
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken String
    The Grafana Cloud access policy.
    grafanaSaToken String
    The service account token.
    grafanaUser String
    The user to use for the installation.
    stackId String
    The identifier of the stack to install k6 on.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Installation resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    K6AccessToken string
    Generated token to access the k6 API.
    K6Organization string
    The identifier of the k6 organization.
    Id string
    The provider-assigned unique ID for this managed resource.
    K6AccessToken string
    Generated token to access the k6 API.
    K6Organization string
    The identifier of the k6 organization.
    id String
    The provider-assigned unique ID for this managed resource.
    k6AccessToken String
    Generated token to access the k6 API.
    k6Organization String
    The identifier of the k6 organization.
    id string
    The provider-assigned unique ID for this managed resource.
    k6AccessToken string
    Generated token to access the k6 API.
    k6Organization string
    The identifier of the k6 organization.
    id str
    The provider-assigned unique ID for this managed resource.
    k6_access_token str
    Generated token to access the k6 API.
    k6_organization str
    The identifier of the k6 organization.
    id String
    The provider-assigned unique ID for this managed resource.
    k6AccessToken String
    Generated token to access the k6 API.
    k6Organization String
    The identifier of the k6 organization.

    Look up Existing Installation Resource

    Get an existing Installation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: InstallationState, opts?: CustomResourceOptions): Installation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cloud_access_policy_token: Optional[str] = None,
            grafana_sa_token: Optional[str] = None,
            grafana_user: Optional[str] = None,
            k6_access_token: Optional[str] = None,
            k6_organization: Optional[str] = None,
            stack_id: Optional[str] = None) -> Installation
    func GetInstallation(ctx *Context, name string, id IDInput, state *InstallationState, opts ...ResourceOption) (*Installation, error)
    public static Installation Get(string name, Input<string> id, InstallationState? state, CustomResourceOptions? opts = null)
    public static Installation get(String name, Output<String> id, InstallationState state, CustomResourceOptions options)
    resources:  _:    type: grafana:k6:Installation    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    CloudAccessPolicyToken string
    The Grafana Cloud access policy.
    GrafanaSaToken string
    The service account token.
    GrafanaUser string
    The user to use for the installation.
    K6AccessToken string
    Generated token to access the k6 API.
    K6Organization string
    The identifier of the k6 organization.
    StackId string
    The identifier of the stack to install k6 on.
    CloudAccessPolicyToken string
    The Grafana Cloud access policy.
    GrafanaSaToken string
    The service account token.
    GrafanaUser string
    The user to use for the installation.
    K6AccessToken string
    Generated token to access the k6 API.
    K6Organization string
    The identifier of the k6 organization.
    StackId string
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken String
    The Grafana Cloud access policy.
    grafanaSaToken String
    The service account token.
    grafanaUser String
    The user to use for the installation.
    k6AccessToken String
    Generated token to access the k6 API.
    k6Organization String
    The identifier of the k6 organization.
    stackId String
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken string
    The Grafana Cloud access policy.
    grafanaSaToken string
    The service account token.
    grafanaUser string
    The user to use for the installation.
    k6AccessToken string
    Generated token to access the k6 API.
    k6Organization string
    The identifier of the k6 organization.
    stackId string
    The identifier of the stack to install k6 on.
    cloud_access_policy_token str
    The Grafana Cloud access policy.
    grafana_sa_token str
    The service account token.
    grafana_user str
    The user to use for the installation.
    k6_access_token str
    Generated token to access the k6 API.
    k6_organization str
    The identifier of the k6 organization.
    stack_id str
    The identifier of the stack to install k6 on.
    cloudAccessPolicyToken String
    The Grafana Cloud access policy.
    grafanaSaToken String
    The service account token.
    grafanaUser String
    The user to use for the installation.
    k6AccessToken String
    Generated token to access the k6 API.
    k6Organization String
    The identifier of the k6 organization.
    stackId String
    The identifier of the stack to install k6 on.

    Package Details

    Repository
    grafana pulumiverse/pulumi-grafana
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the grafana Terraform Provider.
    grafana logo
    Grafana v0.19.2 published on Friday, Jul 18, 2025 by pulumiverse