grafana.ServiceAccountToken
Explore with Pulumi AI
Note: This resource is available only with Grafana 9.1+.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const test = new grafana.oss.ServiceAccount("test", {
    name: "test-service-account",
    role: "Viewer",
});
const foo = new grafana.oss.ServiceAccountToken("foo", {
    name: "key_foo",
    serviceAccountId: test.id,
});
const bar = new grafana.oss.ServiceAccountToken("bar", {
    name: "key_bar",
    serviceAccountId: test.id,
    secondsToLive: 30,
});
export const serviceAccountTokenFooKeyOnly = foo.key;
export const serviceAccountTokenBar = bar;
import pulumi
import pulumiverse_grafana as grafana
test = grafana.oss.ServiceAccount("test",
    name="test-service-account",
    role="Viewer")
foo = grafana.oss.ServiceAccountToken("foo",
    name="key_foo",
    service_account_id=test.id)
bar = grafana.oss.ServiceAccountToken("bar",
    name="key_bar",
    service_account_id=test.id,
    seconds_to_live=30)
pulumi.export("serviceAccountTokenFooKeyOnly", foo.key)
pulumi.export("serviceAccountTokenBar", bar)
package main
import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := oss.NewServiceAccount(ctx, "test", &oss.ServiceAccountArgs{
			Name: pulumi.String("test-service-account"),
			Role: pulumi.String("Viewer"),
		})
		if err != nil {
			return err
		}
		foo, err := oss.NewServiceAccountToken(ctx, "foo", &oss.ServiceAccountTokenArgs{
			Name:             pulumi.String("key_foo"),
			ServiceAccountId: test.ID(),
		})
		if err != nil {
			return err
		}
		bar, err := oss.NewServiceAccountToken(ctx, "bar", &oss.ServiceAccountTokenArgs{
			Name:             pulumi.String("key_bar"),
			ServiceAccountId: test.ID(),
			SecondsToLive:    pulumi.Int(30),
		})
		if err != nil {
			return err
		}
		ctx.Export("serviceAccountTokenFooKeyOnly", foo.Key)
		ctx.Export("serviceAccountTokenBar", bar)
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Grafana = Pulumiverse.Grafana;
return await Deployment.RunAsync(() => 
{
    var test = new Grafana.Oss.ServiceAccount("test", new()
    {
        Name = "test-service-account",
        Role = "Viewer",
    });
    var foo = new Grafana.Oss.ServiceAccountToken("foo", new()
    {
        Name = "key_foo",
        ServiceAccountId = test.Id,
    });
    var bar = new Grafana.Oss.ServiceAccountToken("bar", new()
    {
        Name = "key_bar",
        ServiceAccountId = test.Id,
        SecondsToLive = 30,
    });
    return new Dictionary<string, object?>
    {
        ["serviceAccountTokenFooKeyOnly"] = foo.Key,
        ["serviceAccountTokenBar"] = bar,
    };
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.oss.ServiceAccount;
import com.pulumi.grafana.oss.ServiceAccountArgs;
import com.pulumi.grafana.oss.ServiceAccountToken;
import com.pulumi.grafana.oss.ServiceAccountTokenArgs;
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) {
        var test = new ServiceAccount("test", ServiceAccountArgs.builder()
            .name("test-service-account")
            .role("Viewer")
            .build());
        var foo = new ServiceAccountToken("foo", ServiceAccountTokenArgs.builder()
            .name("key_foo")
            .serviceAccountId(test.id())
            .build());
        var bar = new ServiceAccountToken("bar", ServiceAccountTokenArgs.builder()
            .name("key_bar")
            .serviceAccountId(test.id())
            .secondsToLive(30)
            .build());
        ctx.export("serviceAccountTokenFooKeyOnly", foo.key());
        ctx.export("serviceAccountTokenBar", bar);
    }
}
resources:
  test:
    type: grafana:oss:ServiceAccount
    properties:
      name: test-service-account
      role: Viewer
  foo:
    type: grafana:oss:ServiceAccountToken
    properties:
      name: key_foo
      serviceAccountId: ${test.id}
  bar:
    type: grafana:oss:ServiceAccountToken
    properties:
      name: key_bar
      serviceAccountId: ${test.id}
      secondsToLive: 30
outputs:
  serviceAccountTokenFooKeyOnly: ${foo.key}
  serviceAccountTokenBar: ${bar}
Create ServiceAccountToken Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ServiceAccountToken(name: string, args: ServiceAccountTokenArgs, opts?: CustomResourceOptions);@overload
def ServiceAccountToken(resource_name: str,
                        args: ServiceAccountTokenArgs,
                        opts: Optional[ResourceOptions] = None)
@overload
def ServiceAccountToken(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        name: Optional[str] = None,
                        seconds_to_live: Optional[int] = None,
                        service_account_id: Optional[str] = None)func NewServiceAccountToken(ctx *Context, name string, args ServiceAccountTokenArgs, opts ...ResourceOption) (*ServiceAccountToken, error)public ServiceAccountToken(string name, ServiceAccountTokenArgs args, CustomResourceOptions? opts = null)
