Skip to content

Commit

Permalink
Add support for Feature flag and FF SDK Key resources (#517)
Browse files Browse the repository at this point in the history
* Add support for Feature flag and FF SDK Key resources

* Add changelog and render docs
  • Loading branch information
ehardisty committed Apr 25, 2023
1 parent 99ca179 commit 2e30f27
Show file tree
Hide file tree
Showing 8 changed files with 791 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changelog/517.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:new-resource
platform_feature_flag - Added feature flag resources to the Harness Terraform Provider.
platform_ff_api_key - Added FF SDK API key resources to the Harness Terraform provider.
```
124 changes: 124 additions & 0 deletions docs/resources/platform_feature_flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_feature_flag Resource - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
Resource for managing Feature Flags.
---

# harness_platform_feature_flag (Resource)

Resource for managing Feature Flags.

## Example Usage

```terraform
// Boolean Flag
resource "harness_platform_feature_flag" "mybooleanflag" {
org_id = "test"
project_id = "testff"
kind = "boolean"
name = "MY_FEATURE"
identifier = "MY_FEATURE"
permanent = false
default_on_variation = "Enabled"
default_off_variation = "Disabled"
variation {
identifier = "Enabled"
name = "Enabled"
description = "The feature is enabled"
value = "true"
}
variation {
identifier = "Disabled"
name = "Disabled"
description = "The feature is disabled"
value = "false"
}
}
// Multivariate flag
resource "harness_platform_feature_flag" "mymultivariateflag" {
org_id = "test"
project_id = "testff"
kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
permanent = false
default_on_variation = "trial7"
default_off_variation = "trial20"
variation {
identifier = "trial7"
name = "7 days trial"
description = "Free trial period 7 days"
value = "7"
}
variation {
identifier = "trial14"
name = "14 days trial"
description = "Free trial period 14 days"
value = "14"
}
variation {
identifier = "trial20"
name = "20 days trial"
description = "Free trial period 20 days"
value = "20"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `default_off_variation` (String) Which of the variations to use when the flag is toggled to off state
- `default_on_variation` (String) Which of the variations to use when the flag is toggled to on state
- `identifier` (String) Identifier of the Feature Flag
- `kind` (String) The type of data the flag represents. Valid values are `boolean`, `int`, `string`, `json`
- `name` (String) Name of the Feature Flag
- `org_id` (String) Organization Identifier
- `permanent` (Boolean) Whether or not the flag is permanent. If it is, it will never be flagged as stale
- `project_id` (String) Project Identifier
- `variation` (Block List, Min: 2) The options available for your flag (see [below for nested schema](#nestedblock--variation))

### Optional

- `archived` (Boolean) Whether or not the flag is archived
- `git_details` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--git_details))
- `owner` (String) The owner of the flag

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--variation"></a>
### Nested Schema for `variation`

Required:

- `description` (String) The description of the variation
- `identifier` (String) The identifier of the variation
- `name` (String) The user friendly name of the variation
- `value` (String) The value of the variation


<a id="nestedblock--git_details"></a>
### Nested Schema for `git_details`

Required:

- `commit_msg` (String) The commit message to use as part of a gitsync operation


55 changes: 55 additions & 0 deletions docs/resources/platform_ff_api_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_ff_api_key Resource - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
Resource for creating an environment SDK key for Feature Flags.
---

# harness_platform_ff_api_key (Resource)

Resource for creating an environment SDK key for Feature Flags.

## Example Usage

```terraform
resource "harness_platform_ff_api_key" "testserverapikey" {
identifier = "testserver"
name = "TestServer"
description = "this is a server SDK key"
org_id = "test"
project_id = "testff"
env_id = "testenv"
expired_at = 1713729225
type = "Server"
}
output "serversdkkey" {
value = harness_platform_ff_api_key.testserverapikey.api_key
sensitive = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `env_id` (String) Environment Identifier
- `identifier` (String) Identifier of the SDK API Key
- `name` (String) Name of the SDK API Key
- `org_id` (String) Organization Identifier
- `project_id` (String) Project Identifier
- `type` (String) Type of SDK. Valid values are `Server` or `Client`.

### Optional

- `description` (String) Description of the SDK API Key
- `expired_at` (Number) Expiration datetime of the SDK API Key

### Read-Only

- `api_key` (String, Sensitive) The value of the SDK API Key
- `id` (String) The ID of this resource.


63 changes: 63 additions & 0 deletions examples/resources/harness_platform_feature_flag/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Boolean Flag
resource "harness_platform_feature_flag" "mybooleanflag" {
org_id = "test"
project_id = "testff"

kind = "boolean"
name = "MY_FEATURE"
identifier = "MY_FEATURE"
permanent = false

default_on_variation = "Enabled"
default_off_variation = "Disabled"

variation {
identifier = "Enabled"
name = "Enabled"
description = "The feature is enabled"
value = "true"
}

variation {
identifier = "Disabled"
name = "Disabled"
description = "The feature is disabled"
value = "false"
}
}


// Multivariate flag
resource "harness_platform_feature_flag" "mymultivariateflag" {
org_id = "test"
project_id = "testff"

kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
permanent = false

default_on_variation = "trial7"
default_off_variation = "trial20"

variation {
identifier = "trial7"
name = "7 days trial"
description = "Free trial period 7 days"
value = "7"
}

variation {
identifier = "trial14"
name = "14 days trial"
description = "Free trial period 14 days"
value = "14"
}

variation {
identifier = "trial20"
name = "20 days trial"
description = "Free trial period 20 days"
value = "20"
}
}
15 changes: 15 additions & 0 deletions examples/resources/harness_platform_ff_api_key/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "harness_platform_ff_api_key" "testserverapikey" {
identifier = "testserver"
name = "TestServer"
description = "this is a server SDK key"
org_id = "test"
project_id = "testff"
env_id = "testenv"
expired_at = 1713729225
type = "Server"
}

output "serversdkkey" {
value = harness_platform_ff_api_key.testserverapikey.api_key
sensitive = true
}
4 changes: 4 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"log"

"github.com/harness/terraform-provider-harness/internal/service/platform/feature_flag"
"github.com/harness/terraform-provider-harness/internal/service/platform/ff_api_key"
"github.com/harness/terraform-provider-harness/internal/service/platform/gitops/agent_yaml"
"github.com/harness/terraform-provider-harness/internal/service/platform/manual_freeze"
"github.com/harness/terraform-provider-harness/internal/service/platform/policy"
Expand Down Expand Up @@ -248,6 +250,8 @@ func Provider(version string) func() *schema.Provider {
"harness_platform_environment_group": pl_environment_group.ResourceEnvironmentGroup(),
"harness_platform_environment_clusters_mapping": pl_environment_clusters_mapping.ResourceEnvironmentClustersMapping(),
"harness_platform_environment_service_overrides": pl_environment_service_overrides.ResourceEnvironmentServiceOverrides(),
"harness_platform_feature_flag": feature_flag.ResourceFeatureFlag(),
"harness_platform_ff_api_key": ff_api_key.ResourceFFApiKey(),
"harness_platform_gitops_agent": gitops_agent.ResourceGitopsAgent(),
"harness_platform_gitops_applications": gitops_applications.ResourceGitopsApplication(),
"harness_platform_gitops_cluster": gitops_cluster.ResourceGitopsCluster(),
Expand Down
Loading

0 comments on commit 2e30f27

Please sign in to comment.