blog post banner image

DevCycle Releases Terraform Provider: Managing Feature Flags and Infrastructure as Code

Victor Vucicevich


Today, we're excited to announce the release of our Terraform provider! This new feature allows developers to manage their feature flags and infrastructure as code. With DevCycle's Terraform provider, you can now apply your entire SCM process and pipeline around it, catering to your safety and review process. Release with even more confidence!

What is Terraform?

If you're a developer, then chances are you've heard of Terraform. And if you haven't, well, let me introduce you to what is about to become your new best friend. Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. It's open-source and has been battle-tested by some of the biggest companies in the world.

Introducing DevCycle for Terraform

With the DevCycle terraform provider, you can manage your feature flags and your infrastructure using code. This is a really great way to keep track of everything and make sure it all works the way you want it to.  You can also apply your entire SCM process and pipeline around it, so you can have complete confidence in your deployments.

How this new provider will help you

This new provider will help you save time and energy when managing your feature flags and infrastructure. It's easy to use and it will make sure everything is up-to-date and working the way you want it to. So if you're a developer, then I highly recommend checking out DevCycle's terraform provider!

How to get started with this new provider

First, Install the provider:

Install the Terraform Provider

terraform {  
required_providers {    
devcycle = {      
source = "DevCycleHQ/devcycle"    
version = "1.0.0"    }  
}}provider "devcycle" {  
client_id = "your-client-id"  
client_secret = "your-client-secret"
server_sdk_token = "project-specific-server-sdk-token"}

Set up DevCycle API Credentials

All actions by the Terraform provider are scoped at the organization root level. This requires DevCycle API authorization. Your DevCycle organization's client ID and secret must be provided. They can be obtained from the settings page of the DevCycle dashboard.

There are several ways to provide these credentials:

Directly in the Terraform configuration

This is not recommended, as your credentials will be visible in your Terraform state. But if you are securly controlling access to the state file, then this can be used safely. Set the client_id and client_secret fields in the provider.devcycle block in your Terraform configuration to the respective values. These will be used to get an OAuth2 access token at the time of use - this value is not stored in the Terraform state file for security.

For the server_sdk_token field, this is scoped to a single DevCycle project. This should be the project you want to control your resources from. The server sdk token can be found in the same settings page as the client id and secret - but you need to select the right project first.

Environment Variables

Set the following environment variables:

$ export DEVCYCLE_CLIENT_ID=<your client id>$ export DEVCYCLE_CLIENT_SECRET=<your client secret>$ export DEVCYCLE_SERVER_TOKEN=<your server token>

Terraform will use these as a fallback from the provider passed variables. Meaning the values in the configuration block will take precedence over the environment variables.


For more detailed documentation on the DevCycle Terraform provider, see the DevCycle Terraform Provider Documentation

After configuration of the provider - let's use the provider to create a DevCycle project.

Quick example: Creating a Project

*resource "devcycle_project"* "example" {  name        = "Example DevCycle Project"  key         = "example-devcycle-project"  description = "Terraform example project"}

Running terraform apply will create this project - and you can see it in the DevCycle dashboard.

This creates a bare project - with no features or variables. To add those, lets create a feature, and to do that, head over to the DevCycle Documentation

What’s Next?

We’re constantly looking to improve everything we offer at DevCycle. Give the Terraform provider a try and let us know what you think, and if you’d like to see more to it.

Thanks for reading!

Written By

Victor Vucicevich