Legacy Dev Forum Posts

 View Only

Sign Up

Creating Roles with Terraform

  • 1.  Creating Roles with Terraform

    Posted 06-05-2025 18:25

    VernonVanDam | 2023-04-19 03:54:13 UTC | #1

    Hi Team

    I'm trying to get Terraform to deploy a new Role. I'm using the code:

    resource "genesyscloudauthrole" "agentrole" { name = "Terraform Agent Role" description = "Custom Terraform Role for Agents" permissions = ["groupcreation", "employee"] permissionpolicies { domain = "conversation" entityname = "call" action_set = ["accept", "add", "record"] } }

    This works fine and creates the Role with only the 3 permissions set. How do I increase the permission_policies to list various permissions that need to assigned to this role?

    I'm using a JSON export of the users role as example and it contains multiple permission_policies but somehow that doesnt translate to a tf file.

    Sample JSON I'm using:

    "User": { "defaultroleid": "engage", "description": "Role for basic agent functions", "name": "User", "permissionpolicies": [ { "actionset": [ "accept", "add", "record" ], "conditions": null, "domain": "conversation", "entityname": "call" }, { "actionset": [ "accept", "create", "forward" ], "conditions": null, "domain": "conversation", "entity_name": "email" },

    Thanx V


    Hemanth | 2023-04-19 10:47:24 UTC | #2

    If you want to have more entities to be added to specfic permissions. You can add a new permission_policies describing the entity and actions for that enitity

    resource "genesyscloudauthrole" "agentrole" { name = "Terraform Agent Role" description = "Custom Terraform Role for Agents" permissions = ["groupcreation", "employee"] permissionpolicies { domain = "conversation" entityname = "call" actionset = ["accept", "add", "record"] } permissionpolicies { domain = "conversation" entityname = "email" actionset = ["accept", "add", "record"] } }


    VernonVanDam | 2023-04-19 22:56:20 UTC | #3

    Thanx Hemanth, that worked. My final code looks like this:

    resource "genesyscloudauthrole" "agentrole" { > name = "Terraform Agent Role" > description = "Custom Terraform Role for Agents" > permissions = ["groupcreation", "employee"] > permissionpolicies { > domain = "conversation" > entityname = "call" > actionset = ["accept", "add", "record"] > } > permissionpolicies { > domain = "conversation" > entityname = "email" > actionset = ["accept", "create", "forward"] > } > }

    Is there an easier way to convert the JSON export to a Terraform resource format or is this a manual process?


    This post was migrated from the old Developer Forum.

    ref: 19524