grafana.CloudAccessPolicy

Explore with Pulumi AI

Example Usage

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Grafana = Lbrlabs.PulumiPackage.Grafana;
using Grafana = Pulumi.Grafana;

return await Deployment.RunAsync(() => 
{
    var current = Grafana.GetCloudOrganization.Invoke(new()
    {
        Slug = "<your org slug>",
    });

    var testCloudAccessPolicy = new Grafana.CloudAccessPolicy("testCloudAccessPolicy", new()
    {
        Region = "us",
        DisplayName = "My Policy",
        Scopes = new[]
        {
            "metrics:read",
            "logs:read",
        },
        Realms = new[]
        {
            new Grafana.Inputs.CloudAccessPolicyRealmArgs
            {
                Type = "org",
                Identifier = current.Apply(getCloudOrganizationResult => getCloudOrganizationResult.Id),
                LabelPolicies = new[]
                {
                    new Grafana.Inputs.CloudAccessPolicyRealmLabelPolicyArgs
                    {
                        Selector = "{namespace=\"default\"}",
                    },
                },
            },
        },
    });

    var testCloudAccessPolicyToken = new Grafana.CloudAccessPolicyToken("testCloudAccessPolicyToken", new()
    {
        Region = "us",
        AccessPolicyId = testCloudAccessPolicy.PolicyId,
        DisplayName = "My Policy Token",
        ExpiresAt = "2023-01-01T00:00:00Z",
    });

});
package main

