Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(New resource: App Configuration Evaluation provider) - Initial commit #4948

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .github/labeler-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ service/Activity Tracker:
- '((\*|-) ?`?|(data|resource) "?)ibm_atracker'
service/App Configuration:
- '((\*|-) ?`?|(data|resource) "?)ibm_app_config'
service/App Configuration Evaluation:
- '((\*|-) ?`?|(data|resource) "?)ibm_app_config_evaluate_'
service/APPID Management:
- '((\*|-) ?`?|(data|resource) "?)ibm_appid'
service/Catalog Management:
Expand Down
81 changes: 81 additions & 0 deletions examples/ibm-app-configuration-evaluation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Example for AppConfigurationEvaluation

This example illustrates how to use the AppConfigurationEvaluation for feature flags & properties.

The following types of data sources are supported:

* App Configuration evaluate feature flag.
* App Configuration evaluate property.

## Usage

To run this example, execute the following commands:

```bash
terraform init
terraform plan
terraform apply
```

Run `terraform destroy` when you don't need these data sources.

## AppConfigurationEvaluation data sources

ibm_app_config_evaluate_feature_flag data source:

```hcl
data "ibm_app_config_evaluate_feature_flag" "evaluate_feature_flag" {
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
feature_id = var.app_config_feature_id
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}
```

ibm_app_config_evaluate_property data source:

```hcl
data "ibm_app_config_evaluate_property" "evaluate_property" {
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
property_id = var.app_config_property_id
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}
```

## Requirements

| Name | Version |
| --------- | ------- |
| terraform | ~> 0.12 |

## Providers

| Name | Version |
| ---- | ------- |
| ibm | 1.60.0 |

## Inputs

| Name | Description | Type | Required |
| ------------------ | ---------------------------------- | -------- | -------- |
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
| region | IBM Cloud region name. | `string` | true |
| guid | App Configuration instance Id. | `string` | true |
| collection_id | App Configuration Collection Id. | `string` | true |
| environment_id | App Configuration Environment Id. | `string` | true |
| feature_id | App Configuration Feature flag Id. | `string` | true |
| property_id | App Configuration Property Id. | `string` | true |
| entity_id | Entity Id. | `string` | true |
| entity_attributes | Entity attributes. | `object` | false |

## Outputs
| Name | Description |
| -------------- | ------------------------------------------------------------- |
| result_boolean | Evaluated value of the BOOLEAN type feature flag or property. |
| result_string | Evaluated value of the STRING type feature flag or property. |
| result_numeric | Evaluated value of the NUMERIC type feature flag or property. |
46 changes: 46 additions & 0 deletions examples/ibm-app-configuration-evaluation/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
}

// Single feature flag
data "ibm_app_config_evaluate_feature_flag" "evaluate_feature_flag" {
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
feature_id = var.app_config_feature_id
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}

// Multiple feature flags
data "ibm_app_config_evaluate_feature_flag" "evaluate_feature_flags" {
for_each = toset(var.app_config_feature_flag_ids)
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
feature_id = each.value
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}

// Single property
data "ibm_app_config_evaluate_property" "evaluate_property" {
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
property_id = var.app_config_property_id
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}

// Multiple properties
data "ibm_app_config_evaluate_property" "evaluate_properties" {
for_each = toset(var.app_config_property_ids)
guid = var.app_config_guid
environment_id = var.app_config_environment_id
collection_id = var.app_config_collection_id
property_id = each.value
entity_id = var.app_config_entity_id
entity_attributes = var.app_config_entity_attributes
}
19 changes: 19 additions & 0 deletions examples/ibm-app-configuration-evaluation/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This output allows data to be referenced by other resources and the terraform CLI
// Modify this output if only certain data should be exposed

output "ibm_app_config_feature_flag_evaluated_value" {
value = data.ibm_app_config_evaluate_feature_flag.evaluate_feature_flag.result_numeric
description = "Feature flag evaluated value."
}
output "ibm_app_config_feature_flag_evaluated_values" {
value = values(data.ibm_app_config_evaluate_feature_flag.evaluate_feature_flags)[*].result_boolean
description = "Feature flag evaluated values."
}
output "ibm_app_config_property_evaluated_value" {
value = data.ibm_app_config_evaluate_property.evaluate_property.result_numeric
description = "Property evaluated value."
}
output "ibm_app_config_property_evaluated_values" {
value = values(data.ibm_app_config_evaluate_property.evaluate_properties)[*].result_string
description = "Property evaluated values."
}
58 changes: 58 additions & 0 deletions examples/ibm-app-configuration-evaluation/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
variable "ibmcloud_api_key" {
description = "IBM Cloud API key"
type = string
default = "<Add IAM Apikey>"
}
variable "region" {
description = "IBM Cloud region where your App Configuration instance is located."
type = string
default = "au-syd"
}
variable "app_config_guid" {
description = "App Configuration instance id or guid."
type = string
default = "36401ffc-6280-459a-ba98-456aba10d0c7"
}
variable "app_config_environment_id" {
description = "Id of the environment created in App Configuration instance under the Environments section."
type = string
default = "dev"
}
variable "app_config_collection_id" {
description = "Id of the collection created in App Configuration instance under the Collections section."
type = string
default = "car-rentals"
}
variable "app_config_feature_id" {
description = "Feature flag id required to be evaluated."
type = string
default = "weekend-discount"
}
variable "app_config_property_id" {
description = "Property id required to be evaluated."
type = string
default = "users-location"
}
variable "app_config_entity_id" {
description = "Entity Id."
type = string
default = "user123"
}
variable "app_config_entity_attributes" {
description = "Entity attributes for evaluation."
type = map(any)
default = {
city = "Bangalore",
radius = 60,
}
}
variable "app_config_feature_flag_ids" {
description = "List of feature flag id's required to evaluate."
type = list(string)
default = ["feature-1", "feature-2", "feature-3", "feature-4"]
}
variable "app_config_property_ids" {
description = "List of property id's required to evaluate."
type = list(string)
default = ["property-1", "property-2"]
}
9 changes: 9 additions & 0 deletions examples/ibm-app-configuration-evaluation/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.0"
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "1.60.0"
}
}
}
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/IBM-Cloud/power-go-client v1.5.4
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appconfiguration-go-sdk v0.5.1
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
github.com/IBM/cloud-databases-go-sdk v0.3.2
github.com/IBM/cloudant-go-sdk v0.0.43
Expand Down Expand Up @@ -118,6 +119,7 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -189,9 +191,11 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
Expand Down
Loading