public ServiceAccountToken(String name, ServiceAccountTokenArgs args)
public ServiceAccountToken(String name, ServiceAccountTokenArgs args, CustomResourceOptions options)
type: grafana:ServiceAccountToken
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 ServiceAccountTokenArgs
- 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 ServiceAccountTokenArgs
- 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 ServiceAccountTokenArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServiceAccountTokenArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ServiceAccountTokenArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ServiceAccountToken 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 ServiceAccountToken resource accepts the following input properties:
- ServiceAccount stringId 
- The ID of the service account to which the token belongs.
- Name string
- The name of the service account token.
- SecondsTo intLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- ServiceAccount stringId 
- The ID of the service account to which the token belongs.
- Name string
- The name of the service account token.
- SecondsTo intLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount StringId 
- The ID of the service account to which the token belongs.
- name String
- The name of the service account token.
- secondsTo IntegerLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount stringId 
- The ID of the service account to which the token belongs.
- name string
- The name of the service account token.
- secondsTo numberLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- service_account_ strid 
- The ID of the service account to which the token belongs.
- name str
- The name of the service account token.
- seconds_to_ intlive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount StringId 
- The ID of the service account to which the token belongs.
- name String
- The name of the service account token.
- secondsTo NumberLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
Outputs
All input properties are implicitly available as output properties. Additionally, the ServiceAccountToken resource produces the following output properties:
- Expiration string
- The expiration date of the service account token.
- HasExpired bool
- The status of the service account token.
- Id string
- The provider-assigned unique ID for this managed resource.
- Key string
- The key of the service account token.
- Expiration string
- The expiration date of the service account token.
- HasExpired bool
- The status of the service account token.
- Id string
- The provider-assigned unique ID for this managed resource.
- Key string
- The key of the service account token.
- expiration String
- The expiration date of the service account token.
- hasExpired Boolean
- The status of the service account token.
- id String
- The provider-assigned unique ID for this managed resource.
- key String
- The key of the service account token.
- expiration string
- The expiration date of the service account token.
- hasExpired boolean
- The status of the service account token.
- id string
- The provider-assigned unique ID for this managed resource.
- key string
- The key of the service account token.
- expiration str
- The expiration date of the service account token.
- has_expired bool
- The status of the service account token.
- id str
- The provider-assigned unique ID for this managed resource.
- key str
- The key of the service account token.
- expiration String
- The expiration date of the service account token.
- hasExpired Boolean
- The status of the service account token.
- id String
- The provider-assigned unique ID for this managed resource.
- key String
- The key of the service account token.
Look up Existing ServiceAccountToken Resource
Get an existing ServiceAccountToken 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?: ServiceAccountTokenState, opts?: CustomResourceOptions): ServiceAccountToken@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        expiration: Optional[str] = None,
        has_expired: Optional[bool] = None,
        key: Optional[str] = None,
        name: Optional[str] = None,
        seconds_to_live: Optional[int] = None,
        service_account_id: Optional[str] = None) -> ServiceAccountTokenfunc GetServiceAccountToken(ctx *Context, name string, id IDInput, state *ServiceAccountTokenState, opts ...ResourceOption) (*ServiceAccountToken, error)public static ServiceAccountToken Get(string name, Input<string> id, ServiceAccountTokenState? state, CustomResourceOptions? opts = null)public static ServiceAccountToken get(String name, Output<String> id, ServiceAccountTokenState state, CustomResourceOptions options)resources:  _:    type: grafana:ServiceAccountToken    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.
- Expiration string
- The expiration date of the service account token.
- HasExpired bool
- The status of the service account token.
- Key string
- The key of the service account token.
- Name string
- The name of the service account token.
- SecondsTo intLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- ServiceAccount stringId 
- The ID of the service account to which the token belongs.
- Expiration string
- The expiration date of the service account token.
- HasExpired bool
- The status of the service account token.
- Key string
- The key of the service account token.
- Name string
- The name of the service account token.
- SecondsTo intLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- ServiceAccount stringId 
- The ID of the service account to which the token belongs.
- expiration String
- The expiration date of the service account token.
- hasExpired Boolean
- The status of the service account token.
- key String
- The key of the service account token.
- name String
- The name of the service account token.
- secondsTo IntegerLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount StringId 
- The ID of the service account to which the token belongs.
- expiration string
- The expiration date of the service account token.
- hasExpired boolean
- The status of the service account token.
- key string
- The key of the service account token.
- name string
- The name of the service account token.
- secondsTo numberLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount stringId 
- The ID of the service account to which the token belongs.
- expiration str
- The expiration date of the service account token.
- has_expired bool
- The status of the service account token.
- key str
- The key of the service account token.
- name str
- The name of the service account token.
- seconds_to_ intlive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- service_account_ strid 
- The ID of the service account to which the token belongs.
- expiration String
- The expiration date of the service account token.
- hasExpired Boolean
- The status of the service account token.
- key String
- The key of the service account token.
- name String
- The name of the service account token.
- secondsTo NumberLive 
- The key expiration in seconds. It is optional. If it is a positive number an expiration date for the key is set. If it is null, zero or is omitted completely (unless api_key_max_seconds_to_liveconfiguration option is set) the key will never expire.
- serviceAccount StringId 
- The ID of the service account to which the token belongs.
Package Details
- Repository
- grafana pulumiverse/pulumi-grafana
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the grafanaTerraform Provider.