import (
	"github.com/lbrlabs/pulumi-grafana/sdk/go/grafana"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		current, err := grafana.GetCloudOrganization(ctx, &grafana.GetCloudOrganizationArgs{
			Slug: pulumi.StringRef("<your org slug>"),
		}, nil)
		if err != nil {
			return err
		}
		testCloudAccessPolicy, err := grafana.NewCloudAccessPolicy(ctx, "testCloudAccessPolicy", &grafana.CloudAccessPolicyArgs{
			Region:      pulumi.String("us"),
			DisplayName: pulumi.String("My Policy"),
			Scopes: pulumi.StringArray{
				pulumi.String("metrics:read"),
				pulumi.String("logs:read"),
			},
			Realms: grafana.CloudAccessPolicyRealmArray{
				&grafana.CloudAccessPolicyRealmArgs{
					Type:       pulumi.String("org"),
					Identifier: *pulumi.String(current.Id),
					LabelPolicies: grafana.CloudAccessPolicyRealmLabelPolicyArray{
						&grafana.CloudAccessPolicyRealmLabelPolicyArgs{
							Selector: pulumi.String("{namespace=\"default\"}"),
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = grafana.NewCloudAccessPolicyToken(ctx, "testCloudAccessPolicyToken", &grafana.CloudAccessPolicyTokenArgs{
			Region:         pulumi.String("us"),
			AccessPolicyId: testCloudAccessPolicy.PolicyId,
			DisplayName:    pulumi.String("My Policy Token"),
			ExpiresAt:      pulumi.String("2023-01-01T00:00:00Z"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.GrafanaFunctions;
import com.pulumi.grafana.inputs.GetCloudOrganizationArgs;
import com.pulumi.grafana.CloudAccessPolicy;
import com.pulumi.grafana.CloudAccessPolicyArgs;
import com.pulumi.grafana.inputs.CloudAccessPolicyRealmArgs;
import com.pulumi.grafana.CloudAccessPolicyToken;
import com.pulumi.grafana.CloudAccessPolicyTokenArgs;
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 = GrafanaFunctions.getCloudOrganization(GetCloudOrganizationArgs.builder()
            .slug("<your org slug>")
            .build());

        var testCloudAccessPolicy = new CloudAccessPolicy("testCloudAccessPolicy", CloudAccessPolicyArgs.builder()        
            .region("us")
            .displayName("My Policy")
            .scopes(            
                "metrics:read",
                "logs:read")
            .realms(CloudAccessPolicyRealmArgs.builder()
                .type("org")
                .identifier(current.applyValue(getCloudOrganizationResult -> getCloudOrganizationResult.id()))
                .labelPolicies(CloudAccessPolicyRealmLabelPolicyArgs.builder()
                    .selector("{namespace=\"default\"}")
                    .build())
                .build())
            .build());

        var testCloudAccessPolicyToken = new CloudAccessPolicyToken("testCloudAccessPolicyToken", CloudAccessPolicyTokenArgs.builder()        
            .region("us")
            .accessPolicyId(testCloudAccessPolicy.policyId())
            .displayName("My Policy Token")
            .expiresAt("2023-01-01T00:00:00Z")
            .build());

    }
}
import pulumi
import lbrlabs_pulumi_grafana as grafana
import pulumi_grafana as grafana

current = grafana.get_cloud_organization(slug="<your org slug>")
test_cloud_access_policy = grafana.CloudAccessPolicy("testCloudAccessPolicy",
    region="us",
    display_name="My Policy",
    scopes=[
        "metrics:read",
        "logs:read",
    ],
    realms=[grafana.CloudAccessPolicyRealmArgs(
        type="org",
        identifier=current.id,
        label_policies=[grafana.CloudAccessPolicyRealmLabelPolicyArgs(
            selector="{namespace=\"default\"}",
        )],
    )])
test_cloud_access_policy_token = grafana.CloudAccessPolicyToken("testCloudAccessPolicyToken",
    region="us",
    access_policy_id=test_cloud_access_policy.policy_id,
    display_name="My Policy Token",
    expires_at="2023-01-01T00:00:00Z")
import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@lbrlabs/pulumi-grafana";
import * as grafana from "@pulumi/grafana";

const current = grafana.getCloudOrganization({
    slug: "<your org slug>",
});
const testCloudAccessPolicy = new grafana.CloudAccessPolicy("testCloudAccessPolicy", {
    region: "us",
    displayName: "My Policy",
    scopes: [
        "metrics:read",
        "logs:read",
    ],
    realms: [{
        type: "org",
        identifier: current.then(current => current.id),
        labelPolicies: [{
            selector: "{namespace=\"default\"}",
        }],
    }],
});
const testCloudAccessPolicyToken = new grafana.CloudAccessPolicyToken("testCloudAccessPolicyToken", {
    region: "us",
    accessPolicyId: testCloudAccessPolicy.policyId,
    displayName: "My Policy Token",
    expiresAt: "2023-01-01T00:00:00Z",
});
resources:
  testCloudAccessPolicy:
    type: grafana:CloudAccessPolicy
    properties:
      region: us
      displayName: My Policy
      scopes:
        - metrics:read
        - logs:read
      realms:
        - type: org
          identifier: ${current.id}
          labelPolicies:
            - selector: '{namespace="default"}'
  testCloudAccessPolicyToken:
    type: grafana:CloudAccessPolicyToken
    properties:
      region: us
      accessPolicyId: ${testCloudAccessPolicy.policyId}
      displayName: My Policy Token
      expiresAt: 2023-01-01T00:00:00Z
variables:
  current:
    fn::invoke:
      Function: grafana:getCloudOrganization
      Arguments:
        slug: <your org slug>

Create CloudAccessPolicy Resource

new CloudAccessPolicy(name: string, args: CloudAccessPolicyArgs, opts?: CustomResourceOptions);
@overload
def CloudAccessPolicy(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      display_name: Optional[str] = None,
                      name: Optional[str] = None,
                      realms: Optional[Sequence[CloudAccessPolicyRealmArgs]] = None,
                      region: Optional[str] = None,
                      scopes: Optional[Sequence[str]] = None)
@overload
def CloudAccessPolicy(resource_name: str,
                      args: CloudAccessPolicyArgs,
                      opts: Optional[ResourceOptions] = None)
func NewCloudAccessPolicy(ctx *Context, name string, args CloudAccessPolicyArgs, opts ...ResourceOption) (*CloudAccessPolicy, error)
public CloudAccessPolicy(string name, CloudAccessPolicyArgs args, CustomResourceOptions? opts = null)
public CloudAccessPolicy(String name, CloudAccessPolicyArgs args)
public CloudAccessPolicy(String name, CloudAccessPolicyArgs args, CustomResourceOptions options)
type: grafana:CloudAccessPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args CloudAccessPolicyArgs
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 CloudAccessPolicyArgs
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 CloudAccessPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args CloudAccessPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args CloudAccessPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

CloudAccessPolicy Resource Properties

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

Inputs

The CloudAccessPolicy resource accepts the following input properties:

Realms List<Lbrlabs.PulumiPackage.Grafana.Inputs.CloudAccessPolicyRealmArgs>
Region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

Scopes List<string>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

DisplayName string

Display name of the access policy. Defaults to the name.

Name string

Name of the access policy.

Realms []CloudAccessPolicyRealmArgs
Region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

Scopes []string

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

DisplayName string

Display name of the access policy. Defaults to the name.

Name string

Name of the access policy.

realms List<CloudAccessPolicyRealmArgs>
region String

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes List<String>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

displayName String

Display name of the access policy. Defaults to the name.

name String

Name of the access policy.

realms CloudAccessPolicyRealmArgs[]
region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes string[]

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

displayName string

Display name of the access policy. Defaults to the name.

name string

Name of the access policy.

realms Sequence[CloudAccessPolicyRealmArgs]
region str

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes Sequence[str]

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

display_name str

Display name of the access policy. Defaults to the name.

name str

Name of the access policy.

realms List<Property Map>
region String

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes List<String>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

displayName String

Display name of the access policy. Defaults to the name.

name String

Name of the access policy.

Outputs

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

CreatedAt string

Creation date of the access policy.

Id string

The provider-assigned unique ID for this managed resource.

PolicyId string

ID of the access policy.

UpdatedAt string

Last update date of the access policy.

CreatedAt string

Creation date of the access policy.

Id string

The provider-assigned unique ID for this managed resource.

PolicyId string

ID of the access policy.

UpdatedAt string

Last update date of the access policy.

createdAt String

Creation date of the access policy.

id String

The provider-assigned unique ID for this managed resource.

policyId String

ID of the access policy.

updatedAt String

Last update date of the access policy.

createdAt string

Creation date of the access policy.

id string

The provider-assigned unique ID for this managed resource.

policyId string

ID of the access policy.

updatedAt string

Last update date of the access policy.

created_at str

Creation date of the access policy.

id str

The provider-assigned unique ID for this managed resource.

policy_id str

ID of the access policy.

updated_at str

Last update date of the access policy.

createdAt String

Creation date of the access policy.

id String

The provider-assigned unique ID for this managed resource.

policyId String

ID of the access policy.

updatedAt String

Last update date of the access policy.

Look up Existing CloudAccessPolicy Resource

Get an existing CloudAccessPolicy 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?: CloudAccessPolicyState, opts?: CustomResourceOptions): CloudAccessPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        created_at: Optional[str] = None,
        display_name: Optional[str] = None,
        name: Optional[str] = None,
        policy_id: Optional[str] = None,
        realms: Optional[Sequence[CloudAccessPolicyRealmArgs]] = None,
        region: Optional[str] = None,
        scopes: Optional[Sequence[str]] = None,
        updated_at: Optional[str] = None) -> CloudAccessPolicy
func GetCloudAccessPolicy(ctx *Context, name string, id IDInput, state *CloudAccessPolicyState, opts ...ResourceOption) (*CloudAccessPolicy, error)
public static CloudAccessPolicy Get(string name, Input<string> id, CloudAccessPolicyState? state, CustomResourceOptions? opts = null)
public static CloudAccessPolicy get(String name, Output<String> id, CloudAccessPolicyState 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:
CreatedAt string

Creation date of the access policy.

DisplayName string

Display name of the access policy. Defaults to the name.

Name string

Name of the access policy.

PolicyId string

ID of the access policy.

Realms List<Lbrlabs.PulumiPackage.Grafana.Inputs.CloudAccessPolicyRealmArgs>
Region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

Scopes List<string>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

UpdatedAt string

Last update date of the access policy.

CreatedAt string

Creation date of the access policy.

DisplayName string

Display name of the access policy. Defaults to the name.

Name string

Name of the access policy.

PolicyId string

ID of the access policy.

Realms []CloudAccessPolicyRealmArgs
Region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

Scopes []string

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

UpdatedAt string

Last update date of the access policy.

createdAt String

Creation date of the access policy.

displayName String

Display name of the access policy. Defaults to the name.

name String

Name of the access policy.

policyId String

ID of the access policy.

realms List<CloudAccessPolicyRealmArgs>
region String

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes List<String>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

updatedAt String

Last update date of the access policy.

createdAt string

Creation date of the access policy.

displayName string

Display name of the access policy. Defaults to the name.

name string

Name of the access policy.

policyId string

ID of the access policy.

realms CloudAccessPolicyRealmArgs[]
region string

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes string[]

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

updatedAt string

Last update date of the access policy.

created_at str

Creation date of the access policy.

display_name str

Display name of the access policy. Defaults to the name.

name str

Name of the access policy.

policy_id str

ID of the access policy.

realms Sequence[CloudAccessPolicyRealmArgs]
region str

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes Sequence[str]

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

updated_at str

Last update date of the access policy.

createdAt String

Creation date of the access policy.

displayName String

Display name of the access policy. Defaults to the name.

name String

Name of the access policy.

policyId String

ID of the access policy.

realms List<Property Map>
region String

Region where the API is deployed. Generally where the stack is deployed. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/reference/cloud-api/#list-regions.

scopes List<String>

Scopes of the access policy. See https://grafana.com/docs/grafana-cloud/authentication-and-permissions/access-policies/#scopes for possible values.

updatedAt String

Last update date of the access policy.

Supporting Types

CloudAccessPolicyRealm

Identifier string

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

Type string

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

LabelPolicies List<Lbrlabs.PulumiPackage.Grafana.Inputs.CloudAccessPolicyRealmLabelPolicy>
Identifier string

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

Type string

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

LabelPolicies []CloudAccessPolicyRealmLabelPolicy
identifier String

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

type String

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

labelPolicies List<CloudAccessPolicyRealmLabelPolicy>
identifier string

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

type string

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

labelPolicies CloudAccessPolicyRealmLabelPolicy[]
identifier str

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

type str

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

label_policies Sequence[CloudAccessPolicyRealmLabelPolicy]
identifier String

The identifier of the org or stack. For orgs, this is the slug, for stacks, this is the stack ID.

type String

Whether a policy applies to a Cloud org or a specific stack. Should be one of org or stack.

labelPolicies List<Property Map>

CloudAccessPolicyRealmLabelPolicy

Selector string
Selector string
selector String
selector string
selector String

Package Details

Repository
grafana lbrlabs/pulumi-grafana
License
Apache-2.0
Notes

This Pulumi package is based on the grafana Terraform Provider.