Skip to content

Commit

Permalink
add service_to_service_enabled field to atracker event streams endpoi…
Browse files Browse the repository at this point in the history
…nt (IBM-Cloud#5605)

* add service_to_service_enabled field to atracker event streams endpoint

* update example

* update go mod
  • Loading branch information
helenxu1221 committed Sep 11, 2024
1 parent 939ddcc commit 4712cab
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 16 deletions.
1 change: 1 addition & 0 deletions examples/ibm-atracker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "ibm_atracker_target" atracker_target_eventstreams_instance {
brokers = [ "kafka-x:9094" ]
topic = "my-topic"
api_key = "xxxxxxxxxxxxxx"
service_to_service_enabled = false
}
region = var.atracker_target_region
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/IBM/logs-router-go-sdk v1.0.3
github.com/IBM/mqcloud-go-sdk v0.1.0
github.com/IBM/networking-go-sdk v0.49.0
github.com/IBM/platform-services-go-sdk v0.67.0
github.com/IBM/platform-services-go-sdk v0.68.1
github.com/IBM/project-go-sdk v0.3.5
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/sarama v1.41.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/IBM/mqcloud-go-sdk v0.1.0 h1:fWt4uisg5GbbsfNmAxx5/6c5gQIPM+VrEsTtnimE
github.com/IBM/mqcloud-go-sdk v0.1.0/go.mod h1:LesMQlKHXvdks4jqQLZH7HfATY5lvTzHuwQU5+y7b2g=
github.com/IBM/networking-go-sdk v0.49.0 h1:lPS34u3C0JVrbxH+Ulua76Nwl6Frv8BEfq6LRkyvOv0=
github.com/IBM/networking-go-sdk v0.49.0/go.mod h1:G9CKbmPE8gSLjN+ABh4hIZ1bMx076enl5Eekvj6zQnA=
github.com/IBM/platform-services-go-sdk v0.67.0 h1:AGu3NiCUyvyFUqbgtmsFRh74kyXrmNbSu1yG/qwGLIM=
github.com/IBM/platform-services-go-sdk v0.67.0/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4=
github.com/IBM/platform-services-go-sdk v0.68.1 h1:RXGzEmdllzSj5OzCJO7AoTeQ+cgTTNa20CrrpLQe5KQ=
github.com/IBM/platform-services-go-sdk v0.68.1/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4=
github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM=
github.com/IBM/project-go-sdk v0.3.5/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo=
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4=
Expand Down
12 changes: 10 additions & 2 deletions ibm/service/atracker/data_source_ibm_atracker_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func DataSourceIBMAtrackerTargets() *schema.Resource {
"service_to_service_enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.",
Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
},
},
},
Expand Down Expand Up @@ -151,7 +151,12 @@ func DataSourceIBMAtrackerTargets() *schema.Resource {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
Description: "The user password (api key) for the message hub topic in the Event Streams instance.",
Description: "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.",
},
"service_to_service_enabled": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
},
},
},
Expand Down Expand Up @@ -421,6 +426,9 @@ func DataSourceIBMAtrackerTargetsEventstreamsEndpointToMap(model *atrackerv2.Eve
if model.APIKey != nil {
modelMap["api_key"] = *model.APIKey // pragma: allowlist secret
}
if model.ServiceToServiceEnabled != nil {
modelMap["service_to_service_enabled"] = *model.ServiceToServiceEnabled
}
return modelMap, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func testAccCheckIBMAtrackerTargetsDataSourceConfig(targetName string, targetTar
brokers = [ "kafka-x:9094" ]
topic = "my-topic"
api_key = "%s" // pragma: allowlist secret
service_to_service_enabled = false
}
cloudlogs_endpoint {
target_crn = "crn:v1:bluemix:public:logs:eu-es:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::"
Expand Down
17 changes: 13 additions & 4 deletions ibm/service/atracker/resource_ibm_atracker_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func ResourceIBMAtrackerTarget() *schema.Resource {
"service_to_service_enabled": {
Type: schema.TypeBool,
Optional: true,
Description: "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.",
Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
},
},
},
Expand Down Expand Up @@ -127,10 +127,15 @@ func ResourceIBMAtrackerTarget() *schema.Resource {
},
"api_key": &schema.Schema{ // pragma: allowlist secret
Type: schema.TypeString,
Required: true,
Optional: true,
Sensitive: true,
DiffSuppressFunc: flex.ApplyOnce,
Description: "The user password (api key) for the message hub topic in the Event Streams instance.",
Description: "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.",
},
"service_to_service_enabled": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
},
},
},
Expand Down Expand Up @@ -575,7 +580,10 @@ func resourceIBMAtrackerTargetMapToEventstreamsEndpointPrototype(modelMap map[st
brokers = append(brokers, brokersItem.(string))
}
model.Brokers = brokers
model.APIKey = core.StringPtr(modelMap["api_key"].(string)) // pragma: whitelist secret
if modelMap["api_key"] != nil && modelMap["api_key"].(string) != "" {
model.APIKey = core.StringPtr(modelMap["api_key"].(string)) // pragma: whitelist secret
}
model.ServiceToServiceEnabled = core.BoolPtr(modelMap["service_to_service_enabled"].(bool))
return model, nil
}

