Example roles and policies
Overview
This topic shows some examples of different roles and policies you can implement with policy statements for roles, integrations access, and Relay Proxy access.
LaunchDarkly provides several preset roles which include access to common sets of features. Customers on select plans can update these presets or create their own roles. If you are looking for example roles or policies, we recommend that you start by examining the preset organization and project roles provided by LaunchDarkly. You can also add policy statements to these roles, if the permissions they provide are not quite what works best for your organization. To learn more, read Member role concepts, Organization roles, and Project roles.
Role examples
Use these sets of policy statements as a starting point for creating or updating roles in your account.
Example: Grant access to specific environments and flags
Expand Example: Grant access to specific environments and flags, by tag
This example policy uses the *
wildcard to allow members of the QA team to administer environments that have tags beginning with qa_
, such as qa_test
, qa_production
, and so on. This policy also allows members to manage flags in environments that have tags beginning with qa_
.
To manage flags in environments tagged qa_*
, you must specify the flag-level resource you want to control. Limiting resources
to "proj/*:env/*;qa_*"
lets you manage the environment itself.
When you recreate this custom role, keep the By default, members can view all LaunchDarkly content box checked.
Copy this policy and make any modifications to it to suit your needs:
Expand Example: Grant access to specific environments and flags, by tag and property-based selector
Here are two example policies that use the {property:value}
pattern to allow actions on environments based on whether or not they are critical environments. You can mark any environment as critical when you create or update it. Production environments default to being marked as critical.
To manage environments based on the critical
property, you must specify the property-based selector as part of the modifiers for the environment resource. Limiting resources
to "proj/*:env/*;{critical:true}"
accomplishes this.
In the first example, the policy allows members of the DevOps team to administer environments that are marked as critical and tagged as fedramp-enabled
. This policy also allows members to manage flags in environments that are marked as critical and tagged as fedramp-enabled
.
Copy this policy and make any modifications to it to suit your needs:
In the second example, the policy allows members of the Support Team to perform all actions on all environments not marked as critical with flags tagged with support
.
Copy this policy and make any modifications to it to suit your needs:
Expand Example: Deny access to bypass approvals in critical environments
This example policy uses the {property:value}
pattern to deny actions on environments based on whether or not they are critical environments. You can mark any environment as critical when you create or update it. Production environments default to being marked as critical.
To manage environments based on the critical
property, you must specify the property-based selector as part of the modifiers for the environment resource. Limiting resources
to "proj/*:env/*;{critical:true}"
accomplishes this.
Copy this policy and make any modifications to it to suit your needs:
Example: Tag-specific permissions
Expand Example: Tag-specific permissions
One way to organize access to resources is by tagging individual resources, and then creating roles with access based on those tags. For example, you can create a dev
tag for your environments and use it in a policy to allow access only to development environments. You can add tags to projects, environments, segments, flags, and metrics.
Copy this policy and make any modifications to it to suit your needs:
Anyone with this role can edit resources that have a dev
tag.
For more tag policy examples, read Tags in role policies.
Example: Grant access to flag toggles, but not flag rollout or targeting rules
Expand Example: Grant access to flag toggles, but not flag rollout or targeting rules
This example policy allows members of the Ops team to toggle on or off any flags in the production environment. They may not change percentage rollouts or targeting rules, or manage any environments or projects.
Copy this policy and make any modifications to it to suit your needs:
Example: Grant all actions to just one flag
Expand Example: Grant all actions to just one flag
The policy below allows all actions to be done to a single specified flag, flag-1
.
For a complete list of flag actions, read Feature flag actions.
Copy this policy and make any modifications to it to suit your needs:
Example: Grant all actions to just one flag while showing only one project
Expand Example: Grant all actions to just one flag while showing only one project
The policy below allows access only to a project a flag is in, and allows you to perform actions on that flag. In this example, both the project and the flag are specified using role attributes. When you assign this role to a member or team, you are prompted to fill in the projectKey
and flagKey
referenced in this role. This means you can reuse this role for different members working on different projects and flags.
Copy this policy and make any modifications to it to suit your needs:
Example: Restrict actions within production environments
Expand Example: Restrict actions within production environments
This policy allows using only these actions in the production
environment:
updateFlagVariations
updateTags
This means you can take all other actions in any other non-production environment. In this example, the environment is set to the production
environment, but the project is specified using a role attribute. When you assign this role to a member or team, you are prompted to fill in the projectKey
referenced in this role. This means you can reuse this role for different members working on different projects.
Copy this policy and make any modifications to it to suit your needs:
Example: Allow access to flags, metrics, and segments in one project
Expand Example: Allow access to flags, metrics, and segments in one project
In this example, the policy allows specific flag actions in one project, all segment actions in all projects, and all metric actions in all projects. The particular project is specified using a role attribute. When you assign this role to a member or team, you are prompted to fill in the projectKey
referenced in this role.
Copy this policy and make any modifications to it to suit your needs:
Example: Deny access to the production environment
Expand Example: Deny access to the production environment
In the next example, the environment key production
represents the account’s production environment in all projects. This policy denies the member from modifying any feature flags in production:
You can also name an “inverse” set of resources by using notResources
in a statement. notResources
explicitly allows all actions to feature flags across all environments except an environment you specify.
In the example below, the combination of notResources
and the allow
effect gives access to all environments except the production environment.
Here’s how:
Base role templates
Unlike the LaunchDarkly-provided preset roles, you cannot edit or view policy details of the base roles in the LaunchDarkly user interface. The sections below show the policy details for these roles. You can copy and modify these Reader, Writer, Admin, and No access role templates for your own roles if needed.
Reader role
Expand Reader role
Copy this Reader base role and make any modifications to it to suit your needs:
Writer role
Expand Writer role
Because permissions are set to deny
by default, you must explicitly allow actions for the Writer role. The code snippet below is a replication of LaunchDarkly’s Writer base role. You can copy it and make adjustments as needed.
Copy this Writer base role and make any modifications to it to suit your needs:
Admin Role
Expand Admin role
Because permissions are set to deny
by default, you must explicitly allow actions for the Admin role. The code snippet below is a replication of LaunchDarkly’s Admin base role. You can copy it and make adjustments as needed.
Copy this Admin base role and make any modifications to it to suit your needs:
No access role
Expand No access role
Permissions are set to deny
by default. In other words, by default roles cannot take any actions on any resources. You must create a policy that provides the level of access you prefer. An empty policy is equivalent to the Member preset role or the No access base role.