Skip to content

Commit 0078b2d

Browse files
klaarousSrividyaKamakshi
authored andcommitted
Added - Support for Connector Source/Targets with Private Endpoints
1 parent 521823f commit 0078b2d

File tree

5 files changed

+217
-25
lines changed

5 files changed

+217
-25
lines changed

internal/integrationtest/sch_service_connector_resource_test.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ import (
1717
)
1818

1919
var (
20+
SchServiceConnectorResourceDependenciesForPrivateStream = acctest.GenerateResourceFromRepresentationMap("oci_logging_log", "test_log", acctest.Required, acctest.Create, LoggingLogRepresentation) +
21+
acctest.GenerateResourceFromRepresentationMap("oci_logging_log", "test_update_log", acctest.Required, acctest.Update, acctest.GetUpdatedRepresentationCopy("configuration.source.category", acctest.Representation{RepType: acctest.Required, Create: `read`}, LoggingLogRepresentation)) +
22+
SchLoggingLogResourceDependencies +
23+
acctest.GenerateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group", acctest.Required, acctest.Create, CoreNetworkSecurityGroupRepresentation) +
24+
acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreSubnetRepresentation, map[string]interface{}{"prohibit_public_ip_on_vnic": acctest.Representation{RepType: acctest.Required, Create: `true`}, "prohibit_internet_ingress": acctest.Representation{RepType: acctest.Required, Create: `true`}})) +
25+
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, acctest.RepresentationCopyWithNewProperties(CoreVcnRepresentation, map[string]interface{}{
26+
"dns_label": acctest.Representation{RepType: acctest.Required, Create: `dnslabel`},
27+
})) +
28+
acctest.GenerateResourceFromRepresentationMap("oci_functions_application", "test_application", acctest.Required, acctest.Create, FunctionsApplicationRepresentation) +
29+
acctest.GenerateResourceFromRepresentationMap("oci_functions_function", "test_function", acctest.Required, acctest.Create, SchFunctionsFunctionRepresentation) +
30+
KeyResourceDependencyConfig + kmsKeyIdCreateVariableStr +
31+
acctest.GenerateResourceFromRepresentationMap("oci_streaming_stream", "test_stream", acctest.Optional, acctest.Create, streampoolidRepresentation) +
32+
acctest.GenerateResourceFromRepresentationMap("oci_streaming_stream_pool", "test_stream_pool", acctest.Optional, acctest.Create, StreamingStreamPoolRepresentation)
2033
// streaming as a source definition
2134
serviceConnectorStreamingSourceCursorRepresentation = map[string]interface{}{
2235
"kind": acctest.Representation{RepType: acctest.Optional, Create: `LATEST`, Update: `TRIM_HORIZON`},
@@ -137,8 +150,35 @@ func TestSchServiceConnectorResource_streamingAnalytics(t *testing.T) {
137150
singularDatasourceName := "data.oci_sch_service_connector.test_service_connector"
138151

139152
var resId, resId2 string
140-
141153
acctest.ResourceTest(t, testAccCheckSchServiceConnectorDestroy, []resource.TestStep{
154+
// verify private streaming as a source with functions target
155+
{
156+
Config: config + compartmentIdVariableStr + SchServiceConnectorResourceDependenciesForPrivateStream + imageVariableStr +
157+
acctest.GenerateResourceFromRepresentationMap("oci_sch_service_connector", "test_service_connector", acctest.Required, acctest.Create, serviceConnectorFunctionTargetStreamingSourceRepresentation),
158+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
159+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
160+
resource.TestCheckResourceAttr(resourceName, "display_name", "My_Service_Connector"),
161+
resource.TestCheckResourceAttr(resourceName, "source.#", "1"),
162+
resource.TestCheckResourceAttr(resourceName, "source.0.kind", "streaming"),
163+
resource.TestCheckResourceAttr(resourceName, "source.0.cursor.0.kind", "LATEST"),
164+
resource.TestCheckResourceAttrSet(resourceName, "source.0.stream_id"),
165+
resource.TestCheckResourceAttr(resourceName, "source.0.private_endpoint_metadata.#", "1"),
166+
resource.TestCheckResourceAttr(resourceName, "target.#", "1"),
167+
resource.TestCheckResourceAttr(resourceName, "target.0.kind", "functions"),
168+
resource.TestCheckResourceAttrSet(resourceName, "target.0.function_id"),
169+
170+
func(s *terraform.State) (err error) {
171+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
172+
return err
173+
},
174+
),
175+
},
176+
177+
// delete before next Create
178+
{
179+
Config: config + compartmentIdVariableStr + imageVariableStr,
180+
},
181+
142182
// verify streaming as a source with functions target
143183
{
144184
Config: config + compartmentIdVariableStr + SchServiceConnectorResourceDependencies + imageVariableStr +
@@ -298,6 +338,7 @@ func TestSchServiceConnectorResource_streamingAnalytics(t *testing.T) {
298338
},
299339
),
300340
},
341+
301342
// verify updates to updatable parameters
302343
{
303344
Config: config + compartmentIdVariableStr + SchServiceConnectorResourceDependencies + imageVariableStr + logAnLogGroupIdVariableStr + logAnLogSourceNameVariableStr +

internal/service/sch/sch_service_connector_resource.go

Lines changed: 148 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,27 @@ func SchServiceConnectorResource() *schema.Resource {
209209
},
210210

211211
// Computed
212+
"private_endpoint_metadata": {
213+
Type: schema.TypeList,
214+
Computed: true,
215+
Elem: &schema.Resource{
216+
Schema: map[string]*schema.Schema{
217+
// Required
218+
219+
// Optional
220+
221+
// Computed
222+
"rce_dns_proxy_ip_address": {
223+
Type: schema.TypeString,
224+
Computed: true,
225+
},
226+
"rce_traffic_ip_address": {
227+
Type: schema.TypeString,
228+
Computed: true,
229+
},
230+
},
231+
},
232+
},
212233
},
213234
},
214235
},
@@ -376,6 +397,27 @@ func SchServiceConnectorResource() *schema.Resource {
376397
},
377398

