This guide explains how LaunchDarkly partners can use the REST API to build an Environment as a Service (EaaS) integration. By the end of this guide, you as a LaunchDarkly partner should have the information you need to create an integration that can manage the full lifecycle of on-demand LaunchDarkly environments.
LaunchDarkly feature management gives customers the ability to enable certain features only for specific application environments, or for specific end users within those environments.
Organizations that use ephemeral environments for development and testing need feature management specific to their ephemeral environment. This gives developers control of application features independent of other environments. It minimizes the risk of toggling features impacting other development efforts.
If you are a LaunchDarkly partner providing EaaS, you can use the LaunchDarkly REST API as part of your integration to create, and then delete, a separate LaunchDarkly environment that is specific to the ephemeral environment you’re providing for development and testing.
In LaunchDarkly, environments are organizational units contained within projects. LaunchDarkly customers will already have a configured project that they are looking to use.
Environments allow LaunchDarkly customers to manage feature flags throughout the entire development lifecycle, from local development through production. Examples of LaunchDarkly environments within a project could be Production, QA, Staging, or individual environments. The exact naming is left to LaunchDarkly customers to configure.
To learn more, read Environments.
Environments are nested under projects and contain environment-specific metadata. When you create a new environment, all feature flag targeting is set to default values for the environment, or, if you specify a source parameter during creation, feature flag targeting is set to match that source environment.
Here’s a visualization:
To build an integration, make sure you meet the prerequisites. Then follow the steps outlined on the Getting started page.
The Getting started page explains each of the following steps in detail:
"otherCapabilities"" ["external"].For an EaaS integration, include requests to create and delete a LaunchDarkly environment each time you spin up and shut down an ephemeral environment. The following sections describe the required request format.
All API calls from LaunchDarkly partners should include a custom User-Agent:
Your integration can use either API keys or OAuth for authentication:
LaunchDarkly has support for OAuth clients. The only two types of scoped permissions are currently reader and writer. An EaaS integration needs the writer scope so it can create and delete environments. However, your customers may not want to provide the level of access overall that this functionality would grant.
The endpoint to create a new environment accepts a POST body in JSON format. The minimum set of required parameters is:
key: The environment keyname: The environment namecolor: The HTML hex color code for the environment when viewed in the LaunchDarkly user interface (UI)Most EaaS integrations will want to leverage the source parameter to use another environment’s targeting to clone. There are no hard-coded environment keys in LaunchDarkly.
If a customer creates a project in LaunchDarkly without specifying environments, by default LaunchDarkly creates two environments, prod and test. If the customer creates a project and does specify environments, then those defaults will not be used.
Optionally you, the partner, may want to tag environments with a consistent value so it is easier to query the LaunchDarkly API for a list of those environments.
As a partner you will have to allow your end users to provide a LaunchDarkly Environment key that they want to use as the value of the source parameter.
You can also use the REST API: Create a LaunchDarkly environment
In your EaaS integration, you should clean up any LaunchDarkly environments that you create when the associated ephemeral environment no longer exists. If you need to recreate the LaunchDarkly environment later, you can recreate it on demand using the source environment to get the latest flags. This also helps your customers experience less drift between LaunchDarkly environments if they have been in existence for an extended period of time.
You can also use the REST API: Delete a LaunchDarkly environment
This manifest is required for an integration. It renders your integration metadata inside of the LaunchDarkly UI.
This guide describes the process of building an ephemeral Environments as a Service (EaaS) integration. The crucial step is to have your integration create, and then delete, a LaunchDarkly environment each time you spin up and shut down an ephemeral environment. To learn more about building your own integrations, read Building partner integrations.