Skip to content

Commit

Permalink
FFM-9213: Implement targets for the feature flag terraform resource (#…
Browse files Browse the repository at this point in the history
…684)

* Add targets rule for feature flags
* update instructions definition
* include mapping for the instruction types
* update feature flag definition
* fix documentation
  • Loading branch information
ribeirophillipe committed Sep 13, 2023
1 parent 3b3c2c2 commit 5fd4ff1
Show file tree
Hide file tree
Showing 5 changed files with 527 additions and 13 deletions.
137 changes: 135 additions & 2 deletions docs/resources/platform_feature_flag.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,103 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}
}
// Assign targets to 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"
}
add_target_rules {
variation = "enabled"
targets = ["targets1", "targets2"]
}
}
// Assign target groups to 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"
}
add_target_groups_rules {
group_name = "group_name"
variation = "enabled"
distribution = {
bucketBy = "identifier",
variations = [
{
variation = "foo"
weight = 30
},
{
variation = "bat"
weight = 30
},
{
variation = "name"
weight = 40
}
]
}
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -95,6 +192,8 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {

### Optional

- `add_target_group_rules` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_group_rules))
- `add_target_rules` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_rules))
- `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
Expand All @@ -114,11 +213,45 @@ Required:
- `value` (String) The value of the variation


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

Optional:

- `distribution` (Block List) The distribution of the rule (see [below for nested schema](#nestedblock--add_target_group_rules--distribution))
- `group_name` (String) The name of the target group
- `variation` (String) The identifier of the variation. Valid values are `enabled`, `disabled`

<a id="nestedblock--add_target_group_rules--distribution"></a>
### Nested Schema for `add_target_group_rules.distribution`

Optional:

- `variations` (Block List) The variations of the rule (see [below for nested schema](#nestedblock--add_target_group_rules--distribution--variations))

<a id="nestedblock--add_target_group_rules--distribution--variations"></a>
### Nested Schema for `add_target_group_rules.distribution.variations`

Optional:

- `variation` (String) The identifier of the variation
- `weight` (Number) The weight of the variation




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

Optional:

- `targets` (List of String) The targets of the rule
- `variation` (String) The identifier of the variation. Valid values are `enabled`, `disabled`


<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


18 changes: 9 additions & 9 deletions docs/resources/platform_feature_flag_target_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ Resource for creating a Harness Feature Flag Target Group.

```terraform
resource "harness_platform_feature_flag_target_group" "target" {
org_id = "test"
project = "test"
org_id = "test"
project = "test"
identifier = "MY_FEATURE"
environment = "MY_ENVIRONMENT"
name = "MY_FEATURE"
account_id = "MY_ACCOUNT_ID"
included = ["target_id_1"]
excluded = ["target_id_2"]
rules = [
{
attribute = "MY_ATTRIBUTE"
operator = "EQUALS"
value = "MY_VALUE"
}
]
rules = [
{
attribute = "MY_ATTRIBUTE"
operator = "EQUALS"
value = "MY_VALUE"
}
]
}
```

Expand Down
1 change: 0 additions & 1 deletion docs/resources/platform_ff_api_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ output "serversdkkey" {
- `api_key` (String, Sensitive) The value of the SDK API Key
- `id` (String) The ID of this resource.


96 changes: 96 additions & 0 deletions examples/resources/harness_platform_feature_flag/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,100 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
description = "Free trial period 20 days"
value = "20"
}
}

// Assign targets to 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"
}

add_target_rules {
variation = "enabled"
targets = ["targets1", "targets2"]
}
}

// Assign target groups to 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"
}

add_target_groups_rules {
group_name = "group_name"
variation = "enabled"
distribution = {
variations = [
{
variation = "foo"
weight = 30
},
{
variation = "bat"
weight = 30
},
{
variation = "name"
weight = 40
}
]
}
}
}
Loading

0 comments on commit 5fd4ff1

Please sign in to comment.