1. Packages
  2. Grafana Cloud
  3. API Docs
  4. cloud
  5. AccessPolicyToken
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse

grafana.cloud.AccessPolicyToken

Explore with Pulumi AI

grafana logo
Grafana v0.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse

    Required access policy scopes:

    • accesspolicies:read
    • accesspolicies:write
    • accesspolicies:delete

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumi/grafana";
    import * as grafana from "@pulumiverse/grafana";
    
    const current = grafana.cloud.getOrganization({
        slug: "<your org slug>",
    });
    const test = new grafana.cloud.AccessPolicy("test", {
        region: "us",
        name: "my-policy",
        displayName: "My Policy",
        scopes: [
            "metrics:read",
            "logs:read",
        ],
        realms: [{
            type: "org",
            identifier: current.then(current => current.id),
            labelPolicies: [{
                selector: "{namespace=\"default\"}",
            }],
        }],
    });
    const testAccessPolicyToken = new grafana.cloud.AccessPolicyToken("test", {
        region: "us",
        accessPolicyId: test.policyId,
        name: "my-policy-token",
        displayName: "My Policy Token",
        expiresAt: "2023-01-01T00:00:00Z",
    });
    
    import pulumi
    import pulumi_grafana as grafana
    import pulumiverse_grafana as grafana
    
    current = grafana.cloud.get_organization(slug="<your org slug>")
    test = grafana.cloud.AccessPolicy("test",
        region="us",
        name="my-policy",
        display_name="My Policy",
        scopes=[
            "metrics:read",
            "logs:read",
        ],
        realms=[{
            "type": "org",
            "identifier": current.id,
            "label_policies": [{
                "selector": "{namespace=\"default\"}",
            }],
        }])
    test_access_policy_token = grafana.cloud.AccessPolicyToken("test",
        region="us",
        access_policy_id=test.policy_id,
        name="my-policy-token",
        display_name="My Policy Token",
        expires_at="2023-01-01T00:00:00Z")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/cloud"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		current, err := cloud.GetOrganization(ctx, &cloud.GetOrganizationArgs{
    			Slug: pulumi.StringRef("<your org slug>"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		test, err := cloud.NewAccessPolicy(ctx, "test", &cloud.AccessPolicyArgs{
    			Region:      pulumi.String("us"),
    			Name:        pulumi.String("my-policy"),
    			DisplayName: pulumi.String("My Policy"),
    			Scopes: pulumi.StringArray{
    				pulumi.String("metrics:read"),
    				pulumi.String("logs:read"),
    			},
    			Realms: cloud.AccessPolicyRealmArray{
    				&cloud.AccessPolicyRealmArgs{
    					Type:       pulumi.String("org"),
    					Identifier: pulumi.String(current.Id),
    					LabelPolicies: cloud.AccessPolicyRealmLabelPolicyArray{
    						&cloud.AccessPolicyRealmLabelPolicyArgs{
    							Selector: pulumi.String("{namespace=\"default\"}"),
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cloud.NewAccessPolicyToken(ctx, "test", &cloud.AccessPolicyTokenArgs{
    			Region:         pulumi.String("us"),
    			AccessPolicyId: test.PolicyId,
    			Name:           pulumi.String("my-policy-token"),
    			DisplayName:    pulumi.String("My Policy Token"),
    			ExpiresAt:      pulumi.String("2023-01-01T00:00:00Z"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Grafana = Pulumi.Grafana;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Grafana.Cloud.GetOrganization.Invoke(new()
        {
            Slug = "<your org slug>",
        });
    
        var test = new Grafana.Cloud.AccessPolicy("test", new()
        {
            Region = "us",
            Name = "my-policy",
            DisplayName = "My Policy",
            Scopes = new[]
            {
                "metrics:read",
                "logs:read",
            },
            Realms = new[]
            {
                new Grafana.Cloud.Inputs.AccessPolicyRealmArgs
                {
                    Type = "org",
                    Identifier = current.Apply(getOrganizationResult => getOrganizationResult.Id),
                    LabelPolicies = new[]
                    {
                        new Grafana.Cloud.Inputs.AccessPolicyRealmLabelPolicyArgs
                        {
                            Selector = "{namespace=\"default\"}",
                        },
                    },
                },
            },
        });
    
        var testAccessPolicyToken = new Grafana.Cloud.AccessPolicyToken("test", new()
        {
            Region = "us",
            AccessPolicyId = test.PolicyId,
            Name = "my-policy-token",
            DisplayName = "My Policy Token",
            ExpiresAt = "2023-01-01T00:00:00Z",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.cloud.CloudFunctions;
    import com.pulumi.grafana.cloud.inputs.GetOrganizationArgs;
    import com.pulumi.grafana.cloud.AccessPolicy;
    import com.pulumi.grafana.cloud.AccessPolicyArgs;
    import com.pulumi.grafana.cloud.inputs.AccessPolicyRealmArgs;
    import com.pulumi.grafana.cloud.AccessPolicyToken;
    import com.pulumi.grafana.cloud.AccessPolicyTokenArgs;
    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 current = CloudFunctions.getOrganization(GetOrganizationArgs.builder()
                .slug("<your org slug>")
                .build());
    
            var test = new AccessPolicy("test", AccessPolicyArgs.builder()
                .region("us")
                .name("my-policy")
                .displayName("My Policy")
                .scopes(            
                    "metrics:read",
                    "logs:read")
                .realms(AccessPolicyRealmArgs.builder()
                    .type("org")
                    .identifier(current.applyValue(getOrganizationResult -> getOrganizationResult.id()))
                    .labelPolicies(AccessPolicyRealmLabelPolicyArgs.builder()
                        .selector("{namespace=\"default\"}")
                        .build())
                    .build())
                .build());
    
            var testAccessPolicyToken = new AccessPolicyToken("testAccessPolicyToken", AccessPolicyTokenArgs.builder()
                .region("us")
                .accessPolicyId(test.policyId())
                .name("my-policy-token")
                .displayName("My Policy Token")
                .expiresAt("2023-01-01T00:00:00Z")
                .build());
    
        }
    }
    
    resources:
      test:
        type: grafana:cloud:AccessPolicy
        properties:
          region: us
          name: my-policy
          displayName: My Policy
          scopes:
            - metrics:read
            - logs:read
          realms:
            - type: org
              identifier: ${current.id}
              labelPolicies:
                - selector: '{namespace="default"}'
      testAccessPolicyToken:
        type: grafana:cloud:AccessPolicyToken
        name: test
        properties:
          region: us
          accessPolicyId: ${test.policyId}
          name: my-policy-token
          displayName: My Policy Token
          expiresAt: 2023-01-01T00:00:00Z
    variables:
      current:
        fn::invoke:
          Function: grafana:cloud:getOrganization
          Arguments:
            slug: <your org slug>
    

    Create AccessPolicyToken Resource

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

    Constructor syntax

    new AccessPolicyToken(name: string, args: AccessPolicyTokenArgs, opts?: CustomResourceOptions);
    @overload
    def AccessPolicyToken(resource_name: str,
                          args: AccessPolicyTokenArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def AccessPolicyToken(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          access_policy_id: Optional[str] = None,
                          region: Optional[str] = None,
                          display_name: Optional[str] = None,
                          expires_at: Optional[str] = None,
                          name: Optional[str] = None)
    func NewAccessPolicyToken(ctx *Context, name string, args AccessPolicyTokenArgs, opts ...ResourceOption) (*AccessPolicyToken, error)
    public AccessPolicyToken(string name, AccessPolicyTokenArgs args, CustomResourceOptions? opts = null)
    public AccessPolicyToken(String name, AccessPolicyTokenArgs args)
    public AccessPolicyToken(String name, AccessPolicyTokenArgs args, CustomResourceOptions options)
    
    type: grafana:cloud:AccessPolicyToken
    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 AccessPolicyTokenArgs
    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 AccessPolicyTokenArgs
    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 AccessPolicyTokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AccessPolicyTokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AccessPolicyTokenArgs
    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 accessPolicyTokenResource = new Grafana.Cloud.AccessPolicyToken("accessPolicyTokenResource", new()
    {
        AccessPolicyId = "string",
        Region = "string",
        DisplayName = "string",
        ExpiresAt = "string",
        Name = "string",
    });
    
    example, err := cloud.NewAccessPolicyToken(ctx, "accessPolicyTokenResource", &cloud.AccessPolicyTokenArgs{
    	AccessPolicyId: pulumi.String("string"),
    	Region:         pulumi.String("string"),
    	DisplayName:    pulumi.String("string"),
    	ExpiresAt:      pulumi.String("string"),
    	Name:           pulumi.String("string"),
    })
    
    var accessPolicyTokenResource = new AccessPolicyToken("accessPolicyTokenResource", AccessPolicyTokenArgs.builder()
        .accessPolicyId("string")
        .region("string")
        .displayName("string")
        .expiresAt("string")
        .name("string")
        .build());
    
    access_policy_token_resource = grafana.cloud.AccessPolicyToken("accessPolicyTokenResource",
        access_policy_id="string",
        region="string",
        display_name="string",
        expires_at="string",
        name="string")
    
    const accessPolicyTokenResource = new grafana.cloud.AccessPolicyToken("accessPolicyTokenResource", {
        accessPolicyId: "string",
        region: "string",
        displayName: "string",
        expiresAt: "string",
        name: "string",
    });
    
    type: grafana:cloud:AccessPolicyToken
    properties:
        accessPolicyId: string
        displayName: string
        expiresAt: string
        name: string
        region: string
    

    AccessPolicyToken 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 AccessPolicyToken resource accepts the following input properties:

    AccessPolicyId string
    ID of the access policy for which to create a token.
    Region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    DisplayName string
    Display name of the access policy token. Defaults to the name.
    ExpiresAt string
    Expiration date of the access policy token. Does not expire by default.
    Name string
    Name of the access policy token.
    AccessPolicyId string
    ID of the access policy for which to create a token.
    Region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    DisplayName string
    Display name of the access policy token. Defaults to the name.
    ExpiresAt string
    Expiration date of the access policy token. Does not expire by default.
    Name string
    Name of the access policy token.
    accessPolicyId String
    ID of the access policy for which to create a token.
    region String
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    displayName String
    Display name of the access policy token. Defaults to the name.
    expiresAt String
    Expiration date of the access policy token. Does not expire by default.
    name String
    Name of the access policy token.
    accessPolicyId string
    ID of the access policy for which to create a token.
    region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    displayName string
    Display name of the access policy token. Defaults to the name.
    expiresAt string
    Expiration date of the access policy token. Does not expire by default.
    name string
    Name of the access policy token.
    access_policy_id str
    ID of the access policy for which to create a token.
    region str
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    display_name str
    Display name of the access policy token. Defaults to the name.
    expires_at str
    Expiration date of the access policy token. Does not expire by default.
    name str
    Name of the access policy token.
    accessPolicyId String
    ID of the access policy for which to create a token.
    region String
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    displayName String
    Display name of the access policy token. Defaults to the name.
    expiresAt String
    Expiration date of the access policy token. Does not expire by default.
    name String
    Name of the access policy token.

    Outputs

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

    CreatedAt string
    Creation date of the access policy token.
    Id string
    The provider-assigned unique ID for this managed resource.
    Token string
    UpdatedAt string
    Last update date of the access policy token.
    CreatedAt string
    Creation date of the access policy token.
    Id string
    The provider-assigned unique ID for this managed resource.
    Token string
    UpdatedAt string
    Last update date of the access policy token.
    createdAt String
    Creation date of the access policy token.
    id String
    The provider-assigned unique ID for this managed resource.
    token String
    updatedAt String
    Last update date of the access policy token.
    createdAt string
    Creation date of the access policy token.
    id string
    The provider-assigned unique ID for this managed resource.
    token string
    updatedAt string
    Last update date of the access policy token.
    created_at str
    Creation date of the access policy token.
    id str
    The provider-assigned unique ID for this managed resource.
    token str
    updated_at str
    Last update date of the access policy token.
    createdAt String
    Creation date of the access policy token.
    id String
    The provider-assigned unique ID for this managed resource.
    token String
    updatedAt String
    Last update date of the access policy token.

    Look up Existing AccessPolicyToken Resource

    Get an existing AccessPolicyToken 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?: AccessPolicyTokenState, opts?: CustomResourceOptions): AccessPolicyToken
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            access_policy_id: Optional[str] = None,
            created_at: Optional[str] = None,
            display_name: Optional[str] = None,
            expires_at: Optional[str] = None,
            name: Optional[str] = None,
            region: Optional[str] = None,
            token: Optional[str] = None,
            updated_at: Optional[str] = None) -> AccessPolicyToken
    func GetAccessPolicyToken(ctx *Context, name string, id IDInput, state *AccessPolicyTokenState, opts ...ResourceOption) (*AccessPolicyToken, error)
    public static AccessPolicyToken Get(string name, Input<string> id, AccessPolicyTokenState? state, CustomResourceOptions? opts = null)
    public static AccessPolicyToken get(String name, Output<String> id, AccessPolicyTokenState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    AccessPolicyId string
    ID of the access policy for which to create a token.
    CreatedAt string
    Creation date of the access policy token.
    DisplayName string
    Display name of the access policy token. Defaults to the name.
    ExpiresAt string
    Expiration date of the access policy token. Does not expire by default.
    Name string
    Name of the access policy token.
    Region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    Token string
    UpdatedAt string
    Last update date of the access policy token.
    AccessPolicyId string
    ID of the access policy for which to create a token.
    CreatedAt string
    Creation date of the access policy token.
    DisplayName string
    Display name of the access policy token. Defaults to the name.
    ExpiresAt string
    Expiration date of the access policy token. Does not expire by default.
    Name string
    Name of the access policy token.
    Region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    Token string
    UpdatedAt string
    Last update date of the access policy token.
    accessPolicyId String
    ID of the access policy for which to create a token.
    createdAt String
    Creation date of the access policy token.
    displayName String
    Display name of the access policy token. Defaults to the name.
    expiresAt String
    Expiration date of the access policy token. Does not expire by default.
    name String
    Name of the access policy token.
    region String
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    token String
    updatedAt String
    Last update date of the access policy token.
    accessPolicyId string
    ID of the access policy for which to create a token.
    createdAt string
    Creation date of the access policy token.
    displayName string
    Display name of the access policy token. Defaults to the name.
    expiresAt string
    Expiration date of the access policy token. Does not expire by default.
    name string
    Name of the access policy token.
    region string
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    token string
    updatedAt string
    Last update date of the access policy token.
    access_policy_id str
    ID of the access policy for which to create a token.
    created_at str
    Creation date of the access policy token.
    display_name str
    Display name of the access policy token. Defaults to the name.
    expires_at str
    Expiration date of the access policy token. Does not expire by default.
    name str
    Name of the access policy token.
    region str
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    token str
    updated_at str
    Last update date of the access policy token.
    accessPolicyId String
    ID of the access policy for which to create a token.
    createdAt String
    Creation date of the access policy token.
    displayName String
    Display name of the access policy token. Defaults to the name.
    expiresAt String
    Expiration date of the access policy token. Does not expire by default.
    name String
    Name of the access policy token.
    region String
    Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions.
    token String
    updatedAt String
    Last update date of the access policy token.

    Import

    $ pulumi import grafana:cloud/accessPolicyToken:AccessPolicyToken name "{{ region }}:{{ tokenId }}"
    

    To learn more about importing existing cloud resources, see Importing resources.

    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.7.0 published on Tuesday, Nov 5, 2024 by pulumiverse