Terraform configuration for managing LaunchDarkly resources for Interactive Investor using an existing project.
- Terraform >= 1.13
- LaunchDarkly Provider 2.26.0-beta.4
- Project: Uses existing LaunchDarkly project (
default) - Views:
- Activation (
activation) - Acquisition (
acquisition) - Content and Research (
content-and-research) - Design Architecture and System (
design-architecture-and-system) - Portfolio and Trading (
portfolio-and-trading) - Proposition 2 (
proposition-2) - Servicing 1 (
servicing-1) - Servicing 2 (
servicing-2)
- Activation (
- Teams:
- Activation (
activation) - Acquisition (
acquisition) - Content and Research (
content-and-research) - Design Architecture and System (
design-architecture-and-system) - Portfolio and Trading (
portfolio-and-trading) - Proposition 2 (
proposition-2) - Servicing 1 (
servicing-1) - Servicing 2 (
servicing-2)
- Activation (
- Custom Roles: Five custom roles with different permission levels
Full administrative access to all LaunchDarkly resources including account settings, integrations, members, and all project resources. Mimics the built-in admin role.
- Can manage all flag actions in non-critical environments
- Can submit change requests for critical environments (cannot review/apply them)
- Full access to experiments, metrics, segments, and release pipelines
- Scoped to specific views via role attributes
- Can modify flags and segments in non-critical environments only
- View-only access to critical environments (can update flag metadata but not targeting)
- Full access to experiments, metrics, holdouts, and layers in non-critical environments
- No access to release pipelines
- Scoped to specific views via role attributes
- Read-only access to flags
- Full access to manage experiments, holdouts, layers, metrics, and metric groups in all environments
- Ideal for product managers and business analysts running experiments
- Scoped to specific views via role attributes
- Can modify flag targeting (toggle flags, update rules, targets, and prerequisites) in non-critical environments for testing purposes
- Scoped to specific views via role attributes
This configuration implements a two-tier authorization model:
- Purpose: Define different permission levels based on job functions
- Role Attributes: Reference Views using
$${roleAttribute/viewKeys}in policy statements - Assignment: Assigned directly to LD Members without specifying role attributes at assignment time
- Scoping: All roles (except LD Admins) are scoped to specific views via role attributes
- Purpose: Organize members by team within the organization
- Role Attributes: Each team has
viewKeysattribute scoped to their specific view - Assignment: Members inherit role attributes from team membership
- Lifecycle: Team
member_idsare ignored by Terraform to allow manual management via LaunchDarkly UI - Examples: Activation team members automatically get
viewKeys = ["activation"], Acquisition team members getviewKeys = ["acquisition"], etc.
- Members are assigned custom roles directly (defining their permission level)
- Members are added to teams (inheriting team-specific View access)
- When accessing LaunchDarkly, members' effective permissions are the intersection of their custom role permissions AND their team's view scope
- This allows different personas (roles) within the same team to have different permission levels while maintaining team-based access boundaries
- Additionally, if in the future you decide to implement mapping between LD Custom Roles/Teams and IdP Security Groups, this approach allows reducing the number of the security groups that would need to be created
main.tf- Main configurationvariables.tf- Variable definitionsoutputs.tf- Output definitionsterraform.tfvars.example- Example variables
-
Copy the example file:
cp terraform.tfvars.example terraform.tfvars
-
Edit
terraform.tfvarswith your LaunchDarkly API token and maintainer IDs:launchdarkly_access_token- Your LaunchDarkly API access tokenview_maintainer_id- User ID for view maintainerteam_maintainer_id- User ID for team maintainer
-
Initialize and apply:
terraform init terraform plan terraform apply
This configuration uses an existing LaunchDarkly project (default) and creates:
- Views: Eight team-specific views for organizing feature flags (with SDK keys generated)
- Teams: Eight teams with team-specific role attributes (
viewKeys) - Custom Roles: Five custom roles with different permission levels for various team members
To add a new team/squad, you only need to edit one place in main.tf:
- Locate the
local.teamsmap inmain.tf(around line 48-83) - Add a new entry to the map with the following structure:
your_team_key = { key = "your-team-key" # LaunchDarkly resource key (use kebab-case) name = "Your Team Name" # Display name shown in LaunchDarkly UI }
- Run Terraform:
terraform plan # Preview the changes terraform apply # Create the new view and team
Example:
locals {
teams = {
# ... existing teams ...
new_team = {
key = "new-team"
name = "New Team"
}
}
}The view and team resources will be automatically created from this configuration.
- Locate the team entry in the
local.teamsmap inmain.tf - Update the
keyornamefields as needed - Run Terraform:
terraform plan # Preview the changes terraform apply # Update the resources
- Remove the team entry from the
local.teamsmap inmain.tf - Run Terraform:
terraform plan # Preview the changes (will show destruction) terraform apply # Destroy the view and team
- Only edit the
local.teamsmap - The view and team resources are automatically generated usingfor_eachand should not be edited directly - The map key (e.g.,
activation) is used as the Terraform resource identifier (usesnake_case) - The
keyfield (e.g.,"activation") is used as the LaunchDarkly resource key (usekebab-case) - The
namefield is the display name shown in the LaunchDarkly UI - After making changes, always run
terraform planfirst to preview what will be created/modified/destroyed
- Team membership (
member_ids) is managed outside of Terraform to allow flexible member management via the LaunchDarkly UI - All resources are tagged with team-specific and project tags for organization