Skip to content

Commit a27ea38

Browse files
committed
Support for Data Safe target database registration
1 parent d5d5a1e commit a27ea38

27 files changed

+2305
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## 4.30.0 (June 09, 2021)
22

3+
### Added
4+
- Support for Data Safe target database registration
5+
6+
## 4.30.0 (June 09, 2021)
7+
38
### Added
49
- Support for Higher performance volumes added to `core`
510
- Support for End-to-end encryption for Bare Metal hosts to `core`

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ skip_goimports_check_flag := $(if $(skip_goimports_check), -s, )
1515
## This rule will set GO mod environment variables so that builds/tests are using the vendor folder
1616
## May need to remove this in future so that it doesn't interfere with environment settings of .travis.yml file
1717
gomodenv:
18-
export GO111MODULE=on
18+
export GO111MODULE=off
1919
export GOFLAGS=-mod=vendor
2020

2121
default: build
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {
5+
}
6+
7+
variable "user_ocid" {
8+
}
9+
10+
variable "fingerprint" {
11+
}
12+
13+
variable "private_key_path" {
14+
}
15+
16+
variable "region" {
17+
}
18+
19+
variable "compartment_ocid" {
20+
}
21+
22+
provider "oci" {
23+
tenancy_ocid = var.tenancy_ocid
24+
user_ocid = var.user_ocid
25+
fingerprint = var.fingerprint
26+
private_key_path = var.private_key_path
27+
region = var.region
28+
}
29+
30+
resource "oci_core_vcn" "test_vcn" {
31+
cidr_block = "10.0.0.0/16"
32+
compartment_id = var.compartment_ocid
33+
display_name = "exampleVCN"
34+
dns_label = "tfexamplevcn"
35+
}
36+
37+
resource "oci_core_subnet" "test_subnet" {
38+
cidr_block = "10.0.1.0/24"
39+
display_name = "regionalSubnet"
40+
dns_label = "regionalsubnet"
41+
compartment_id = var.compartment_ocid
42+
vcn_id = oci_core_vcn.test_vcn.id
43+
}
44+
45+
resource "oci_data_safe_data_safe_configuration" "test_data_safe_configuration" {
46+
is_enabled = "true"
47+
}
48+
49+
resource "oci_data_safe_data_safe_private_endpoint" "test_data_safe_private_endpoint" {
50+
compartment_id = var.compartment_ocid
51+
display_name = "PE2"
52+
subnet_id = oci_core_subnet.test_subnet.id
53+
vcn_id = oci_core_vcn.test_vcn.id
54+
}
55+
56+
variable "target_database_description" {
57+
default = "description"
58+
}
59+
60+
variable "target_database_display_name" {
61+
default = "targetDatabase1"
62+
}
63+
64+
resource "random_string" "autonomous_database_admin_password" {
65+
length = 16
66+
min_numeric = 1
67+
min_lower = 1
68+
min_upper = 1
69+
min_special = 1
70+
}
71+
variable "autonomous_database_db_workload" {
72+
default = "OLTP"
73+
}
74+
75+
variable "autonomous_database_freeform_tags" {
76+
default = {
77+
"Department" = "Finance"
78+
}
79+
}
80+
81+
variable "autonomous_database_license_model" {
82+
default = "LICENSE_INCLUDED"
83+
}
84+
85+
resource "oci_database_autonomous_database" "autonomous_database" {
86+
#Required
87+
admin_password = random_string.autonomous_database_admin_password.result
88+
compartment_id = var.compartment_ocid
89+
cpu_core_count = "1"
90+
data_storage_size_in_tbs = "1"
91+
db_name = "adbdb1"
92+
93+
#Optional
94+
db_workload = var.autonomous_database_db_workload
95+
display_name = "example_autonomous_database"
96+
freeform_tags = var.autonomous_database_freeform_tags
97+
is_auto_scaling_enabled = "true"
98+
license_model = var.autonomous_database_license_model
99+
is_preview_version_with_service_terms_accepted = "false"
100+
}
101+
102+
resource "oci_data_safe_target_database" "test_target_database" {
103+
#Required
104+
compartment_id = var.compartment_ocid
105+
display_name = var.target_database_display_name
106+
107+
database_details {
108+
database_type = "AUTONOMOUS_DATABASE"
109+
infrastructure_type = "ORACLE_CLOUD"
110+
autonomous_database_id = oci_database_autonomous_database.autonomous_database.id
111+
}
112+
113+
#Optional
114+
connection_option {
115+
connection_type = "PRIVATE_ENDPOINT"
116+
datasafe_private_endpoint_id = oci_data_safe_data_safe_private_endpoint.test_data_safe_private_endpoint.id
117+
}
118+
description = var.target_database_description
119+
}
120+
121+
data "oci_data_safe_target_databases" "test_target_databases" {
122+
compartment_id = var.compartment_ocid
123+
display_name = var.target_database_display_name
124+
target_database_id = oci_data_safe_target_database.test_target_database.id
125+
}

