Skip to content

Commit b68f0f0

Browse files
Terraform Team Automationvsin12
authored andcommitted
Added - Support for ScanProxy in Data Flow
1 parent ece26ce commit b68f0f0

File tree

7 files changed

+148
-1
lines changed

7 files changed

+148
-1
lines changed

examples/dataflow/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ resource "oci_dataflow_application" "tf_application" {
9696
#logs_bucket_uri = var.application_logs_bucket_uri}"
9797
type = "BATCH"
9898
archive_uri = var.application_archive_uri
99+
logs_bucket_uri = var.dataflow_logs_bucket_uri
99100
#parameters {
100101
#Required
101102
#name = var.application_parameters_name}"
@@ -159,7 +160,11 @@ resource "oci_dataflow_private_endpoint" "test_private_endpoint" {
159160
description = "description"
160161
display_name = "pe_name"
161162
dns_zones = ["custpvtsubnet.oraclevcn.com"]
162-
163+
scan_details {
164+
#Optional
165+
fqdn = "scan.test.com"
166+
port = "1521"
167+
}
163168
freeform_tags = {
164169
"Department" = "Finance"
165170
}
@@ -348,6 +353,7 @@ resource "oci_dataflow_application" "test_application_submit" {
348353
archive_uri = var.application_archive_uri
349354
private_endpoint_id = oci_dataflow_private_endpoint.test_private_endpoint.id
350355
metastore_id = var.metastore_id
356+
logs_bucket_uri = var.dataflow_logs_bucket_uri
351357
}
352358

353359
resource "oci_dataflow_invoke_run" "test_invokey_run_submit" {

internal/integrationtest/dataflow_private_endpoint_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ var (
5959
"max_host_count": acctest.Representation{RepType: acctest.Optional, Create: `256`, Update: `512`},
6060
"nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group.id}`}, Update: []string{}},
6161
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsChangesForDataFlowResource},
62+
"scan_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: DataflowPrivateEndpointScanDetailsRepresentation},
63+
}
64+
DataflowPrivateEndpointScanDetailsRepresentation = map[string]interface{}{
65+
"fqdn": acctest.Representation{RepType: acctest.Optional, Create: `scan.test1.com`, Update: `scan.test2.com`},
66+
"port": acctest.Representation{RepType: acctest.Optional, Create: `1521`, Update: `1522`},
6267
}
6368

6469
DataflowPrivateEndpointResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group", acctest.Required, acctest.Create, CoreNetworkSecurityGroupRepresentation) +
@@ -125,6 +130,9 @@ func TestDataflowPrivateEndpointResource_basic(t *testing.T) {
125130
resource.TestCheckResourceAttrSet(resourceName, "id"),
126131
resource.TestCheckResourceAttr(resourceName, "max_host_count", "256"),
127132
resource.TestCheckResourceAttrSet(resourceName, "owner_principal_id"),
133+
resource.TestCheckResourceAttr(resourceName, "scan_details.#", "1"),
134+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.fqdn", "scan.test1.com"),
135+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.port", "1521"),
128136
resource.TestCheckResourceAttrSet(resourceName, "state"),
129137
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
130138
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -158,6 +166,9 @@ func TestDataflowPrivateEndpointResource_basic(t *testing.T) {
158166
resource.TestCheckResourceAttrSet(resourceName, "id"),
159167
resource.TestCheckResourceAttr(resourceName, "max_host_count", "256"),
160168
resource.TestCheckResourceAttrSet(resourceName, "owner_principal_id"),
169+
resource.TestCheckResourceAttr(resourceName, "scan_details.#", "1"),
170+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.fqdn", "scan.test1.com"),
171+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.port", "1521"),
161172
resource.TestCheckResourceAttrSet(resourceName, "state"),
162173
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
163174
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -186,6 +197,9 @@ func TestDataflowPrivateEndpointResource_basic(t *testing.T) {
186197
resource.TestCheckResourceAttrSet(resourceName, "id"),
187198
resource.TestCheckResourceAttr(resourceName, "max_host_count", "512"),
188199
resource.TestCheckResourceAttrSet(resourceName, "owner_principal_id"),
200+
resource.TestCheckResourceAttr(resourceName, "scan_details.#", "1"),
201+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.fqdn", "scan.test2.com"),
202+
resource.TestCheckResourceAttr(resourceName, "scan_details.0.port", "1522"),
189203
resource.TestCheckResourceAttrSet(resourceName, "state"),
190204
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
191205
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
@@ -230,6 +244,9 @@ func TestDataflowPrivateEndpointResource_basic(t *testing.T) {
230244
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
231245
resource.TestCheckResourceAttr(singularDatasourceName, "max_host_count", "512"),
232246
resource.TestCheckResourceAttrSet(singularDatasourceName, "owner_user_name"),
247+
resource.TestCheckResourceAttr(singularDatasourceName, "scan_details.#", "1"),
248+
resource.TestCheckResourceAttr(singularDatasourceName, "scan_details.0.fqdn", "scan.test2.com"),
249+
resource.TestCheckResourceAttr(singularDatasourceName, "scan_details.0.port", "1522"),
233250
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
234251
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
235252
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_updated"),

internal/service/dataflow/dataflow_private_endpoint_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func (s *DataflowPrivateEndpointDataSourceCrud) SetData() error {
104104
s.D.Set("owner_user_name", *s.Res.OwnerUserName)
105105
}
106106

107+
scanDetails := []interface{}{}
108+
for _, item := range s.Res.ScanDetails {
109+
scanDetails = append(scanDetails, ScanToMap(item))
110+
}
111+
s.D.Set("scan_details", scanDetails)
112+
107113
s.D.Set("state", s.Res.LifecycleState)
108114

109115
if s.Res.SubnetId != nil {

internal/service/dataflow/dataflow_private_endpoint_resource.go

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@ func DataflowPrivateEndpointResource() *schema.Resource {
8787
Type: schema.TypeString,
8888
},
8989
},
90+
"scan_details": {
91+
Type: schema.TypeList,
92+
Optional: true,
93+
Computed: true,
94+
Elem: &schema.Resource{
95+
Schema: map[string]*schema.Schema{
96+
// Required
97+
98+
// Optional
99+
"fqdn": {
100+
Type: schema.TypeString,
101+
Optional: true,
102+
Computed: true,
103+
},
104+
"port": {
105+
Type: schema.TypeString,
106+
Optional: true,
107+
Computed: true,
108+
},
109+
110+
// Computed
111+
},
112+
},
113+
},
90114

91115
// Computed
92116
"lifecycle_details": {
@@ -247,6 +271,23 @@ func (s *DataflowPrivateEndpointResourceCrud) Create() error {
247271
}
248272
}
249273

274+
if scanDetails, ok := s.D.GetOkExists("scan_details"); ok {
275+
interfaces := scanDetails.([]interface{})
276+
tmp := make([]oci_dataflow.Scan, len(interfaces))
277+
for i := range interfaces {
278+
stateDataIndex := i
279+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "scan_details", stateDataIndex)
280+
converted, err := s.mapToScan(fieldKeyFormat)
281+
if err != nil {
282+
return err
283+
}
284+
tmp[i] = converted
285+
}
286+
if len(tmp) != 0 || s.D.HasChange("scan_details") {
287+
request.ScanDetails = tmp
288+
}
289+
}
290+
250291
if subnetId, ok := s.D.GetOkExists("subnet_id"); ok {
251292
tmp := subnetId.(string)
252293
request.SubnetId = &tmp
@@ -466,6 +507,23 @@ func (s *DataflowPrivateEndpointResourceCrud) Update() error {
466507
tmp := s.D.Id()
467508
request.PrivateEndpointId = &tmp
468509

510+
if scanDetails, ok := s.D.GetOkExists("scan_details"); ok {
511+
interfaces := scanDetails.([]interface{})
512+
tmp := make([]oci_dataflow.Scan, len(interfaces))
513+
for i := range interfaces {
514+
stateDataIndex := i
515+
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "scan_details", stateDataIndex)
516+
converted, err := s.mapToScan(fieldKeyFormat)
517+
if err != nil {
518+
return err
519+
}
520+
tmp[i] = converted
521+
}
522+
if len(tmp) != 0 || s.D.HasChange("scan_details") {
523+
request.ScanDetails = tmp
524+
}
525+
}
526+
469527
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "dataflow")
470528

471529
response, err := s.Client.UpdatePrivateEndpoint(context.Background(), request)
@@ -540,6 +598,12 @@ func (s *DataflowPrivateEndpointResourceCrud) SetData() error {
540598
s.D.Set("owner_user_name", *s.Res.OwnerUserName)
541599
}
542600

601+
scanDetails := []interface{}{}
602+
for _, item := range s.Res.ScanDetails {
603+
scanDetails = append(scanDetails, ScanToMap(item))
604+
}
605+
s.D.Set("scan_details", scanDetails)
606+
543607
s.D.Set("state", s.Res.LifecycleState)
544608

545609
if s.Res.SubnetId != nil {
@@ -602,6 +666,12 @@ func PrivateEndpointSummaryToMap(obj oci_dataflow.PrivateEndpointSummary, dataso
602666
result["owner_user_name"] = string(*obj.OwnerUserName)
603667
}
604668

669+
scanDetails := []interface{}{}
670+
for _, item := range obj.ScanDetails {
671+
scanDetails = append(scanDetails, ScanToMap(item))
672+
}
673+
result["scan_details"] = scanDetails
674+
605675
result["state"] = string(obj.LifecycleState)
606676

607677
if obj.SubnetId != nil {
@@ -619,6 +689,36 @@ func PrivateEndpointSummaryToMap(obj oci_dataflow.PrivateEndpointSummary, dataso
619689
return result
620690
}
621691

692+
func (s *DataflowPrivateEndpointResourceCrud) mapToScan(fieldKeyFormat string) (oci_dataflow.Scan, error) {
693+
result := oci_dataflow.Scan{}
694+
695+
if fqdn, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "fqdn")); ok {
696+
tmp := fqdn.(string)
697+
result.Fqdn = &tmp
698+
}
699+
700+
if port, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "port")); ok {
701+
tmp := port.(string)
702+
result.Port = &tmp
703+
}
704+
705+
return result, nil
706+
}
707+
708+
func ScanToMap(obj oci_dataflow.Scan) map[string]interface{} {
709+
result := map[string]interface{}{}
710+
711+
if obj.Fqdn != nil {
712+
result["fqdn"] = string(*obj.Fqdn)
713+
}
714+
715+
if obj.Port != nil {
716+
result["port"] = string(*obj.Port)
717+
}
718+
719+
return result
720+
}
721+
622722
func (s *DataflowPrivateEndpointResourceCrud) updateCompartment(compartment interface{}) error {
623723
changeCompartmentRequest := oci_dataflow.ChangePrivateEndpointCompartmentRequest{}
624724

website/docs/d/dataflow_private_endpoint.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ The following attributes are exported:
4545
* `nsg_ids` - An array of network security group OCIDs.
4646
* `owner_principal_id` - The OCID of the user who created the resource.
4747
* `owner_user_name` - The username of the user who created the resource. If the username of the owner does not exist, `null` will be returned and the caller should refer to the ownerPrincipalId value instead.
48+
* `scan_details` - An array of fqdn/port pairs used to create private endpoint. Each object is a simple key-value pair with FQDN as key and port number as value. [ { fqdn: "scan1.oracle.com", port: "1521"}, { fqdn: "scan2.oracle.com", port: "1521" } ]
49+
* `fqdn` - A fully-qualified domain name (FQDN).
50+
* `port` - The port number of the FQDN
4851
* `state` - The current state of this private endpoint.
4952
* `subnet_id` - The OCID of a subnet.
5053
* `time_created` - The date and time a application was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. Example: `2018-04-03T21:10:29.600Z`

website/docs/d/dataflow_private_endpoints.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ The following attributes are exported:
6161
* `nsg_ids` - An array of network security group OCIDs.
6262
* `owner_principal_id` - The OCID of the user who created the resource.
6363
* `owner_user_name` - The username of the user who created the resource. If the username of the owner does not exist, `null` will be returned and the caller should refer to the ownerPrincipalId value instead.
64+
* `scan_details` - An array of fqdn/port pairs used to create private endpoint. Each object is a simple key-value pair with FQDN as key and port number as value. [ { fqdn: "scan1.oracle.com", port: "1521"}, { fqdn: "scan2.oracle.com", port: "1521" } ]
65+
* `fqdn` - A fully-qualified domain name (FQDN).
66+
* `port` - The port number of the FQDN
6467
* `state` - The current state of this private endpoint.
6568
* `subnet_id` - The OCID of a subnet.
6669
* `time_created` - The date and time a application was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. Example: `2018-04-03T21:10:29.600Z`

website/docs/r/dataflow_private_endpoint.html.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ resource "oci_dataflow_private_endpoint" "test_private_endpoint" {
2929
freeform_tags = {"Department"= "Finance"}
3030
max_host_count = var.private_endpoint_max_host_count
3131
nsg_ids = var.private_endpoint_nsg_ids
32+
scan_details {
33+
34+
#Optional
35+
fqdn = var.private_endpoint_scan_details_fqdn
36+
port = var.private_endpoint_scan_details_port
37+
}
3238
}
3339
```
3440

@@ -44,6 +50,9 @@ The following arguments are supported:
4450
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
4551
* `max_host_count` - (Optional) (Updatable) The maximum number of hosts to be accessed through the private endpoint. This value is used to calculate the relevant CIDR block and should be a multiple of 256. If the value is not a multiple of 256, it is rounded up to the next multiple of 256. For example, 300 is rounded up to 512.
4652
* `nsg_ids` - (Optional) (Updatable) An array of network security group OCIDs.
53+
* `scan_details` - (Optional) (Updatable) An array of fqdn/port pairs used to create private endpoint. Each object is a simple key-value pair with FQDN as key and port number as value. [ { fqdn: "scan1.oracle.com", port: "1521"}, { fqdn: "scan2.oracle.com", port: "1521" } ]
54+
* `fqdn` - (Optional) (Updatable) A fully-qualified domain name (FQDN).
55+
* `port` - (Optional) (Updatable) The port number of the FQDN
4756
* `subnet_id` - (Required) The OCID of a subnet.
4857

4958

@@ -66,6 +75,9 @@ The following attributes are exported:
6675
* `nsg_ids` - An array of network security group OCIDs.
6776
* `owner_principal_id` - The OCID of the user who created the resource.
6877
* `owner_user_name` - The username of the user who created the resource. If the username of the owner does not exist, `null` will be returned and the caller should refer to the ownerPrincipalId value instead.
78+
* `scan_details` - An array of fqdn/port pairs used to create private endpoint. Each object is a simple key-value pair with FQDN as key and port number as value. [ { fqdn: "scan1.oracle.com", port: "1521"}, { fqdn: "scan2.oracle.com", port: "1521" } ]
79+
* `fqdn` - A fully-qualified domain name (FQDN).
80+
* `port` - The port number of the FQDN
6981
* `state` - The current state of this private endpoint.
7082
* `subnet_id` - The OCID of a subnet.
7183
* `time_created` - The date and time a application was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. Example: `2018-04-03T21:10:29.600Z`

0 commit comments

Comments
 (0)