Onboarding to views

Overview

This topic explains how to start using views. Views let you logically group flags and segments within a project. You can also control access to these resources using views.

For example, you can use views to group flags according to the teams in your organization and the features they work on. A flag can be linked to more than one view.

Benefits of using views

The benefits of using views include:

  • Consistency and security: Views allow you to organize and control access to sets of resources within a single project.
  • Reduced complexity: When you restrict access to sets of resources, members of your organization can focus on just the items they work with. You can have multiple views per project, which means you can give multiple sets of developers access to some of the same resources if needed.
  • Improved scalability: Many organizations depend on the benefits of having all of their flags in a single project. For instance, using flag prerequisites requires all flags in a dependency chain to be in the same project. Using views means you can continue to use a single project, while limiting access to flags and related resources within that project.

Prerequisites

Members with an Admin, Owner, or Writer base role automatically have access to creating and managing views. After you create the views you want in each project, you can create roles that assign access within the project based on each view.

Create views

We recommend having one member, such as an architect or tech lead, create views for a given project.

To create a new view and link flags to it:

  1. Click the project dropdown. The project menu appears.

  2. Select Project settings.

  3. Select Views. The Views list appears:

    The Views list in project settings.

    The Views list in project settings.
  4. Click Create view. The “Create view” dialog appears:

    The "Create view" dialog.

    The "Create view" dialog.
  5. Enter a unique, human-readable Name for the view.

  6. (Optional) Update the view Key. A suggested key auto-populates from the name you enter, but you can customize it if you wish.

  7. (Optional) Enter a Description.

  8. (Optional) Click the tag icon. Enter a tag name to search for an existing tag or create a new one with that name.

  9. (Optional) Click Add maintainer to set the maintainer of the view. The maintainer defaults to the view’s creator if you do not set one.

  10. Click Create view. The “Add flags to [view]” dialog appears.

  11. Check the flags that you want to include in the view. You can add any segments after you finish creating the view.

  12. Click Add flags.

You can also create a view and then link flags and segments later. To create a view without linking any resources, follow steps 1-9 in the procedure above, check the Create view & close checkbox, and then click Create view.

Assign access based on views

We recommend assigning most members, such as software engineers and product managers, access to the flags and segments they need based on the view that those items are linked to.

For example, to assign access to flags in a particular view, create a role with access to all actions on flags in that view and project.

Here’s how:

Allow access to flags in the "frontend" view in the "default" project
1[
2 {
3 "effect": "allow",
4 "actions": ["*"],
5 "resources": ["proj/default:env/*:flag/*;view:frontend"]
6 }
7]

For additional examples, read Use views in complex policy statements.

If you use views to restrict access to sets of flags and segments, it may be helpful to require that they are associated with a view.

You can require that new flags or segments are linked to a view from Project settings. To learn how, read Require resources to be linked to a view.

An alternative way to enforce this is to create a role that allows the createFlag action only within a particular view.

Here’s an example:

Only allow flag creation in the "frontend" view in the "default" project
1[
2 {
3 "effect": "allow",
4 "actions": ["createFlag"],
5 "resources": ["proj/default:env/*:flag/*;view:frontend"]
6 }
7]

Use views from the list pages

From the Flags list and Segments list in the LaunchDarkly UI, you can use the View menu to show only those items that are linked to selected views:

The "Flags" list with the "View" menu called out.

The "Flags" list with the "View" menu called out.

Manage views with Terraform

You can use the LaunchDarkly Terraform provider to manage your views using Terraform. To learn more, read the provider documentation on the Terraform Registry.

The provider includes the following views-related capabilities:

  • Link flags and segments to views: Use the view_keys attribute on launchdarkly_feature_flag and launchdarkly_segment resources to specify which views a flag or segment should be linked to.
  • Require view association: Use the require_view_association_for_new_flags and require_view_association_for_new_segments attributes on launchdarkly_project to require that new flags or segments are associated with at least one view.
  • Bulk link resources to views: Use the launchdarkly_view_links resource to link multiple flags or segments to a view in a single resource block.

Here is an example of a project that requires flags and segments to be linked to a view:

Require view association for new flags and segments
1resource "launchdarkly_project" "example" {
2 key = "example-project"
3 name = "Example project"
4
5 require_view_association_for_new_flags = true
6 require_view_association_for_new_segments = true
7
8 environments {
9 key = "production"
10 name = "Production"
11 color = "EEEEEE"
12 }
13}

Here is an example of a flag linked to a view:

Link a flag to views
1resource "launchdarkly_feature_flag" "example" {
2 project_key = "example-project"
3 key = "example-flag"
4 name = "Example flag"
5 variation_type = "boolean"
6
7 view_keys = ["frontend-team", "mobile-team"]
8
9 variations {
10 value = true
11 }
12 variations {
13 value = false
14 }
15}

Next steps

For additional information on managing views, read Views. To learn more about creating roles, read Creating roles and policies.