Example LaunchDarkly project configured using the LaunchDarkly Terraform provider
This repository contains a series of directories containing detailed examples of how to configure LaunchDarkly via the Terraform provider. Click here for the official documentation on the Terraform website. A description of the examples included here can be found in the Contents section.
! TAKE NOTE! Running
terraform apply
on any of these directories with your auth credentials will result in real resources being created that may cost real money. These are meant to be used as examples only and LaunchDarkly is not responsible for any costs incurred via testing.
Before getting started with the LaunchDarkly Terraform provider, make sure you have Terraform correctly installed and configured. For more on this, see the Setup section.
-
v1 contains examples of configurations compatible with v1.X of the LaunchDarkly provider. Please note that this version is no longer maintained.
- v1/full_config contains an example of a simple but fully fleshed-out LaunchDarkly project configuration, including environments, feature flags, team members, roles, and segments. It provides an example of how to organize a more complex configuration with multiple resources.
- v1/multiple_projects contains an example of the simultaneous configuration of multiple projects and associated environments and flags in a single file.
- v1/feature_flags contains a full range of flag examples, covering both flag variation types and complex targeting rules.
-
v2 contains examples of configurations compatible with v2+ of the LaunchDarkly provider.
- v2/full_config contains an example of a simple but fully fleshed-out LaunchDarkly project configuration with nested environments, feature flags, team members, roles, and segments. It provides an example of how to organize a more complex configuration with multiple resources.
- v2/feature_flags contains a full range of flag examples, covering both flag variation types and complex targeting rules.
- v2/environment contains an example of how to configure a standalone LaunchDarkly environment in Terraform. Please note that this is only recommended in v2 of the provider if you wish to manage the encapsulating project outside of Terraform.
- v2/segment contains an example of a LaunchDarkly segment configuration to send LD event notifications to an external endpoint.
- v2/webhook contains an example of a LaunchDarkly webhook configuration to send LD event notifications to an external endpoint.
- v2/data_source_destination provides an example of how to configure a LaunchDarkly data export destination data source for easy reference in other resources.
- v2/data_source_webhook provides an example of how to configure a LaunchDarkly webhook data source for easy reference in other resources.
-
access_token contains an example of how to configure LaunchDarkly access tokens using Terraform. This configuration is compatible with both v1 and v2 of the provider.
-
custom_role contains an example of how to configure a custom role within LaunchDarkly using Terraform. This configuration is compatible with both v1 and v2 of the provider.
-
team_member contains an example of how to configure a team member within LaunchDarkly using Terraform. This configuration is compatible with both v1 and v2 of the provider.
-
For an example of how to configure your provider if using Terraform version 0.13 or above, please see the terraform_0.13.
First and foremost, you need to make sure you have Terraform installed on the machine you will be applying the configurations from and that you meet the requirements listed on the project readme. For instructions on how to install Terraform, see here.
Before getting started with the LaunchDarkly provider, you need to ensure you have your LaunchDarkly credentials properly set up. All you will need for this is a LaunchDarkly access token, which you can create via the LaunchDarkly platform under Account settings > Authorization.
Once you have your access token in hand, there are several ways to set variables within your Terraform context. For the sake of ease, we've set the access token as an environmental variable named LAUNCHDARKLY_ACCESS_TOKEN
. The provider configuration will then automatically access it from your environment so that your provider config should only have to contain
provider "launchdarkly" {
version = "~> 1.0"
}
! TAKE NOTE! If you are using Terraform version 0.13 or above, your provider block will be nested inside of your
terraform
block as seen below.
terraform {
required_providers {
launchdarkly = {
source = "launchdarkly/launchdarkly"
version = "~> 1.5"
}
}
required_version = ">= 0.13"
}
Some resources or attributes, such as webhook policy_statements, that were added later may require a provider version later than 1.0; check the changelog for more information on versions.
If you would prefer to define your variables some other way, see Terraform's documentation on input variables for some other ways to do so.