378399
// Computed
400+
"private_endpoint_metadata": {
401+
Type: schema.TypeList,
402+
Computed: true,
403+
Elem: &schema.Resource{
404+
Schema: map[string]*schema.Schema{
405+
// Required
406+
407+
// Optional
408+
409+
// Computed
410+
"rce_dns_proxy_ip_address": {
411+
Type: schema.TypeString,
412+
Computed: true,
413+
},
414+
"rce_traffic_ip_address": {
415+
Type: schema.TypeString,
416+
Computed: true,
417+
},
418+
},
419+
},
420+
},
379421
},
380422
},
381423
},
@@ -439,6 +481,27 @@ func SchServiceConnectorResource() *schema.Resource {
439481
},
440482

441483
// Computed
484+
"private_endpoint_metadata": {
485+
Type: schema.TypeList,
486+
Computed: true,
487+
Elem: &schema.Resource{
488+
Schema: map[string]*schema.Schema{
489+
// Required
490+
491+
// Optional
492+
493+
// Computed
494+
"rce_dns_proxy_ip_address": {
495+
Type: schema.TypeString,
496+
Computed: true,
497+
},
498+
"rce_traffic_ip_address": {
499+
Type: schema.TypeString,
500+
Computed: true,
501+
},
502+
},
503+
},
504+
},
442505
},
443506
},
444507
},
@@ -1304,6 +1367,20 @@ func MonitoringSourceSelectedNamespaceToMap(obj oci_sch.MonitoringSourceSelected
13041367
return result
13051368
}
13061369

