diff --git a/ibm/service/atracker/resource_ibm_atracker_route_test.go b/ibm/service/atracker/resource_ibm_atracker_route_test.go index ea29002c4b..579f821e7c 100644 --- a/ibm/service/atracker/resource_ibm_atracker_route_test.go +++ b/ibm/service/atracker/resource_ibm_atracker_route_test.go @@ -48,6 +48,38 @@ func TestAccIBMAtrackerRouteBasic(t *testing.T) { }) } +func TestAccIBMAtrackerRouteBasicMultipleRules(t *testing.T) { + var conf atrackerv2.Route + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMAtrackerRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIBMAtrackerRouteExists("ibm_atracker_route.atracker_route", conf), + resource.TestCheckResourceAttr("ibm_atracker_route.atracker_route", "name", name), + ), + }, + { + Config: testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(nameUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_atracker_route.atracker_route", "name", nameUpdate), + ), + }, + { + ResourceName: "ibm_atracker_route.atracker_route", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckIBMAtrackerRouteConfigBasic(name string) string { return fmt.Sprintf(` resource "ibm_atracker_target" "atracker_target" { @@ -71,6 +103,33 @@ func testAccCheckIBMAtrackerRouteConfigBasic(name string) string { `, name) } +func testAccCheckIBMAtrackerRouteConfigBasicMultipleRules(name string) string { + return fmt.Sprintf(` + resource "ibm_atracker_target" "atracker_target" { + name = "my-cos-target" + target_type = "cloud_object_storage" + cos_endpoint { + endpoint = "s3.private.us-east.cloud-object-storage.appdomain.cloud" + target_crn = "crn:v1:bluemix:public:cloud-object-storage:global:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" + bucket = "my-atracker-bucket" + api_key = "xxxxxxxxxxxxxx" + } + } + + resource "ibm_atracker_route" "atracker_route" { + name = "%s" + rules { + target_ids = [ ibm_atracker_target.atracker_target.id ] + locations = [ "us-south" ] + } + rules { + target_ids = [ ibm_atracker_target.atracker_target.id ] + locations = [ "us-east" ] + } + } + `, name) +} + func testAccCheckIBMAtrackerRouteExists(n string, obj atrackerv2.Route) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/website/docs/r/atracker_route.html.markdown b/website/docs/r/atracker_route.html.markdown index cf3570bb51..8a501634f8 100644 --- a/website/docs/r/atracker_route.html.markdown +++ b/website/docs/r/atracker_route.html.markdown @@ -12,6 +12,7 @@ Provides a resource for Activity Tracker Route. This allows Activity Tracker Rou ## Example usage +### Example with a single rule ```terraform resource "ibm_atracker_route" "atracker_route" { name = "my-route" @@ -26,6 +27,26 @@ resource "ibm_atracker_route" "atracker_route" { } ``` +### Example with multiple rules + +```terraform +resource "ibm_atracker_route" "atracker_route" { + name = "my-route" + rules { + target_ids = [ ibm_atracker_target.atracker_target.id ] + locations = [ "us-south", "global" ] + } + rules { + target_ids = [ ibm_atracker_target.atracker_target.id ] + locations = [ "us-east" ] + } + lifecycle { + # Recommended to ensure that if a target ID is removed here and destroyed in a plan, this is updated first + create_before_destroy = true + } +} +``` + ## Argument reference Review the argument reference that you can specify for your resource. diff --git a/website/docs/r/atracker_settings.html.markdown b/website/docs/r/atracker_settings.html.markdown index be26ebf20d..8340ab54be 100644 --- a/website/docs/r/atracker_settings.html.markdown +++ b/website/docs/r/atracker_settings.html.markdown @@ -34,7 +34,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -]/`. * `metadata_region_primary` - (Required, String) To store all your meta data in a single region. * Constraints: The maximum length is `256` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -_]/`. -* `metadata_region_primary` - (Optional, String) To store all your meta data in a backup region. +* `metadata_region_backup` - (Optional, String) To store all your meta data in a backup region. * Constraints: The maximum length is `256` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -_]/`. * `permitted_target_regions` - (Optional, List) If present then only these regions may be used to define a target. * Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -_]/`. diff --git a/website/docs/r/atracker_target.html.markdown b/website/docs/r/atracker_target.html.markdown index e22073ea4c..53eddbf694 100644 --- a/website/docs/r/atracker_target.html.markdown +++ b/website/docs/r/atracker_target.html.markdown @@ -40,9 +40,9 @@ 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"] - "topic": "my-topic" - "api_key": "api-key" // pragma: allowlist secret + brokers = ["xxxxx.cloud.ibm.com:9093","yyyyy.cloud.ibm.com:9093"] + topic = "my-topic" + api_key = "api-key" // pragma: allowlist secret } name = "my-eventstreams-target" target_type = "event_streams"