oci/data_safe_data_safe_private_endpoint_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func (s *DataSafeDataSafePrivateEndpointDataSourceCrud) SetData() error {
105105
s.D.Set("subnet_id", *s.Res.SubnetId)
106106
}
107107

108+
if s.Res.SystemTags != nil {
109+
s.D.Set("system_tags", systemTagsToMap(s.Res.SystemTags))
110+
}
111+
108112
if s.Res.TimeCreated != nil {
109113
s.D.Set("time_created", s.Res.TimeCreated.String())
110114
}

oci/data_safe_data_safe_private_endpoint_resource.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ func DataSafeDataSafePrivateEndpointResource() *schema.Resource {
100100
Type: schema.TypeString,
101101
Computed: true,
102102
},
103+
"system_tags": {
104+
Type: schema.TypeMap,
105+
Computed: true,
106+
Elem: schema.TypeString,
107+
},
103108
"time_created": {
104109
Type: schema.TypeString,
105110
Computed: true,
@@ -502,6 +507,10 @@ func (s *DataSafeDataSafePrivateEndpointResourceCrud) SetData() error {
502507
s.D.Set("subnet_id", *s.Res.SubnetId)
503508
}
504509

510+
if s.Res.SystemTags != nil {
511+
s.D.Set("system_tags", systemTagsToMap(s.Res.SystemTags))
512+
}
513+
505514
if s.Res.TimeCreated != nil {
506515
s.D.Set("time_created", s.Res.TimeCreated.String())
507516
}

oci/data_safe_data_safe_private_endpoint_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ var (
3131
}
3232

3333
dataSafePrivateEndpointDataSourceRepresentation = map[string]interface{}{
34-
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
35-
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
36-
"state": Representation{repType: Optional, create: `ACTIVE`},
37-
"vcn_id": Representation{repType: Optional, create: `${oci_core_vcn.test_vcn.id}`},
38-
"filter": RepresentationGroup{Required, dataSafePrivateEndpointDataSourceFilterRepresentation}}
34+
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
35+
"access_level": Representation{repType: Optional, create: `RESTRICTED`},
36+
"compartment_id_in_subtree": Representation{repType: Optional, create: `true`},
37+
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
38+
"state": Representation{repType: Optional, create: `ACTIVE`},
39+
"vcn_id": Representation{repType: Optional, create: `${oci_core_vcn.test_vcn.id}`},
40+
"filter": RepresentationGroup{Required, dataSafePrivateEndpointDataSourceFilterRepresentation}}
3941
dataSafePrivateEndpointDataSourceFilterRepresentation = map[string]interface{}{
4042
"name": Representation{repType: Required, create: `id`},
4143
"values": Representation{repType: Required, create: []string{`${oci_data_safe_data_safe_private_endpoint.test_data_safe_private_endpoint.id}`}},
@@ -199,15 +201,19 @@ func TestDataSafeDataSafePrivateEndpointResource_basic(t *testing.T) {
199201
compartmentIdVariableStr + DataSafePrivateEndpointResourceDependencies +
200202
generateResourceFromRepresentationMap("oci_data_safe_data_safe_private_endpoint", "test_data_safe_private_endpoint", Optional, Update, dataSafePrivateEndpointRepresentation),
201203
Check: resource.ComposeAggregateTestCheckFunc(
204+
resource.TestCheckResourceAttr(datasourceName, "access_level", "RESTRICTED"),
202205
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
206+
resource.TestCheckResourceAttr(datasourceName, "compartment_id_in_subtree", "true"),
203207
resource.TestCheckResourceAttr(datasourceName, "display_name", "displayName2"),
204208
resource.TestCheckResourceAttr(datasourceName, "state", "ACTIVE"),
205209
resource.TestCheckResourceAttrSet(datasourceName, "vcn_id"),
206210

207211
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.#", "1"),
208212
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.0.compartment_id", compartmentId),
213+
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.0.defined_tags.%", "0"),
209214
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.0.description", "description2"),
210215
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.0.display_name", "displayName2"),
216+
resource.TestCheckResourceAttr(datasourceName, "data_safe_private_endpoints.0.freeform_tags.%", "0"),
211217
resource.TestCheckResourceAttrSet(datasourceName, "data_safe_private_endpoints.0.id"),
212218
resource.TestCheckResourceAttrSet(datasourceName, "data_safe_private_endpoints.0.private_endpoint_id"),
213219
resource.TestCheckResourceAttrSet(datasourceName, "data_safe_private_endpoints.0.state"),

oci/data_safe_data_safe_private_endpoints_data_source.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ func DataSafeDataSafePrivateEndpointsDataSource() *schema.Resource {
1919
Read: readDataSafeDataSafePrivateEndpoints,
2020
Schema: map[string]*schema.Schema{
2121
"filter": dataSourceFiltersSchema(),
22+
"access_level": {
23+
Type: schema.TypeString,
24+
Optional: true,
25+
},
2226
"compartment_id": {
2327
Type: schema.TypeString,
2428
Required: true,
2529
},
30+
"compartment_id_in_subtree": {
31+
Type: schema.TypeBool,
32+
Optional: true,
33+
},
2634
"display_name": {
2735
Type: schema.TypeString,
2836
Optional: true,
@@ -65,11 +73,20 @@ func (s *DataSafeDataSafePrivateEndpointsDataSourceCrud) VoidState() {
6573
func (s *DataSafeDataSafePrivateEndpointsDataSourceCrud) Get() error {
6674
request := oci_data_safe.ListDataSafePrivateEndpointsRequest{}
6775

76+
if accessLevel, ok := s.D.GetOkExists("access_level"); ok {
77+
request.AccessLevel = oci_data_safe.ListDataSafePrivateEndpointsAccessLevelEnum(accessLevel.(string))
78+
}
79+
6880
if compartmentId, ok := s.D.GetOkExists("compartment_id"); ok {
6981
tmp := compartmentId.(string)
7082
request.CompartmentId = &tmp
7183
}
7284

85+
if compartmentIdInSubtree, ok := s.D.GetOkExists("compartment_id_in_subtree"); ok {
86+
tmp := compartmentIdInSubtree.(bool)
87+
request.CompartmentIdInSubtree = &tmp
88+
}
89+
7390
if displayName, ok := s.D.GetOkExists("display_name"); ok {
7491
tmp := displayName.(string)
7592
request.DisplayName = &tmp
@@ -120,6 +137,10 @@ func (s *DataSafeDataSafePrivateEndpointsDataSourceCrud) SetData() error {
120137
"compartment_id": *r.CompartmentId,
121138
}
122139

140+
if r.DefinedTags != nil {
141+
dataSafePrivateEndpoint["defined_tags"] = definedTagsToMap(r.DefinedTags)
142+
}
143+
123144
if r.Description != nil {
124145
dataSafePrivateEndpoint["description"] = *r.Description
125146
}
@@ -128,6 +149,8 @@ func (s *DataSafeDataSafePrivateEndpointsDataSourceCrud) SetData() error {
128149
dataSafePrivateEndpoint["display_name"] = *r.DisplayName
129150
}
130151

152+
dataSafePrivateEndpoint["freeform_tags"] = r.FreeformTags
153+
131154
if r.Id != nil {
132155
dataSafePrivateEndpoint["id"] = *r.Id
133156
}
@@ -142,6 +165,10 @@ func (s *DataSafeDataSafePrivateEndpointsDataSourceCrud) SetData() error {
142165
dataSafePrivateEndpoint["subnet_id"] = *r.SubnetId
143166
}
144167

168+
if r.SystemTags != nil {
169+
dataSafePrivateEndpoint["system_tags"] = systemTagsToMap(r.SystemTags)
170+
}
171+
145172
if r.TimeCreated != nil {
146173
dataSafePrivateEndpoint["time_created"] = r.TimeCreated.String()
147174
}

oci/data_safe_on_prem_connector_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ func (s *DataSafeOnPremConnectorDataSourceCrud) SetData() error {
9999

100100
s.D.Set("state", s.Res.LifecycleState)
101101

102+
if s.Res.SystemTags != nil {
103+
s.D.Set("system_tags", systemTagsToMap(s.Res.SystemTags))
104+
}
105+
102106
if s.Res.TimeCreated != nil {
103107
s.D.Set("time_created", s.Res.TimeCreated.String())
104108
}

oci/data_safe_on_prem_connector_resource.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func DataSafeOnPremConnectorResource() *schema.Resource {
8080
Type: schema.TypeString,
8181
Computed: true,
8282
},
83+
"system_tags": {
84+
Type: schema.TypeMap,
85+
Computed: true,
86+
Elem: schema.TypeString,
87+
},
8388
"time_created": {
8489
Type: schema.TypeString,
8590
Computed: true,
@@ -430,6 +435,8 @@ func (s *DataSafeOnPremConnectorResourceCrud) SetData() error {
430435

431436
s.D.Set("state", s.Res.LifecycleState)
432437

438+
s.D.Set("system_tags", systemTagsToMap(s.Res.SystemTags))
439+
433440
if s.Res.TimeCreated != nil {
434441
s.D.Set("time_created", s.Res.TimeCreated.String())
435442
}

oci/data_safe_on_prem_connector_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var (
3232

3333
onPremConnectorDataSourceRepresentation = map[string]interface{}{
3434
"compartment_id": Representation{repType: Required, create: `${var.compartment_id}`},
35+
"access_level": Representation{repType: Optional, create: `RESTRICTED`},
36+
"compartment_id_in_subtree": Representation{repType: Optional, create: `true`},
3537
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
3638
"on_prem_connector_id": Representation{repType: Optional, create: `${oci_data_safe_on_prem_connector.test_on_prem_connector.id}`},
3739
"on_prem_connector_lifecycle_state": Representation{repType: Optional, create: `INACTIVE`},
@@ -184,7 +186,9 @@ func TestDataSafeOnPremConnectorResource_basic(t *testing.T) {
184186
compartmentIdVariableStr + OnPremConnectorResourceDependencies +
185187
generateResourceFromRepresentationMap("oci_data_safe_on_prem_connector", "test_on_prem_connector", Optional, Update, onPremConnectorRepresentation),
186188
Check: resource.ComposeAggregateTestCheckFunc(
189+
resource.TestCheckResourceAttr(datasourceName, "access_level", "RESTRICTED"),
187190
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
191+
resource.TestCheckResourceAttr(datasourceName, "compartment_id_in_subtree", "true"),
188192
resource.TestCheckResourceAttr(datasourceName, "display_name", "displayName2"),
189193
resource.TestCheckResourceAttrSet(datasourceName, "on_prem_connector_id"),
190194
resource.TestCheckResourceAttr(datasourceName, "on_prem_connector_lifecycle_state", "INACTIVE"),

0 commit comments

Comments
 (0)