diff --git a/examples/ibm-atracker/README.md b/examples/ibm-atracker/README.md index c7ac19e610..6e2d771fb2 100644 --- a/examples/ibm-atracker/README.md +++ b/examples/ibm-atracker/README.md @@ -33,6 +33,7 @@ resource "atracker_target" "atracker_target_instance" { cos_endpoint = var.atracker_target_cos_endpoint logdna_endpoint = var.atracker_target_logdna_endpoint eventstreams_endpoint = var.atracker_target_eventstreams_endpoint + cloudlogs_endpoint = var.atracker_target_cloudlogs_instance } ``` atracker_route resource: @@ -101,6 +102,8 @@ data "atracker_routes" "atracker_routes_instance" { | target_type | The type of the target. | `string` | true | | cos_endpoint | Property values for a Cloud Object Storage Endpoint. | `` | true | | eventstreams_endpoint | Property values for the Event Streams Endpoint in responses. | `` | false | +| logdna_endpoint | Property values for a LogDNA Endpoint in responses. | `` | false | +| cloudlogs_endpoint | Property values for the IBM Cloud Logs Endpoint in responses. | `` | false | | name | The name of the route. The name must be 1000 characters or less and cannot include any special characters other than `(space) - . _ :`. | `string` | true | | rules | The routing rules that will be evaluated in their order of the array. Once a rule is matched, the remaining rules in the route definition will be skipped. | `list()` | true | | default_targets | The target ID List. In the event that no routing rule causes the event to be sent to a target, these targets will receive the event. | `list(string)` | false | diff --git a/examples/ibm-atracker/main.tf b/examples/ibm-atracker/main.tf index c6d6787889..24f67081bc 100644 --- a/examples/ibm-atracker/main.tf +++ b/examples/ibm-atracker/main.tf @@ -37,6 +37,15 @@ resource "ibm_atracker_target" atracker_target_eventstreams_instance { region = var.atracker_target_region } +resource "ibm_atracker_target" atracker_target_cloudlogs_instance { + name = var.atracker_target_name + target_type = "cloud_logs" + cloudlogs_endpoint { + target_crn = "crn:v1:bluemix:public:logs:eu-es:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" + } + region = var.atracker_target_region +} + // Provision atracker_route resource instance resource "ibm_atracker_route" "atracker_route_instance" { diff --git a/go.mod b/go.mod index 9b3f0c91f6..a7a84d94c5 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.45.0 - github.com/IBM/platform-services-go-sdk v0.62.0 + github.com/IBM/platform-services-go-sdk v0.62.3 github.com/IBM/project-go-sdk v0.2.8-1 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.5 diff --git a/go.sum b/go.sum index 3716310a95..a0397807cc 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,8 @@ github.com/IBM/mqcloud-go-sdk v0.0.4 h1:gqMpoU5a0qJ0GETG4PQrkgeEEoaQLvbxRJnEe6yt github.com/IBM/mqcloud-go-sdk v0.0.4/go.mod h1:gQptHC6D+rxfg0muRFFGvTDmvl4YfiDE0uXkaRRewRk= github.com/IBM/networking-go-sdk v0.45.0 h1:tYgDhVDpgKvELNY7tcodbZ4ny9fatpEWM6PwtQcDe20= github.com/IBM/networking-go-sdk v0.45.0/go.mod h1:NnJPA1e5GWr5opJe+5Hs6e1G6RcBIFz64TrkZsdnSp8= -github.com/IBM/platform-services-go-sdk v0.62.0 h1:IA7kerhjqHHCSirXsLveX6Bk6DnUOA7Z9zaMqLZ5iBY= -github.com/IBM/platform-services-go-sdk v0.62.0/go.mod h1:fd7gUOmsuQYhYLTZVLL+posObT/ISxVV+6JzsfDs5qE= +github.com/IBM/platform-services-go-sdk v0.62.3 h1:utPtD1DYpA2r8Q7vDWoszMYJEsop7U973kyQ6vNizCA= +github.com/IBM/platform-services-go-sdk v0.62.3/go.mod h1:fd7gUOmsuQYhYLTZVLL+posObT/ISxVV+6JzsfDs5qE= github.com/IBM/project-go-sdk v0.2.8-1 h1:2xGV+bZZ0ZrDzCpmVfcMkdOchARNns7vkUtAdQyDanQ= github.com/IBM/project-go-sdk v0.2.8-1/go.mod h1:7YN8IpeiDPPrIdm/4xMJhj2aU/TA1TSrvFuUUSGq9BU= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= diff --git a/ibm/service/atracker/data_source_ibm_atracker_targets.go b/ibm/service/atracker/data_source_ibm_atracker_targets.go index c51fcf8c8a..a377bd1a8e 100644 --- a/ibm/service/atracker/data_source_ibm_atracker_targets.go +++ b/ibm/service/atracker/data_source_ibm_atracker_targets.go @@ -156,6 +156,20 @@ func DataSourceIBMAtrackerTargets() *schema.Resource { }, }, }, + "cloudlogs_endpoint": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Property values for the IBM Cloud Logs endpoint in responses.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "target_crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The CRN of the IBM Cloud Logs instance", + }, + }, + }, + }, "cos_write_status": { Type: schema.TypeList, Computed: true, @@ -340,6 +354,13 @@ func DataSourceIBMAtrackerTargetsTargetToMap(model *atrackerv2.Target) (map[stri } modelMap["eventstreams_endpoint"] = []map[string]interface{}{eventstreamsEndpointMap} } + if model.CloudlogsEndpoint != nil { + cloudlogsEndpointMap, err := DataSourceIBMAtrackerTargetsCloudlogsEndpointToMap(model.CloudlogsEndpoint) + if err != nil { + return modelMap, err + } + modelMap["cloudlogs_endpoint"] = []map[string]interface{}{cloudlogsEndpointMap} + } if model.WriteStatus != nil { writeStatusMap, err := DataSourceIBMAtrackerTargetsWriteStatusToMap(model.WriteStatus) if err != nil { @@ -403,6 +424,14 @@ func DataSourceIBMAtrackerTargetsEventstreamsEndpointToMap(model *atrackerv2.Eve return modelMap, nil } +func DataSourceIBMAtrackerTargetsCloudlogsEndpointToMap(model *atrackerv2.CloudLogsEndpoint) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TargetCRN != nil { + modelMap["target_crn"] = *model.TargetCRN + } + return modelMap, nil +} + func DataSourceIBMAtrackerTargetsWriteStatusToMap(model *atrackerv2.WriteStatus) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Status != nil { diff --git a/ibm/service/atracker/data_source_ibm_atracker_targets_test.go b/ibm/service/atracker/data_source_ibm_atracker_targets_test.go index 30eafa492d..1e362707fe 100644 --- a/ibm/service/atracker/data_source_ibm_atracker_targets_test.go +++ b/ibm/service/atracker/data_source_ibm_atracker_targets_test.go @@ -107,9 +107,13 @@ func testAccCheckIBMAtrackerTargetsDataSourceConfig(targetName string, targetTar topic = "my-topic" api_key = "%s" // pragma: allowlist secret } + cloudlogs_endpoint { + target_crn = "crn:v1:bluemix:public:logs:eu-es:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" + } } data "ibm_atracker_targets" "atracker_targets" { name = ibm_atracker_target.atracker_target.name } + `, targetName, targetTargetType, targetRegion, acc.COSApiKey, acc.IngestionKey, acc.IesApiKey) } diff --git a/ibm/service/atracker/resource_ibm_atracker_target.go b/ibm/service/atracker/resource_ibm_atracker_target.go index 56a56291cd..42b9684bfd 100644 --- a/ibm/service/atracker/resource_ibm_atracker_target.go +++ b/ibm/service/atracker/resource_ibm_atracker_target.go @@ -41,7 +41,7 @@ func ResourceIBMAtrackerTarget() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_atracker_target", "target_type"), - Description: "The type of the target. It can be cloud_object_storage, logdna or event_streams. Based on this type you must include cos_endpoint, logdna_endpoint or eventstreams_endpoint.", + Description: "The type of the target. It can be cloud_object_storage, logdna, event_streams, or cloud_logs. Based on this type you must include cos_endpoint, logdna_endpoint, eventstreams_endpoint or cloudlogs_endpoint.", }, "cos_endpoint": { Type: schema.TypeList, @@ -135,6 +135,21 @@ func ResourceIBMAtrackerTarget() *schema.Resource { }, }, }, + "cloudlogs_endpoint": &schema.Schema{ + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Property values for an IBM Cloud Logs endpoint in requests.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "target_crn": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The CRN of the IBM Cloud Logs instance.", + }, + }, + }, + }, "region": { Type: schema.TypeString, Optional: true, @@ -255,7 +270,7 @@ func ResourceIBMAtrackerTargetValidator() *validate.ResourceValidator { ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, Required: true, - AllowedValues: "cloud_object_storage, logdna, event_streams", + AllowedValues: "cloud_object_storage, logdna, event_streams, cloud_logs", }, validate.ValidateSchema{ Identifier: "region", @@ -303,6 +318,13 @@ func resourceIBMAtrackerTargetCreate(context context.Context, d *schema.Resource } createTargetOptions.SetEventstreamsEndpoint(eventstreamsEndpointModel) } + if _, ok := d.GetOk("cloudlogs_endpoint"); ok { + cloudLogsEndpointModel, err := resourceIBMAtrackerTargetMapToCloudLogsEndpointPrototype(d.Get("cloudlogs_endpoint.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + createTargetOptions.SetCloudlogsEndpoint(cloudLogsEndpointModel) + } if _, ok := d.GetOk("region"); ok { createTargetOptions.SetRegion(d.Get("region").(string)) } @@ -390,6 +412,16 @@ func resourceIBMAtrackerTargetRead(context context.Context, d *schema.ResourceDa } } + if target.CloudlogsEndpoint != nil { + cloudLogsEndpointMap, err := resourceIBMAtrackerTargetCloudLogsEndpointPrototypeToMap(target.CloudlogsEndpoint) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("cloudlogs_endpoint", []map[string]interface{}{cloudLogsEndpointMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting cloudlogs_endpoint: %s", err)) + } + } + if target.CRN != nil { if err = d.Set("crn", target.CRN); err != nil { return diag.FromErr(fmt.Errorf("Error setting crn: %s", err)) @@ -443,7 +475,7 @@ func resourceIBMAtrackerTargetUpdate(context context.Context, d *schema.Resource hasChange := false - if d.HasChange("name") || d.HasChange("cos_endpoint") || d.HasChange("region") || d.HasChange("logdna_endpoint") || d.HasChange("eventstreams_endpoint") { + if d.HasChange("name") || d.HasChange("cos_endpoint") || d.HasChange("region") || d.HasChange("logdna_endpoint") || d.HasChange("eventstreams_endpoint") || d.HasChange("cloudlogs_endpoint") { replaceTargetOptions.SetName(d.Get("name").(string)) _, hasCosEndpoint := d.GetOk("cos_endpoint.0") @@ -471,6 +503,14 @@ func resourceIBMAtrackerTargetUpdate(context context.Context, d *schema.Resource } replaceTargetOptions.SetEventstreamsEndpoint(eventstreamsEndpoint) } + _, hasCloudLogsEndpoint := d.GetOk("cloudlogs_endpoint.0") + if hasCloudLogsEndpoint { + cloudlogsEndpoint, err := resourceIBMAtrackerTargetMapToCloudLogsEndpointPrototype(d.Get("cloudlogs_endpoint.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) + } + replaceTargetOptions.SetCloudlogsEndpoint(cloudlogsEndpoint) + } hasChange = true } @@ -539,6 +579,12 @@ func resourceIBMAtrackerTargetMapToEventstreamsEndpointPrototype(modelMap map[st return model, nil } +func resourceIBMAtrackerTargetMapToCloudLogsEndpointPrototype(modelMap map[string]interface{}) (*atrackerv2.CloudLogsEndpointPrototype, error) { + model := &atrackerv2.CloudLogsEndpointPrototype{} + model.TargetCRN = core.StringPtr(modelMap["target_crn"].(string)) + return model, nil +} + func resourceIBMAtrackerTargetCosEndpointPrototypeToMap(model *atrackerv2.CosEndpoint) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["endpoint"] = model.Endpoint @@ -568,6 +614,12 @@ func resourceIBMAtrackerTargetEventstreamsEndpointPrototypeToMap(model *atracker return modelMap, nil } +func resourceIBMAtrackerTargetCloudLogsEndpointPrototypeToMap(model *atrackerv2.CloudLogsEndpoint) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["target_crn"] = model.TargetCRN + return modelMap, nil +} + func resourceIBMAtrackerTargetWriteStatusToMap(model *atrackerv2.WriteStatus) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["status"] = model.Status diff --git a/website/docs/d/atracker_targets.html.markdown b/website/docs/d/atracker_targets.html.markdown index 2ff868251b..3ac5a2b988 100644 --- a/website/docs/d/atracker_targets.html.markdown +++ b/website/docs/d/atracker_targets.html.markdown @@ -35,7 +35,7 @@ Nested scheme for **targets**: * `name` - (String) The name of the target resource. * `crn` - (String) The crn of the target resource. * `target_type` - (String) The type of the target. - * Constraints: Allowable values are: `cloud_object_storage`, `logdna`, `event_streams`. + * Constraints: Allowable values are: `cloud_object_storage`, `logdna`, `event_streams`, `cloud_logs`. * `encrypt_key` - (String) The encryption key that is used to encrypt events before Activity Tracker services buffer them on storage. This credential is masked in the response. * `region` - (String) Included this optional field if you used it to create a target in a different region other than the one you are connected. * `cos_endpoint` - (List) Property values for a Cloud Object Storage Endpoint. @@ -55,16 +55,20 @@ 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 -._:\/]+$/`. * `target_crn` - (String) The CRN of the LogDNA instance. * 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. - * 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 -._:]+$/`. - * `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 -._:\/]+$/`. + * `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. + * 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 -._:]+$/`. + * `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. + Nested scheme for **cloudlogs_endpoint**: + * `target_crn` - (String) The CRN of the IBM Cloud Logs instance. + * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `write_status` - (List) The status of the write attempt to the target with the provided endpoint parameters. Nested scheme for **write_status**: * `last_failure` - (String) The timestamp of the failure. diff --git a/website/docs/r/atracker_target.html.markdown b/website/docs/r/atracker_target.html.markdown index 53eddbf694..96560c67ea 100644 --- a/website/docs/r/atracker_target.html.markdown +++ b/website/docs/r/atracker_target.html.markdown @@ -26,7 +26,6 @@ resource "ibm_atracker_target" "atracker_target" { } resource "ibm_atracker_target" "atracker_logdna_target" { - target_type = "logdna" logdna_endpoint { target_crn = "crn:v1:bluemix:public:logdna:us-south:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" ingestion_key = "xxxxxxxxxxxxxx" @@ -37,7 +36,6 @@ resource "ibm_atracker_target" "atracker_logdna_target" { } resource "ibm_atracker_target" "atracker_eventstreams_target" { - target_type = "event_streams" eventstreams_endpoint { target_crn = "crn:v1:bluemix:public:logdna:us-south:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" brokers = ["xxxxx.cloud.ibm.com:9093","yyyyy.cloud.ibm.com:9093"] @@ -49,6 +47,15 @@ resource "ibm_atracker_target" "atracker_eventstreams_target" { region = "us-south" } +resource "ibm_atracker_target" "atracker_cloudlogs_target" { + cloudlogs_endpoint { + target_crn = "crn:v1:bluemix:public:logs:eu-es:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" + } + name = "my-cloudlogs-target" + target_type = "cloud_logs" + region = "us-south" +} + ``` ## Argument reference @@ -82,6 +89,9 @@ Nested scheme for **eventstreams_endpoint**: * Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. * `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. + * `target_crn` - (String) The CRN of the IBM Cloud Logs instance. + * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `name` - (Required, String) The name of the target. The name must be 1000 characters or less, and cannot include any special characters other than `(space) - . _ :`. * Constraints: The maximum length is `1000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. * `region` - (Optional, String) Include this optional field if you want to create a target in a different region other than the one you are connected.