1370+
func PrivateEndpointMetadataToMap(obj *oci_sch.PrivateEndpointMetadata) map[string]interface{} {
1371+
result := map[string]interface{}{}
1372+
1373+
if obj.RceDnsProxyIpAddress != nil {
1374+
result["rce_dns_proxy_ip_address"] = string(*obj.RceDnsProxyIpAddress)
1375+
}
1376+
1377+
if obj.RceTrafficIpAddress != nil {
1378+
result["rce_traffic_ip_address"] = string(*obj.RceTrafficIpAddress)
1379+
}
1380+
1381+
return result
1382+
}
1383+
13071384
func ServiceConnectorSummaryToMap(obj oci_sch.ServiceConnectorSummary) map[string]interface{} {
13081385
result := map[string]interface{}{}
13091386

@@ -1459,34 +1536,48 @@ func (s *SchServiceConnectorResourceCrud) mapToSourceDetails(fieldKeyFormat stri
14591536
return baseObject, nil
14601537
}
14611538

1462-
func SourceDetailsResponseToMap(obj *oci_sch.SourceDetails) map[string]interface{} {
1539+
func SourceDetailsResponseToMap(obj *oci_sch.SourceDetailsResponse) map[string]interface{} {
14631540
result := map[string]interface{}{}
14641541
switch v := (*obj).(type) {
1465-
case oci_sch.LoggingSourceDetails:
1542+
case oci_sch.LoggingSourceDetailsResponse:
14661543
result["kind"] = "logging"
14671544

14681545
logSources := []interface{}{}
14691546
for _, item := range v.LogSources {
14701547
logSources = append(logSources, LogSourceToMap(item))
14711548
}
14721549
result["log_sources"] = logSources
1473-
case oci_sch.MonitoringSourceDetails:
1550+
1551+
if v.PrivateEndpointMetadata != nil {
1552+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1553+
}
1554+
1555+
case oci_sch.MonitoringSourceDetailsResponse:
14741556
result["kind"] = "monitoring"
14751557

14761558
monitoringSources := []interface{}{}
14771559
for _, item := range v.MonitoringSources {
14781560
monitoringSources = append(monitoringSources, MonitoringSourceToMap(item))
14791561
}
14801562
result["monitoring_sources"] = monitoringSources
1481-
case oci_sch.PluginSourceDetails:
1563+
if v.PrivateEndpointMetadata != nil {
1564+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1565+
}
1566+
1567+
case oci_sch.PluginSourceDetailsResponse:
14821568
result["kind"] = "plugin"
14831569

14841570
result["config_map"] = ConfigMapJsonObjectToString(v.ConfigMap)
14851571

14861572
if v.PluginName != nil {
14871573
result["plugin_name"] = string(*v.PluginName)
14881574
}
1489-
case oci_sch.StreamingSourceDetails:
1575+
1576+
if v.PrivateEndpointMetadata != nil {
1577+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1578+
}
1579+
1580+
case oci_sch.StreamingSourceDetailsResponse:
14901581
result["kind"] = "streaming"
14911582

14921583
if v.Cursor != nil {
@@ -1500,6 +1591,10 @@ func SourceDetailsResponseToMap(obj *oci_sch.SourceDetails) map[string]interface
15001591
if v.StreamId != nil {
15011592
result["stream_id"] = string(*v.StreamId)
15021593
}
1594+
1595+
if v.PrivateEndpointMetadata != nil {
1596+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1597+
}
15031598
default:
15041599
log.Printf("[WARN] Received 'kind' of unknown type %v", *obj)
15051600
return nil
@@ -1669,10 +1764,10 @@ func (s *SchServiceConnectorResourceCrud) mapToTargetDetails(fieldKeyFormat stri
16691764
return baseObject, nil
16701765
}
16711766

1672-
func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface{} {
1767+
func TargetDetailsResponseToMap(obj *oci_sch.TargetDetailsResponse) map[string]interface{} {
16731768
result := map[string]interface{}{}
16741769
switch v := (*obj).(type) {
1675-
case oci_sch.FunctionsTargetDetails:
1770+
case oci_sch.FunctionsTargetDetailsResponse:
16761771
result["kind"] = "functions"
16771772

16781773
if v.BatchSizeInKbs != nil {
@@ -1690,7 +1785,12 @@ func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface
16901785
if v.FunctionId != nil {
16911786
result["function_id"] = string(*v.FunctionId)
16921787
}
1693-
case oci_sch.LoggingAnalyticsTargetDetails:
1788+
1789+
if v.PrivateEndpointMetadata != nil {
1790+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1791+
}
1792+
1793+
case oci_sch.LoggingAnalyticsTargetDetailsResponse:
16941794
result["kind"] = "loggingAnalytics"
16951795

16961796
if v.LogGroupId != nil {
@@ -1700,7 +1800,12 @@ func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface
17001800
if v.LogSourceIdentifier != nil {
17011801
result["log_source_identifier"] = string(*v.LogSourceIdentifier)
17021802
}
1703-
case oci_sch.MonitoringTargetDetails:
1803+
1804+
if v.PrivateEndpointMetadata != nil {
1805+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1806+
}
1807+
1808+
case oci_sch.MonitoringTargetDetailsResponse:
17041809
result["kind"] = "monitoring"
17051810

17061811
if v.CompartmentId != nil {
@@ -1720,7 +1825,12 @@ func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface
17201825
if v.MetricNamespace != nil {
17211826
result["metric_namespace"] = string(*v.MetricNamespace)
17221827
}
1723-
case oci_sch.NotificationsTargetDetails:
1828+
1829+
if v.PrivateEndpointMetadata != nil {
1830+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1831+
}
1832+
1833+
case oci_sch.NotificationsTargetDetailsResponse:
17241834
result["kind"] = "notifications"
17251835

17261836
if v.EnableFormattedMessaging != nil {
@@ -1730,7 +1840,12 @@ func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface
17301840
if v.TopicId != nil {
17311841
result["topic_id"] = string(*v.TopicId)
17321842
}
1733-
case oci_sch.ObjectStorageTargetDetails:
1843+
1844+
if v.PrivateEndpointMetadata != nil {
1845+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1846+
}
1847+
1848+
case oci_sch.ObjectStorageTargetDetailsResponse:
17341849
result["kind"] = "objectStorage"
17351850

17361851
if v.BatchRolloverSizeInMBs != nil {
@@ -1752,12 +1867,21 @@ func TargetDetailsResponseToMap(obj *oci_sch.TargetDetails) map[string]interface
17521867
if v.ObjectNamePrefix != nil {
17531868
result["object_name_prefix"] = string(*v.ObjectNamePrefix)
17541869
}
1755-
case oci_sch.StreamingTargetDetails:
1870+
1871+
if v.PrivateEndpointMetadata != nil {
1872+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1873+
}
1874+
1875+
case oci_sch.StreamingTargetDetailsResponse:
17561876
result["kind"] = "streaming"
17571877

17581878
if v.StreamId != nil {
17591879
result["stream_id"] = string(*v.StreamId)
17601880
}
1881+
1882+
if v.PrivateEndpointMetadata != nil {
1883+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1884+
}
17611885
default:
17621886
log.Printf("[WARN] Received 'kind' of unknown type %v", *obj)
17631887
return nil
@@ -1805,10 +1929,10 @@ func (s *SchServiceConnectorResourceCrud) mapToTaskDetails(fieldKeyFormat string
18051929
return baseObject, nil
18061930
}
18071931

1808-
func TaskDetailsResponseToMap(obj oci_sch.TaskDetails) map[string]interface{} {
1932+
func TaskDetailsResponseToMap(obj oci_sch.TaskDetailsResponse) map[string]interface{} {
18091933
result := map[string]interface{}{}
18101934
switch v := (obj).(type) {
1811-
case oci_sch.FunctionTaskDetails:
1935+
case oci_sch.FunctionTaskDetailsResponse:
18121936
result["kind"] = "function"
18131937

18141938
if v.BatchSizeInKbs != nil {
@@ -1822,12 +1946,21 @@ func TaskDetailsResponseToMap(obj oci_sch.TaskDetails) map[string]interface{} {
18221946
if v.FunctionId != nil {
18231947
result["function_id"] = string(*v.FunctionId)
18241948
}
1825-
case oci_sch.LogRuleTaskDetails:
1949+
1950+
if v.PrivateEndpointMetadata != nil {
1951+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1952+
}
1953+
1954+
case oci_sch.LogRuleTaskDetailsResponse:
18261955
result["kind"] = "logRule"
18271956

18281957
if v.Condition != nil {
18291958
result["condition"] = string(*v.Condition)
18301959
}
1960+
1961+
if v.PrivateEndpointMetadata != nil {
1962+
result["private_endpoint_metadata"] = []interface{}{PrivateEndpointMetadataToMap(v.PrivateEndpointMetadata)}
1963+
}
18311964
default:
18321965
log.Printf("[WARN] Received 'kind' of unknown type %v", obj)
18331966
return nil

0 commit comments

Comments
 (0)