Manages service account tokens of a Grafana Cloud stack using the Cloud API This can be used to bootstrap a management service account token for a new stack
Required access policy scopes:
- stack-service-accounts:write
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumiverse/grafana";
const cloudSa = new grafana.cloud.StackServiceAccount("cloud_sa", {
stackSlug: "<your stack slug>",
name: "cloud service account",
role: "Admin",
isDisabled: false,
});
const foo = new grafana.cloud.StackServiceAccountToken("foo", {
stackSlug: "<your stack slug>",
name: "key_foo",
serviceAccountId: cloudSa.id,
});
export const serviceAccountTokenFooKey = foo.key;
import pulumi
import pulumiverse_grafana as grafana
cloud_sa = grafana.cloud.StackServiceAccount("cloud_sa",
stack_slug="<your stack slug>",
name="cloud service account",
role="Admin",
is_disabled=False)
foo = grafana.cloud.StackServiceAccountToken("foo",
stack_slug="<your stack slug>",
name="key_foo",
service_account_id=cloud_sa.id)
pulumi.export("serviceAccountTokenFooKey", foo.key)
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-grafana/sdk/v2/go/grafana/cloud"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cloudSa, err := cloud.NewStackServiceAccount(ctx, "cloud_sa", &cloud.StackServiceAccountArgs{
StackSlug: pulumi.String("<your stack slug>"),
Name: pulumi.String("cloud service account"),
Role: pulumi.String("Admin"),
IsDisabled: pulumi.Bool(false),
})
if err != nil {
return err
}
foo, err := cloud.NewStackServiceAccountToken(ctx, "foo", &cloud.StackServiceAccountTokenArgs{
StackSlug: pulumi.String("<your stack slug>"),
Name: pulumi.String("key_foo"),
ServiceAccountId: cloudSa.ID(),
})
if err != nil {
return err
}
ctx.Export("serviceAccountTokenFooKey", foo.Key)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Grafana = Pulumiverse.Grafana;
return await Deployment.RunAsync(() =>
{
var cloudSa = new Grafana.Cloud.StackServiceAccount("cloud_sa", new()
{
StackSlug = "<your stack slug>",
Name = "cloud service account",
Role = "Admin",
IsDisabled = false,
});
var foo = new Grafana.Cloud.StackServiceAccountToken("foo", new()
{
StackSlug = "<your stack slug>",
Name = "key_foo",
ServiceAccountId = cloudSa.Id,
});
return new Dictionary<string, object?>
{
["serviceAccountTokenFooKey"] = foo.Key,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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 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 cloudSa = new StackServiceAccount("cloudSa", StackServiceAccountArgs.builder()
.stackSlug("<your stack slug>")
.name("cloud service account")
.role("Admin")
.isDisabled(false)
.build());
var foo = new StackServiceAccountToken("foo", StackServiceAccountTokenArgs.builder()
.stackSlug("<your stack slug>")
.name("key_foo")
.serviceAccountId(cloudSa.id())
.build());
ctx.export("serviceAccountTokenFooKey", foo.key());
}
}
resources:
cloudSa:
type: grafana:cloud:StackServiceAccount
name: cloud_sa
properties:
stackSlug: <your stack slug>
name: cloud service account
role: Admin
isDisabled: false
foo:
type: grafana:cloud:StackServiceAccountToken
properties:
stackSlug: <your stack slug>
name: key_foo
serviceAccountId: ${cloudSa.id}
outputs:
serviceAccountTokenFooKey: ${foo.key}
Create StackServiceAccountToken Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new StackServiceAccountToken(name: string, args: StackServiceAccountTokenArgs, opts?: CustomResourceOptions);@overload
def StackServiceAccountToken(resource_name: str,
args: StackServiceAccountTokenArgs,
opts: Optional[ResourceOptions] = None)
@overload
def StackServiceAccountToken(resource_name: str,
opts: Optional[ResourceOptions] = None,
service_account_id: Optional[str] = None,
stack_slug: Optional[str] = None,
name: Optional[str] = None,
seconds_to_live: Optional[int] = None)func NewStackServiceAccountToken(ctx *Context, name string, args StackServiceAccountTokenArgs, opts ...ResourceOption) (*StackServiceAccountToken, error)public StackServiceAccountToken(string name, StackServiceAccountTokenArgs args, CustomResourceOptions? opts = null)
public StackServiceAccountToken(String name, StackServiceAccountTokenArgs args)
public StackServiceAccountToken(String name, StackServiceAccountTokenArgs args, CustomResourceOptions options)
type: grafana:cloud:StackServiceAccountToken
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 StackServiceAccountTokenArgs
- 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 StackServiceAccountTokenArgs
- 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 StackServiceAccountTokenArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args StackServiceAccountTokenArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args StackServiceAccountTokenArgs
- 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 stackServiceAccountTokenResource = new Grafana.Cloud.StackServiceAccountToken("stackServiceAccountTokenResource", new()
{
ServiceAccountId = "string",
StackSlug = "string",
Name = "string",
SecondsToLive = 0,
});
example, err := cloud.NewStackServiceAccountToken(ctx, "stackServiceAccountTokenResource", &cloud.StackServiceAccountTokenArgs{
ServiceAccountId: pulumi.String("string"),
StackSlug: pulumi.String("string"),
Name: pulumi.String("string"),
SecondsToLive: pulumi.Int(0),
})
var stackServiceAccountTokenResource = new StackServiceAccountToken("stackServiceAccountTokenResource", StackServiceAccountTokenArgs.builder()
.serviceAccountId("string")
.stackSlug("string")
.name("string")
.secondsToLive(0)
.build());
stack_service_account_token_resource = grafana.cloud.StackServiceAccountToken("stackServiceAccountTokenResource",
service_account_id="string",
stack_slug="string",
name="string",
seconds_to_live=0)
const stackServiceAccountTokenResource = new grafana.cloud.StackServiceAccountToken("stackServiceAccountTokenResource", {
serviceAccountId: "string",
stackSlug: "string",
name: "string",
secondsToLive: 0,
});
type: grafana:cloud:StackServiceAccountToken
properties:
name: string
secondsToLive: 0
serviceAccountId: string
stackSlug: string
StackServiceAccountToken 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 StackServiceAccountToken resource accepts the following input properties:
- Service
Account stringId - The ID of the service account to which the token belongs.
- Stack
Slug string - Name string
- 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 stringId - The ID of the service account to which the token belongs.
- Stack
Slug string - Name string
- 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 StringId - The ID of the service account to which the token belongs.
- stack
Slug String - name String
- The name of the service account token.
- seconds
To 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.
- service
Account stringId - The ID of the service account to which the token belongs.
- stack
Slug string - name string
- The name of the service account token.
- seconds
To 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.
- stack_
slug str - 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 StringId - The ID of the service account to which the token belongs.
- stack
Slug String - name String
- The name of the service account token.
- seconds
To 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 StackServiceAccountToken resource produces the following output properties:
- Expiration string
- The expiration date of the service account token.
- Has
Expired 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.
- Has
Expired 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.
- has
Expired 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.
- has
Expired 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.
- has
Expired 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 StackServiceAccountToken Resource
Get an existing StackServiceAccountToken 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?: StackServiceAccountTokenState, opts?: CustomResourceOptions): StackServiceAccountToken@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,
stack_slug: Optional[str] = None) -> StackServiceAccountTokenfunc GetStackServiceAccountToken(ctx *Context, name string, id IDInput, state *StackServiceAccountTokenState, opts ...ResourceOption) (*StackServiceAccountToken, error)public static StackServiceAccountToken Get(string name, Input<string> id, StackServiceAccountTokenState? state, CustomResourceOptions? opts = null)public static StackServiceAccountToken get(String name, Output<String> id, StackServiceAccountTokenState state, CustomResourceOptions options)resources: _: type: grafana:cloud:StackServiceAccountToken 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.
- Has
Expired 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.
- 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 stringId - The ID of the service account to which the token belongs.
- Stack
Slug string
- Expiration string
- The expiration date of the service account token.
- Has
Expired 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.
- 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 stringId - The ID of the service account to which the token belongs.
- Stack
Slug string
- expiration String
- The expiration date of the service account token.
- has
Expired 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.
- seconds
To 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. - service
Account StringId - The ID of the service account to which the token belongs.
- stack
Slug String
- expiration string
- The expiration date of the service account token.
- has
Expired 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.
- seconds
To 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 stringId - The ID of the service account to which the token belongs.
- stack
Slug string
- 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.
- stack_
slug str
- expiration String
- The expiration date of the service account token.
- has
Expired 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.
- seconds
To 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 StringId - The ID of the service account to which the token belongs.
- stack
Slug String
Package Details
- Repository
- grafana pulumiverse/pulumi-grafana
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
grafanaTerraform Provider.