Expand Down Expand Up @@ -611,6 +619,7 @@ func resourceIBMAtrackerTargetEventstreamsEndpointPrototypeToMap(model *atracker
modelMap["topic"] = model.Topic
// TODO: remove after deprecation
modelMap["api_key"] = REDACTED_TEXT // pragma: whitelist secret
modelMap["service_to_service_enabled"] = model.ServiceToServiceEnabled
return modelMap, nil
}

Expand Down
18 changes: 15 additions & 3 deletions metadata/provider_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,7 @@
"service_to_service_enabled": {
"name": "service_to_service_enabled",
"type": "TypeBool",
"description": "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.",
"description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
"computed": true
},
"target_crn": {
Expand Down Expand Up @@ -3376,7 +3376,7 @@
"api_key": {
"name": "api_key",
"type": "TypeString",
"description": "The user password (api key) for the message hub topic in the Event Streams instance.",
"description": "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.",
"secure": true,
"computed": true
},
Expand All @@ -3400,6 +3400,12 @@
"type": "TypeString",
"description": "The messsage hub topic defined in the Event Streams instance.",
"computed": true
},
"service_to_service_enabled": {
"name": "service_to_service_enabled",
"type": "TypeBool",
"description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
"computed": true
}
}
},
Expand Down Expand Up @@ -87721,6 +87727,12 @@
"type": "TypeString",
"description": "The messsage hub topic defined in the Event Streams instance.",
"required": true
},
"service_to_service_enabled": {
"name": "service_to_service_enabled",
"type": "TypeBool",
"description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
"optional": true
}
},
"max_items": 1
Expand Down Expand Up @@ -87817,7 +87829,7 @@
"service_to_service_enabled": {
"name": "service_to_service_enabled",
"type": "TypeBool",
"description": "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.",
"description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.",
"optional": true
},
"target_crn": {
Expand Down
5 changes: 3 additions & 2 deletions website/docs/d/atracker_targets.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Nested scheme for **targets**:
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `endpoint` - (String) The host name of the Cloud Object Storage endpoint.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `service_to_service_enabled` - (Boolean) ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.
* `service_to_service_enabled` - (Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.
* `target_crn` - (String) The CRN of the Cloud Object Storage instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `logdna_endpoint` - (List) Property values for a LogDNA Endpoint.
Expand All @@ -57,12 +57,13 @@ Nested scheme for **targets**:
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `eventstreams_endpoint` - (List) Property values for Event streams Endpoint.
Nested scheme for **eventstreams_endpoint**:
* `api_key` - (String) The IAM API key that has access to the Event streams instance.
* `api_key` - (String) The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled..
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `topic` - (String) The topic name defined under the Event streams instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `brokers` - (List) The list of brokers defined under the Event streams instance and used in the event streams endpoint.
* Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `service_to_service_enabled` - (Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.
* `target_crn` - (String) The CRN of the Event streams instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `cloudlogs_endpoint` - (List) Property values for an IBM Cloud Logs endpoint.
Expand Down
5 changes: 3 additions & 2 deletions website/docs/r/atracker_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Nested scheme for **cos_endpoint**:
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `endpoint` - (Required, String) The host name of the Cloud Object Storage endpoint.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `service_to_service_enabled` - (Optional, Boolean) ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.
* `service_to_service_enabled` - (Optional, Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.
* `target_crn` - (Required, String) The CRN of the Cloud Object Storage instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `logdna_endpoint` - (Optional, List) Property values for a LogDNA Endpoint.
Expand All @@ -81,12 +81,13 @@ Nested scheme for **logdna_endpoint**:
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `eventstreams_endpoint` - (List) Property values for Event streams Endpoint.
Nested scheme for **eventstreams_endpoint**:
* `api_key` - (String) The IAM API key that has access to the Event streams instance.
* `api_key` - (String) The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled. .
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `topic` - (String) The topic name defined under the Event streams instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `brokers` - (List) The list of brokers defined under the Event streams instance and used in the event streams endpoint.
* Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -._:]+$/`.
* `service_to_service_enabled` - (Optional, Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.
* `target_crn` - (String) The CRN of the Event streams instance.
* Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`.
* `cloudlogs_endpoint` - (Optional, List) Property Values for IBM Cloud Logs Endpoint.
Expand Down

0 comments on commit 4712cab

Please sign in to comment.