1. Packages
  2. AWS Classic
  3. API Docs
  4. grafana
  5. RoleAssociation

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.grafana.RoleAssociation

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides an Amazon Managed Grafana workspace role association resource.

    Example Usage

    Basic configuration

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const assume = new aws.iam.Role("assume", {
        name: "grafana-assume",
        assumeRolePolicy: JSON.stringify({
            Version: "2012-10-17",
            Statement: [{
                Action: "sts:AssumeRole",
                Effect: "Allow",
                Sid: "",
                Principal: {
                    Service: "grafana.amazonaws.com",
                },
            }],
        }),
    });
    const exampleWorkspace = new aws.grafana.Workspace("example", {
        accountAccessType: "CURRENT_ACCOUNT",
        authenticationProviders: ["SAML"],
        permissionType: "SERVICE_MANAGED",
        roleArn: assume.arn,
    });
    const example = new aws.grafana.RoleAssociation("example", {
        role: "ADMIN",
        userIds: [
            "USER_ID_1",
            "USER_ID_2",
        ],
        workspaceId: exampleWorkspace.id,
    });
    
    import pulumi
    import json
    import pulumi_aws as aws
    
    assume = aws.iam.Role("assume",
        name="grafana-assume",
        assume_role_policy=json.dumps({
            "Version": "2012-10-17",
            "Statement": [{
                "Action": "sts:AssumeRole",
                "Effect": "Allow",
                "Sid": "",
                "Principal": {
                    "Service": "grafana.amazonaws.com",
                },
            }],
        }))
    example_workspace = aws.grafana.Workspace("example",
        account_access_type="CURRENT_ACCOUNT",
        authentication_providers=["SAML"],
        permission_type="SERVICE_MANAGED",
        role_arn=assume.arn)
    example = aws.grafana.RoleAssociation("example",
        role="ADMIN",
        user_ids=[
            "USER_ID_1",
            "USER_ID_2",
        ],
        workspace_id=example_workspace.id)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/grafana"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Version": "2012-10-17",
    			"Statement": []map[string]interface{}{
    				map[string]interface{}{
    					"Action": "sts:AssumeRole",
    					"Effect": "Allow",
    					"Sid":    "",
    					"Principal": map[string]interface{}{
    						"Service": "grafana.amazonaws.com",
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		assume, err := iam.NewRole(ctx, "assume", &iam.RoleArgs{
    			Name:             pulumi.String("grafana-assume"),
    			AssumeRolePolicy: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		exampleWorkspace, err := grafana.NewWorkspace(ctx, "example", &grafana.WorkspaceArgs{
    			AccountAccessType: pulumi.String("CURRENT_ACCOUNT"),
    			AuthenticationProviders: pulumi.StringArray{
    				pulumi.String("SAML"),
    			},
    			PermissionType: pulumi.String("SERVICE_MANAGED"),
    			RoleArn:        assume.Arn,
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewRoleAssociation(ctx, "example", &grafana.RoleAssociationArgs{
    			Role: pulumi.String("ADMIN"),
    			UserIds: pulumi.StringArray{
    				pulumi.String("USER_ID_1"),
    				pulumi.String("USER_ID_2"),
    			},
    			WorkspaceId: exampleWorkspace.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var assume = new Aws.Iam.Role("assume", new()
        {
            Name = "grafana-assume",
            AssumeRolePolicy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "2012-10-17",
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Action"] = "sts:AssumeRole",
                        ["Effect"] = "Allow",
                        ["Sid"] = "",
                        ["Principal"] = new Dictionary<string, object?>
                        {
                            ["Service"] = "grafana.amazonaws.com",
                        },
                    },
                },
            }),
        });
    
        var exampleWorkspace = new Aws.Grafana.Workspace("example", new()
        {
            AccountAccessType = "CURRENT_ACCOUNT",
            AuthenticationProviders = new[]
            {
                "SAML",
            },
            PermissionType = "SERVICE_MANAGED",
            RoleArn = assume.Arn,
        });
    
        var example = new Aws.Grafana.RoleAssociation("example", new()
        {
            Role = "ADMIN",
            UserIds = new[]
            {
                "USER_ID_1",
                "USER_ID_2",
            },
            WorkspaceId = exampleWorkspace.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.Role;
    import com.pulumi.aws.iam.RoleArgs;
    import com.pulumi.aws.grafana.Workspace;
    import com.pulumi.aws.grafana.WorkspaceArgs;
    import com.pulumi.aws.grafana.RoleAssociation;
    import com.pulumi.aws.grafana.RoleAssociationArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 assume = new Role("assume", RoleArgs.builder()
                .name("grafana-assume")
                .assumeRolePolicy(serializeJson(
                    jsonObject(
                        jsonProperty("Version", "2012-10-17"),
                        jsonProperty("Statement", jsonArray(jsonObject(
                            jsonProperty("Action", "sts:AssumeRole"),
                            jsonProperty("Effect", "Allow"),
                            jsonProperty("Sid", ""),
                            jsonProperty("Principal", jsonObject(
                                jsonProperty("Service", "grafana.amazonaws.com")
                            ))
                        )))
                    )))
                .build());
    
            var exampleWorkspace = new Workspace("exampleWorkspace", WorkspaceArgs.builder()
                .accountAccessType("CURRENT_ACCOUNT")
                .authenticationProviders("SAML")
                .permissionType("SERVICE_MANAGED")
                .roleArn(assume.arn())
                .build());
    
            var example = new RoleAssociation("example", RoleAssociationArgs.builder()
                .role("ADMIN")
                .userIds(            
                    "USER_ID_1",
                    "USER_ID_2")
                .workspaceId(exampleWorkspace.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:grafana:RoleAssociation
        properties:
          role: ADMIN
          userIds:
            - USER_ID_1
            - USER_ID_2
          workspaceId: ${exampleWorkspace.id}
      exampleWorkspace:
        type: aws:grafana:Workspace
        name: example
        properties:
          accountAccessType: CURRENT_ACCOUNT
          authenticationProviders:
            - SAML
          permissionType: SERVICE_MANAGED
          roleArn: ${assume.arn}
      assume:
        type: aws:iam:Role
        properties:
          name: grafana-assume
          assumeRolePolicy:
            fn::toJSON:
              Version: 2012-10-17
              Statement:
                - Action: sts:AssumeRole
                  Effect: Allow
                  Sid:
                  Principal:
                    Service: grafana.amazonaws.com
    

    Create RoleAssociation Resource

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

    Constructor syntax

    new RoleAssociation(name: string, args: RoleAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def RoleAssociation(resource_name: str,
                        args: RoleAssociationArgs,
                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def RoleAssociation(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        role: Optional[str] = None,
                        workspace_id: Optional[str] = None,
                        group_ids: Optional[Sequence[str]] = None,
                        user_ids: Optional[Sequence[str]] = None)
    func NewRoleAssociation(ctx *Context, name string, args RoleAssociationArgs, opts ...ResourceOption) (*RoleAssociation, error)
    public RoleAssociation(string name, RoleAssociationArgs args, CustomResourceOptions? opts = null)
    public RoleAssociation(String name, RoleAssociationArgs args)
    public RoleAssociation(String name, RoleAssociationArgs args, CustomResourceOptions options)
    
    type: aws:grafana:RoleAssociation
    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 RoleAssociationArgs
    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 RoleAssociationArgs
    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 RoleAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RoleAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RoleAssociationArgs
    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 roleAssociationResource = new Aws.Grafana.RoleAssociation("roleAssociationResource", new()
    {
        Role = "string",
        WorkspaceId = "string",
        GroupIds = new[]
        {
            "string",
        },
        UserIds = new[]
        {
            "string",
        },
    });
    
    example, err := grafana.NewRoleAssociation(ctx, "roleAssociationResource", &grafana.RoleAssociationArgs{
    	Role:        pulumi.String("string"),
    	WorkspaceId: pulumi.String("string"),
    	GroupIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	UserIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    var roleAssociationResource = new RoleAssociation("roleAssociationResource", RoleAssociationArgs.builder()
        .role("string")
        .workspaceId("string")
        .groupIds("string")
        .userIds("string")
        .build());
    
    role_association_resource = aws.grafana.RoleAssociation("roleAssociationResource",
        role="string",
        workspace_id="string",
        group_ids=["string"],
        user_ids=["string"])
    
    const roleAssociationResource = new aws.grafana.RoleAssociation("roleAssociationResource", {
        role: "string",
        workspaceId: "string",
        groupIds: ["string"],
        userIds: ["string"],
    });
    
    type: aws:grafana:RoleAssociation
    properties:
        groupIds:
            - string
        role: string
        userIds:
            - string
        workspaceId: string
    

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

    Role string
    The grafana role. Valid values can be found here.
    WorkspaceId string

    The workspace id.

    The following arguments are optional:

    GroupIds List<string>
    The AWS SSO group ids to be assigned the role given in role.
    UserIds List<string>
    The AWS SSO user ids to be assigned the role given in role.
    Role string
    The grafana role. Valid values can be found here.
    WorkspaceId string

    The workspace id.

    The following arguments are optional:

    GroupIds []string
    The AWS SSO group ids to be assigned the role given in role.
    UserIds []string
    The AWS SSO user ids to be assigned the role given in role.
    role String
    The grafana role. Valid values can be found here.
    workspaceId String

    The workspace id.

    The following arguments are optional:

    groupIds List<String>
    The AWS SSO group ids to be assigned the role given in role.
    userIds List<String>
    The AWS SSO user ids to be assigned the role given in role.
    role string
    The grafana role. Valid values can be found here.
    workspaceId string

    The workspace id.

    The following arguments are optional:

    groupIds string[]
    The AWS SSO group ids to be assigned the role given in role.
    userIds string[]
    The AWS SSO user ids to be assigned the role given in role.
    role str
    The grafana role. Valid values can be found here.
    workspace_id str

    The workspace id.

    The following arguments are optional:

    group_ids Sequence[str]
    The AWS SSO group ids to be assigned the role given in role.
    user_ids Sequence[str]
    The AWS SSO user ids to be assigned the role given in role.
    role String
    The grafana role. Valid values can be found here.
    workspaceId String

    The workspace id.

    The following arguments are optional:

    groupIds List<String>
    The AWS SSO group ids to be assigned the role given in role.
    userIds List<String>
    The AWS SSO user ids to be assigned the role given in role.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing RoleAssociation Resource

    Get an existing RoleAssociation 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?: RoleAssociationState, opts?: CustomResourceOptions): RoleAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group_ids: Optional[Sequence[str]] = None,
            role: Optional[str] = None,
            user_ids: Optional[Sequence[str]] = None,
            workspace_id: Optional[str] = None) -> RoleAssociation
    func GetRoleAssociation(ctx *Context, name string, id IDInput, state *RoleAssociationState, opts ...ResourceOption) (*RoleAssociation, error)
    public static RoleAssociation Get(string name, Input<string> id, RoleAssociationState? state, CustomResourceOptions? opts = null)
    public static RoleAssociation get(String name, Output<String> id, RoleAssociationState 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:
    GroupIds List<string>
    The AWS SSO group ids to be assigned the role given in role.
    Role string
    The grafana role. Valid values can be found here.
    UserIds List<string>
    The AWS SSO user ids to be assigned the role given in role.
    WorkspaceId string

    The workspace id.

    The following arguments are optional:

    GroupIds []string
    The AWS SSO group ids to be assigned the role given in role.
    Role string
    The grafana role. Valid values can be found here.
    UserIds []string
    The AWS SSO user ids to be assigned the role given in role.
    WorkspaceId string

    The workspace id.

    The following arguments are optional:

    groupIds List<String>
    The AWS SSO group ids to be assigned the role given in role.
    role String
    The grafana role. Valid values can be found here.
    userIds List<String>
    The AWS SSO user ids to be assigned the role given in role.
    workspaceId String

    The workspace id.

    The following arguments are optional:

    groupIds string[]
    The AWS SSO group ids to be assigned the role given in role.
    role string
    The grafana role. Valid values can be found here.
    userIds string[]
    The AWS SSO user ids to be assigned the role given in role.
    workspaceId string

    The workspace id.

    The following arguments are optional:

    group_ids Sequence[str]
    The AWS SSO group ids to be assigned the role given in role.
    role str
    The grafana role. Valid values can be found here.
    user_ids Sequence[str]
    The AWS SSO user ids to be assigned the role given in role.
    workspace_id str

    The workspace id.

    The following arguments are optional:

    groupIds List<String>
    The AWS SSO group ids to be assigned the role given in role.
    role String
    The grafana role. Valid values can be found here.
    userIds List<String>
    The AWS SSO user ids to be assigned the role given in role.
    workspaceId String

    The workspace id.

    The following arguments are optional:

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi