### Fetch User by Email Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/user.md This example shows how to fetch user details by providing their email address. ```APIDOC ## Fetch User by Email ### Description Retrieves user information using the user's email address. ### Parameters #### Query Parameters - **email** (String) - Required - The email address of the user. ### Request Example ```terraform data "unleash_user" "search_by_email" { email = "byemail@example.com" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier of the user. - **username** (String) - The username of the user. - **name** (String) - The name of the user. - **email** (String) - The email address of the user. - **root_role** (Number) - The role ID assigned to the user. ``` -------------------------------- ### Create a user with a password Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/user.md This example demonstrates how to create a user and set their password directly. Note that the password field is sensitive and should be handled with care. ```terraform resource "unleash_user" "with_password" { email = "visiblepassword@example.com" name = "Iam Transparent" root_role = 1 send_email = false password = "youcanseeme" } ``` -------------------------------- ### Build Terraform Provider Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Build the Unleash Terraform provider using the Go install command. Ensure Go is installed and you are in the repository directory. ```shell go install ``` -------------------------------- ### Lint and Generate Docs Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Before pushing, lint the code using golangci-lint and generate or update documentation using go generate. Ensure golangci-lint is installed. ```shell golangci-lint run --fix go generate ./... ``` -------------------------------- ### Fetch a permission by name and environment Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/permission.md This example shows how to fetch a permission that is specific to a particular environment. Both `name` and `environment` attributes are required. ```APIDOC ## Data Source: unleash_permission Fetch a permission. ### Example Usage ```terraform data "unleash_permission" "create_feature_strategy" { name = "CREATE_FEATURE_STRATEGY" environment = "development" } ``` ### Schema #### Required - `name` (String) The name of the permission. #### Optional - `environment` (String) Which environment this permission applies to. #### Read-Only - `display_name` (String) The name to display in listings of permissions. - `id` (Number) Identifier for this permission. - `type` (String) What level this permission applies to. Either root, project or the name of the environment it applies to. ``` -------------------------------- ### Fetch a permission by name Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/permission.md This example demonstrates how to fetch a permission using its name. The `name` attribute is required. ```APIDOC ## Data Source: unleash_permission Fetch a permission. ### Example Usage ```terraform data "unleash_permission" "create_project" { name = "CREATE_PROJECT" } ``` ### Schema #### Required - `name` (String) The name of the permission. #### Optional - `environment` (String) Which environment this permission applies to. #### Read-Only - `display_name` (String) The name to display in listings of permissions. - `id` (Number) Identifier for this permission. - `type` (String) What level this permission applies to. Either root, project or the name of the environment it applies to. ``` -------------------------------- ### Fetch User by ID Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/user.md This example demonstrates how to retrieve a user's details using their unique identifier. ```APIDOC ## Fetch User by ID ### Description Retrieves user information using the user's ID. ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier of the user. ### Request Example ```terraform data "unleash_user" "admin" { id = "1" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier of the user. - **username** (String) - The username of the user. - **name** (String) - The name of the user. - **email** (String) - The email address of the user. - **root_role** (Number) - The role ID assigned to the user. ``` -------------------------------- ### Create a Service Account Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/service_account.md Example of creating a service account with a specific name, username, and root role. It is recommended to use the `unleash_role` data source to fetch the role ID. ```terraform data "unleash_role" "admin_role" { name = "Admin" } resource "unleash_service_account" "admin service account" { name = "something unique" username = "something unique" root_role = admin_role.id } ``` -------------------------------- ### Run All Terraform Stages Source: https://github.com/unleash/terraform-provider-unleash/blob/main/examples/staged/README.md Execute all defined stages of the Terraform Unleash setup. This command performs a cleanup before running the stages. ```shell make ``` -------------------------------- ### Create a context field with legal values and description Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/context_field.md This example demonstrates creating a context field with a description and predefined legal values, which restricts the possible inputs for this field. ```terraform resource "unleash_context_field" "cheese_context_field" { name = "cheese" stickiness = true description = "Type of cheese to constrain on" legal_values = [ { value = "brie" description = "Gooey, delicious" } ] } ``` -------------------------------- ### Store Service Account Token in a File Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/service_account_token.md This example demonstrates how to output the generated service account token secret to a file. It is recommended to use a secret manager instead of a plain text file for security reasons. The `local-exec` provisioner is used to run a bash script that echoes the token value and redirects it to a specified file. The `triggers` block ensures the provisioner runs when the token secret changes. ```terraform resource "null_resource" "store_token" { provisioner "local-exec" { command = < /secure/location/service_account_token.txt EOT } triggers = { token_created = unleash_service_account_token.token_for_account_test.secret } } ``` -------------------------------- ### Run Specific Terraform Stages Source: https://github.com/unleash/terraform-provider-unleash/blob/main/examples/staged/README.md Execute individual stages or a selection of stages for the Terraform Unleash setup. Useful for debugging or focusing on specific configurations. ```shell make STAGES="stage_1" # or make STAGES="stage_1 stage_2" # because the stages are stateless, you can run them in any order (one by one or just execute any) make STAGES="stage_4" ``` -------------------------------- ### Update Custom Root Role Permissions Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/role.md This example shows how to modify an existing custom root role by changing its associated permissions. The `name` and `type` remain the same, but the `permissions` block is updated. ```terraform resource "unleash_role" "custom_root_role" { name = "Renamed custom role" type = "root-custom" description = "A custom test root role" permissions = [{ name = "CREATE_SEGMENT" }, { name = "UPDATE_SEGMENT" }] } ``` -------------------------------- ### Create a new user with basic details Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/user.md Use this snippet to create a new user with their email, name, and a root role. The `send_email` flag controls whether a welcome email is sent. Defaults to false. ```terraform resource "unleash_user" "admin" { email = "admin@chucknorris.com" name = "Chuck Norris" root_role = 1 send_email = false } ``` ```terraform resource "unleash_user" "chuck" { email = "doesnotneedemail@chucknorris.com" name = "Chuck Norris" root_role = 1 send_email = false } ``` -------------------------------- ### Run Acceptance Tests with Make Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Run acceptance tests using the make testacc target. This is a convenient way to execute the full suite of acceptance tests. ```shell make testacc ``` -------------------------------- ### Run Enterprise Acceptance Tests (Pro Plan) Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Execute enterprise-compatible acceptance tests against the Pro plan. Sets UNLEASH_ENTERPRISE and UNLEASH_PLAN environment variables. ```shell UNLEASH_ENTERPRISE=true UNLEASH_PLAN=pro TF_LOG=debug TF_ACC=1 go test ./... -v -count=1 ``` -------------------------------- ### unleash_project Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/project.md Fetch a project definition. ```APIDOC ## unleash_project (Data Source) ### Description Fetch a project definition. ### Schema #### Required - `id` (String) The id of this project. #### Optional - `description` (String) A description of the project's purpose. - `mode` (String) The project's collaboration mode. Determines whether non project members can submit change requests and the projects visibility to non members. Valid values are 'open', 'protected' and 'private'. If a value is not set, the project will default to 'open' ### Read-Only - `name` (String) The name of this project. ``` -------------------------------- ### Create a Project Environment Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/project_environment.md Use this resource to link a project and an environment, and configure change request settings. Ensure the project and environment resources are defined first. ```terraform resource "unleash_project" "project_1" { id = "one" name = "First project" description = "My first project" } resource "unleash_environment" "space" { name = "outerspace" type = "vacuum" } resource "unleash_project_environment" "space_environment" { project_id = unleash_project.project_1.id environment_name = unleash_environment.space.name change_requests_enabled = true required_approvals = 2 } ``` -------------------------------- ### Create a Frontend API Token for All Projects Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/api_token.md Use this snippet to create a frontend API token that has access to all projects. Ensure the `expires_at` field is set to a future date and time in ISO 8601 format. ```terraform resource "unleash_api_token" "frontend_token" { token_name = "frontend_token" type = "frontend" expires_at = "2024-12-31T23:59:59Z" projects = ["*"] environment = "development" } ``` -------------------------------- ### Basic SAML Configuration Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/saml.md Configure basic SAML settings including enabling the feature, providing the certificate, entity ID, and sign-on URL. Optionally, enable user auto-creation and set a default root role. ```terraform resource "unleash_saml" "simple_saml_config" { enabled = true certificate = "test-certificate" entity_id = "some-entity-id" sign_on_url = "http://other-places.com" auto_create = true default_root_role = 1 } ``` -------------------------------- ### unleash_saml Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/saml.md Manages SAML configuration. This resource allows you to enable or disable SAML, configure the certificate, entity ID, sign-on URL, and user auto-creation settings. ```APIDOC ## Resource: unleash_saml ### Description Manages SAML configuration for Unleash. ### Schema #### Required - `certificate` (String) - The x509 certificate used by the SAML provider. - `enabled` (Boolean) - Whether SAML is enabled. - `entity_id` (String) - The SAML entity ID. - `sign_on_url` (String) - The SAML sign-on URL. #### Optional - `auto_create` (Boolean) - Whether to auto create users when they login to Unleash for the first time. - `default_root_role` (Number) - The default root role give to a user when that user is created. Only used if auto_create is set to true. ### Example Usage ```terraform resource "unleash_saml" "simple_saml_config" { enabled = true certificate = "test-certificate" entity_id = "some-entity-id" sign_on_url = "http://other-places.com" auto_create = true default_root_role = 1 } ``` ``` -------------------------------- ### Run Enterprise Acceptance Tests Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Execute enterprise-compatible acceptance tests. Requires an enterprise Unleash server and sets the UNLEASH_ENTERPRISE environment variable. ```shell UNLEASH_ENTERPRISE=true TF_LOG=debug TF_ACC=1 go test ./... -v -count=1 ``` -------------------------------- ### Basic OIDC Configuration Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/oidc.md Configure basic OIDC settings, including enabling the feature, providing the discovery URL, client ID, and secret. Optionally, enable automatic user creation and set a default root role. ```terraform resource "unleash_oidc" "simple_oidc_config" { enabled = true discover_url = "http://mock-openid-server:9000/.well-known/openid-configuration" secret = "kinda-sorta-secret" client_id = "client-id" auto_create = true default_root_role = 1 } ``` -------------------------------- ### Fetch a project definition Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/project.md Use this data source to fetch an existing project definition by its ID. The `id` argument is required. ```terraform data "unleash_project" "test" { id = "default" } ``` -------------------------------- ### Create an Unleash Environment Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/environment.md Use this resource to create a new Unleash environment. Ensure the name is URL-friendly. Changing the name requires resource replacement. ```terraform resource "unleash_environment" "space" { name = "outerspace" type = "vacuum" } ``` -------------------------------- ### Run All Tests Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Execute all tests for the Unleash Terraform provider. This command runs tests with a count of 1 and verbose output. ```shell go test -count=1 -v ./... ``` -------------------------------- ### Create and Configure an Unleash Project Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/project.md Defines an Unleash project with a name, description, collaboration mode, feature naming pattern, and link templates. The 'protected' mode restricts changes to project members. The feature naming pattern enforces specific naming conventions for features within the project. ```terraform import { id = "default" to = unleash_project.default_project } resource "unleash_project" "default_project" { id = "default" name = "Default project" description = "Default project now managed by Terraform" } resource "unleash_project" "test_project" { id = "my_project" name = "My Terraform project" description = "A project created through terraform" mode = "protected" feature_naming = { pattern = "^feature_[a-z0-9_-]+$" example = "feature_user_signup" description = "Feature keys must start with feature_ and use lowercase alphanumerics." } link_templates = [ { title = "Product Spec" url_template = "https://docs.example.com/projects/{{project}}/features/{{feature}}" }, { title = "Issue Tracker" url_template = "https://issues.example.com/browse/{{feature}}" } ] } ``` -------------------------------- ### unleash_project_environment Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/project_environment.md The unleash_project_environment data source allows you to retrieve information about a project environment within Unleash. ```APIDOC ## Schema ### Required - `environment_name` (String) Environment identifier, equivalent to the environment name. - `project_id` (String) Project identifier. ### Read-Only - `change_requests_enabled` (Boolean) If change requests are required for this environment, the environment must be enabled for this to have effect. - `enabled` (Boolean) If the environment is enabled for this project. This affects whether or not users will be able to enable flags for this environment on this project. - `required_approvals` (Number) Number of approvals required for change requests. ``` -------------------------------- ### Run Acceptance Tests Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Execute acceptance tests for the Unleash Terraform provider. This command enables debug logging and sets the TF_ACC environment variable. ```shell TF_LOG=debug TF_ACC=1 go test ./... -v -count=1 ``` -------------------------------- ### Fetch User by Email Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/user.md Use the `email` argument to retrieve a user based on their email address. The email must be unique and associated with an existing user. ```terraform data "unleash_user" "search_by_email" { email = "byemail@example.com" } ``` -------------------------------- ### Create a Frontend API Token for a Specific Project Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/api_token.md This snippet demonstrates how to create a frontend API token with access restricted to a specific project. The `projects` list should contain the desired project names. ```terraform resource "unleash_api_token" "frontend_token" { token_name = "frontend_token" type = "frontend" expires_at = "2024-12-31T23:59:59Z" projects = ["default"] environment = "development" } ``` -------------------------------- ### Configure the Unleash Provider Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/index.md Configure the Unleash provider with your Unleash instance's base URL and an authorization token. The authorization token should have the necessary permissions for the operations you intend to perform. ```terraform provider "unleash" { base_url = "http://localhost:4242" authorization = "*:*.admin-token" } ``` -------------------------------- ### Fetch a permission by name Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/permission.md Use this snippet to fetch a permission by its name. This is useful for retrieving details about general permissions that apply across all environments. ```terraform data "unleash_permission" "create_project" { name = "CREATE_PROJECT" } data "unleash_permission" "update_project" { name = "UPDATE_PROJECT" } ``` -------------------------------- ### Create a Service Account Token Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/service_account_token.md This resource creates a new token for a service account. The token's secret must be used immediately upon creation, typically by piping it to a secret manager or another resource. The `expires_at` field specifies the token's expiration. ```terraform resource "unleash_service_account" "account_for_tokens_test" { name = "the service account name" username = "some descriptive name" root_role = 1 } resource "unleash_service_account_token" "token_for_account_test" { service_account_id = unleash_service_account.account_for_tokens_test.id description = "a token for the account" expires_at = "2048-01-01T00:00:00Z" } ``` -------------------------------- ### Fetch User by ID Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/user.md Use the `id` argument to retrieve a specific user. Ensure the user ID exists in your Unleash instance. ```terraform data "unleash_user" "admin" { id = "1" } ``` -------------------------------- ### Create a basic context field Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/context_field.md Use this snippet to create a simple context field with only a name. This is the minimum required configuration. ```terraform resource "unleash_context_field" "ham_context_field" { name = "ham" } ``` -------------------------------- ### unleash_user Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/user.md Manages a user within the Unleash system. This resource allows for the creation, configuration, and management of user accounts, including their email, name, role, and optionally a password. ```APIDOC ## unleash_user (Resource) ### Description Manages a user within the Unleash system. This resource allows for the creation, configuration, and management of user accounts, including their email, name, role, and optionally a password. ### Schema #### Required - `root_role` (Number) - The role id for the user. #### Optional - `email` (String) - The email of the user. - `name` (String) - The name of the user. - `password` (String, Sensitive) - The password of the user. - `send_email` (Boolean) - Send a welcome email to the customer or not. Defaults to false - `username` (String) - The username. #### Read-Only - `id` (String) - Identifier for this user. ### Example Usage ```terraform resource "unleash_user" "admin" { email = "admin@chucknorris.com" name = "Chuck Norris" root_role = 1 send_email = false } ``` ``` -------------------------------- ### unleash_project_access Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/project_access.md Manages project access by assigning roles to users and groups within a specific project. ```APIDOC ## unleash_project_access (Resource) ### Description Manages project access by assigning roles to users and groups within a specific project. ### Schema #### Required - `project` (String) Project identifier. - `roles` (Attributes Set) Roles available in this project with their members. (see [below for nested schema](#nestedatt--roles)) ### Nested Schema for `roles` Required: - `groups` (Set of Number) List of projects with this role assigned. - `role` (Number) The role identifier. - `users` (Set of Number) List of users with this role assigned. ``` -------------------------------- ### Fetch a permission by name and environment Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/permission.md Use this snippet to fetch a permission that is specific to a particular environment. This is useful for managing or querying permissions that have environment-specific configurations. ```terraform data "unleash_permission" "create_feature_strategy" { name = "CREATE_FEATURE_STRATEGY" environment = "development" } ``` -------------------------------- ### Configure Local Provider Registry Source: https://github.com/unleash/terraform-provider-unleash/blob/main/README.md Configure Terraform to use a local copy of the provider instead of downloading from the registry. Create a .terraformrc file with the provider_installation block. ```hcl provider_installation { dev_overrides { "Unleash/unleash" = "/usr/local/go/bin/" } direct {} } ``` -------------------------------- ### Enable Debug Logging for Terraform Source: https://github.com/unleash/terraform-provider-unleash/blob/main/examples/staged/README.md Run Terraform commands with debug logging enabled to capture detailed information about the execution process. This is helpful for troubleshooting. ```shell make TF_LOG=debug ``` -------------------------------- ### Create and manage project access Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/project_access.md Use this resource to define which users and groups have specific roles within a project. Ensure that the project, roles, and users/groups referenced already exist. ```terraform import { id = "default" to = unleash_project_access.default_project_access } resource "unleash_project" "sample_project" { id = "sample" name = "sample-project" } data "unleash_role" "project_owner_role" { name = "Owner" } data "unleash_role" "project_member_role" { name = "Member" } resource "unleash_user" "test_user" { name = "tester" email = "test-password@getunleash.io" password = "you-will-never-guess" root_role = "3" send_email = false } resource "unleash_user" "test_user_2" { name = "tester-2" email = "test-2-password@getunleash.io" password = "you-will-never-guess" root_role = "3" send_email = false } resource "unleash_project_access" "sample_project_access" { project = unleash_project.sample_project.id roles = [ { role = data.unleash_role.project_owner_role.id users = [ unleash_user.test_user.id ] groups = [] }, { role = data.unleash_role.project_member_role.id users = [ unleash_user.test_user_2.id ] groups = [] }, ] } resource "unleash_project_access" "default_project_access" { project = "default" roles = [ { role = data.unleash_role.project_owner_role.id users = [ unleash_user.test_user.id ] groups = [] }, ] } ``` -------------------------------- ### unleash_role Data Source Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/role.md Fetch a role definition by its name. ```APIDOC ## unleash_role (Data Source) ### Description Fetch a role definition. ### Parameters #### Required - **name** (String) The name of this role. #### Read-Only - **description** (String) A more detailed description of the role and what use it's intended for. - **id** (Number) The id of this role. - **type** (String) A role can either be a global root role (applies to all roles) or a role role. ### Example Usage ```terraform data "unleash_role" "admin_role" { name = "Admin" } data "unleash_role" "editor_role" { name = "Editor" } data "unleash_role" "project_member_role" { name = "Member" } ``` ``` -------------------------------- ### unleash_environment Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/environment.md Manages an Unleash environment. This resource defines a new environment within Unleash, specifying its name and type. ```APIDOC ## unleash_environment Resource ### Description Manages an Unleash environment. This resource defines a new environment within Unleash, specifying its name and type. ### Parameters #### Required - **name** (String) - The name of the environment. Must be a URL-friendly string according to RFC 3968. Changing this property will require the resource to be replaced, it's generally safer to remove this resource and create a new one. - **type** (String) - The type of the environment. Unleash recognizes 'development', 'test', 'preproduction' and 'production'. You can pass other values and Unleash will accept them but they will carry no special semantics. ### Request Example ```terraform resource "unleash_environment" "space" { name = "outerspace" type = "vacuum" } ``` ``` -------------------------------- ### unleash_service_account_token Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/service_account_token.md Manages the creation and deletion of service account tokens. Due to their immutability, tokens are rotated on any change to the resource. ```APIDOC ## Resource: unleash_service_account_token ### Description Allows for managing the tokens bound to a service account. Note that service account tokens in Unleash are both immutable and cannot be recovered once created. This means you must use them immediately when creating them via terraform. Typically by piping them to an external secret manager or binding them to some other external terraform resource that requires Unleash tokens. Because service account tokens are immutable, any changes to the terraform resource will trigger a deletion and recreation of those tokens, meaning that the secrets will be rotated out. ### Schema #### Required - `description` (String) The description of the service account token. - `expires_at` (String) The expiration date of the service account token. - `service_account_id` (Number) The ID of the service account this token is bound to. #### Read-Only - `id` (Number) The ID of the service account. - `secret` (String, Sensitive) The secret of the service account token. ``` -------------------------------- ### Create a Custom Root Role Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/role.md Use this snippet to define a custom root role with specific permissions that apply globally. Ensure the `type` is set to `root-custom`. ```terraform resource "unleash_role" "custom_root_role" { name = "A custom role" type = "root-custom" description = "A custom test root role" permissions = [{ name = "CREATE_PROJECT" }, { name = "UPDATE_PROJECT" }] } ``` -------------------------------- ### Fetch Role Definition Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/role.md Use the `unleash_role` data source to retrieve information about predefined roles like 'Admin', 'Editor', or 'Member'. This is useful for referencing existing roles in your Terraform configuration. ```terraform data "unleash_role" "admin_role" { name = "Admin" } data "unleash_role" "editor_role" { name = "Editor" } data "unleash_role" "project_member_role" { name = "Member" } ``` -------------------------------- ### Create a Custom Project Role Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/role.md Define a custom role that applies to specific projects. This snippet includes permissions that can be environment-specific, using the `environment` attribute within the `permissions` block. ```terraform resource "unleash_role" "project_role" { name = "Custom project role" description = "A custom test project role" type = "custom" permissions = [{ name = "CREATE_FEATURE" }, { name = "DELETE_FEATURE" }, { name = "UPDATE_FEATURE_ENVIRONMENT" environment = "development" }] } ``` -------------------------------- ### unleash_context_field Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/data-sources/context_field.md Fetches a context field by its name. ```APIDOC ## Schema ### Required - `name` (String) The name of the context field. ### Optional - `description` (String) A description of the context field. - `legal_values` (Attributes List) Legal values for this context field. If not set, then any value is available for this context field. (see [below for nested schema](#nestedatt--legal_values)) - `stickiness` (Boolean) Whether this field is available for custom stickiness ### Nested Schema for `legal_values` Read-Only: - `description` (String) Description of the allowed value. - `value` (String) The allowed value. ``` -------------------------------- ### unleash_context_field Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/context_field.md The `unleash_context_field` resource allows you to manage context fields within Unleash. You can define their names, descriptions, and legal values. ```APIDOC ## Schema ### Required - `name` (String) The name of the context field. ### Optional - `description` (String) A description of the context field. - `legal_values` (Attributes List) Legal values for this context field. If not set, then any value is available for this context field. (see [below for nested schema](#nestedatt--legal_values)) - `stickiness` (Boolean) Whether this field is available for custom stickiness. Defaults to false if not set. ### Nested Schema for `legal_values` Required: - `value` (String) The allowed value. Optional: - `description` (String) Description of the allowed value. ``` -------------------------------- ### unleash_group Resource Schema Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/group.md Defines the schema for the unleash_group resource, including required, optional, and read-only attributes. ```APIDOC ## Schema ### Required - `name` (String) Name for this group ### Optional - `description` (String) A description of the group's purpose. - `mappings_sso` (List of String) SSO group mappings for this group. - `root_role` (Number) The root role ID for this group. - `users` (List of Number) List of user IDs to add to this group ### Read-Only - `id` (String) Identifier for this group ``` -------------------------------- ### Use Service Account Token with an External Resource Source: https://github.com/unleash/terraform-provider-unleash/blob/main/docs/resources/service_account_token.md This snippet shows how to use a service account token with an external resource that requires an Unleash API key for integration. The `unleash_service_account_token.token_for_account_test.secret` is passed directly as the `unleash_api_key` argument to the `external_resource`. ```terraform resource "external_resource" "external_unleash_integration" { unleash_api_key = unleash_service_account_token.token_for_account_test.secret } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.