Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# configcat-terraform-sample
Automating ConfigCat resources with Terraform
# Automating ConfigCat Resources with Terraform

**[Read the blog post here](https://configcat.com/blog/automating-configcat-resources-with-terraform)**

A companion sample app demonstrating how to automate [ConfigCat feature flags](https://configcat.com) resources using the [ConfigCat Feature Flags Provider](https://registry.terraform.io/providers/configcat/configcat/latest/docs).

## Build & Run

Instructions on how to build and run the application locally.

### Prerequisites

- [Install Terraform](https://developer.hashicorp.com/terraform/install)
- [ConfigCat API credentials](https://app.configcat.com/my-account/public-api-credentials)

### Steps

1. Open this repository in your terminal.

2. Add your [ConfigCat API credentials](https://app.configcat.com/my-account/public-api-credentials) to the `variables.tf` file.

3. Initialize Terraform with the following command:

```bash
terraform init
```

4. Plan and apply the ConfigCat resources:

```bash
terraform plan

terraform apply
```

## Learn more

Useful links to technical resources.

- [ConfigCat Feature Flags Provider documentation](https://registry.terraform.io/providers/configcat/configcat/latest/docs).

[**ConfigCat**](https://configcat.com) supports many other frameworks and languages. Check out the [full list of supported SDKs](https://configcat.com/docs/sdk-reference/overview/).

You can also explore other code samples for various languages, frameworks, and topics in [ConfigCat labs](https://github.com/configcat-labs) on GitHub.

Keep up with ConfigCat on [X](https://x.com/configcat), [Facebook](https://www.facebook.com/configcat), [LinkedIn](https://www.linkedin.com/company/configcat/), and [GitHub](https://github.com/configcat).

## Author

[Chavez Harris](https://github.com/codedbychavez)

## Contributions

Contributions are welcome!
54 changes: 54 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
terraform {
required_providers {
configcat = {
source = "configcat/configcat"
version = "~> 5.0"
}
}
}

provider "configcat" {
basic_auth_username = var.configcat_basic_auth_username
basic_auth_password = var.configcat_basic_auth_password
}

data "configcat_organizations" "my_organizations" {

}

resource "configcat_product" "my_product" {
organization_id = data.configcat_organizations.my_organizations.organizations[0].organization_id
name = "My product"
description = "My example product"
order = 0
}

resource "configcat_environment" "my_environment" {
product_id = configcat_product.my_product.id
name = "Production"
description = "My production environment"
color = "blue"
order = 0
}

resource "configcat_config" "my_config" {
product_id = configcat_product.my_product.id
name = "My config"
description = "My example config"
order = 0
}

resource "configcat_setting" "is_awesome" {
config_id = configcat_config.my_config.id
key = "isAwesomeFeatureEnabled"
name = "My awesome feature flag"
hint = "Thi is the hint for my awesome feature flag"
setting_type = "boolean"
order = 0
}

resource "configcat_setting_value" "is_awesome_value" {
environment_id = configcat_environment.my_environment.id
setting_id = configcat_setting.is_awesome.id
value = "false"
}
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "configcat_basic_auth_username" {
type = string
default = "INPUT_YOUR_AUTH_USERNAME_HERE"
}

variable "configcat_basic_auth_password" {
type = string
default = "INPUT_YOUR_AUTH_PASSWORD_HERE"
}