Skip to content

Commit a05fc12

Browse files
Sandeep KokajiaqchenO
authored andcommitted
Added - Support for ADB-S: Allow Public Access to Databases on Private Endpoint
1 parent a11291b commit a05fc12

9 files changed

+321
-0
lines changed

internal/integrationtest/database_autonomous_database_resource_test.go

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ var (
209209
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_core_subnet.test_subnet.id}`},
210210
}), []string{"whitelisted_ips", "scheduled_operations"})
211211

212+
autonomousDatabasePEWithPublicAccessRepresentation = acctest.RepresentationCopyWithRemovedProperties(
213+
acctest.RepresentationCopyWithNewProperties(
214+
DatabaseAutonomousDatabaseRepresentation,
215+
map[string]interface{}{
216+
"nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group.id}`}, Update: []string{`${oci_core_network_security_group.test_network_security_group.id}`, `${oci_core_network_security_group.test_network_security_group2.id}`}},
217+
"private_endpoint_label": acctest.Representation{RepType: acctest.Optional, Create: `xlx4fc9y`},
218+
"private_endpoint_ip": acctest.Representation{RepType: acctest.Optional, Create: `10.0.0.97`},
219+
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `${oci_core_subnet.test_subnet.id}`},
220+
"whitelisted_ips": acctest.Representation{RepType: acctest.Optional, Create: []string{`1.1.1.1/28`}},
221+
}), []string{"scheduled_operations"})
222+
212223
AutonomousDatabasePrivateEndpointResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_core_subnet", "test_subnet", acctest.Required, acctest.Create, CoreSubnetRepresentation) +
213224
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation) +
214225
acctest.GenerateResourceFromRepresentationMap("oci_core_network_security_group", "test_network_security_group", acctest.Required, acctest.Create, CoreNetworkSecurityGroupRepresentation) +
@@ -1934,6 +1945,138 @@ func TestResourceDatabaseAutonomousDatabaseResource_privateEndpoint(t *testing.T
19341945
})
19351946
}
19361947

1948+
// issue-routing-tag: database/dbaas-adb
1949+
func TestResourceDatabaseAutonomousDatabaseResource_privateEndpointWithPublicAccess(t *testing.T) {
1950+
httpreplay.SetScenario("TestResourceDatabaseAutonomousDatabaseResource_privateEndPointWithPublicAccess")
1951+
defer httpreplay.SaveScenario()
1952+
1953+
config := acctest.ProviderTestConfig()
1954+
1955+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
1956+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
1957+
1958+
resourceName := "oci_database_autonomous_database.test_autonomous_database"
1959+
1960+
var resId, resId2 string
1961+
1962+
acctest.ResourceTest(t, testAccCheckDatabaseAutonomousDatabaseDestroy, []resource.TestStep{
1963+
//0. verify create
1964+
{
1965+
Config: config + compartmentIdVariableStr + AutonomousDatabasePrivateEndpointResourceDependencies +
1966+
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", acctest.Optional, acctest.Create, autonomousDatabasePEWithPublicAccessRepresentation),
1967+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
1968+
resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#11"),
1969+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
1970+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
1971+
resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"),
1972+
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
1973+
resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"),
1974+
resource.TestCheckResourceAttr(resourceName, "display_name", "example_autonomous_database"),
1975+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
1976+
resource.TestCheckResourceAttrSet(resourceName, "id"),
1977+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
1978+
resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"),
1979+
resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"),
1980+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
1981+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_ip", "10.0.0.97"),
1982+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_label", "xlx4fc9y"),
1983+
resource.TestCheckResourceAttr(resourceName, "whitelisted_ips", "1.1.1.1/28"),
1984+
resource.TestCheckResourceAttr(resourceName, "nsg_ids.#", "1"),
1985+
resource.TestCheckResourceAttrSet(resourceName, "state"),
1986+
resource.TestCheckResourceAttrSet(resourceName, "subnet_id"),
1987+
resource.TestCheckResourceAttr(resourceName, "is_mtls_connection_required", "false"),
1988+
resource.TestCheckResourceAttr(resourceName, "connection_strings.0.profiles.#", "6"),
1989+
1990+
func(s *terraform.State) (err error) {
1991+
resId, err = acctest.FromInstanceState(s, resourceName, "id")
1992+
return err
1993+
},
1994+
),
1995+
},
1996+
1997+
//2. modify acl's of pe database
1998+
{
1999+
Config: config + compartmentIdVariableStr + AutonomousDatabasePrivateEndpointResourceDependencies +
2000+
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", acctest.Optional, acctest.Update,
2001+
acctest.RepresentationCopyWithNewProperties(autonomousDatabasePrivateEndpointRepresentation, map[string]interface{}{
2002+
"whitelisted_ips": acctest.Representation{RepType: acctest.Optional, Update: []string{"1.1.1.29"}},
2003+
})),
2004+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
2005+
resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"),
2006+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
2007+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
2008+
resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"),
2009+
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
2010+
resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"),
2011+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
2012+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
2013+
resource.TestCheckResourceAttrSet(resourceName, "id"),
2014+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
2015+
resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"),
2016+
resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"),
2017+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
2018+
resource.TestCheckResourceAttr(resourceName, "nsg_ids.#", "1"),
2019+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_ip", "10.0.0.97"),
2020+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_label", "xlx4fc9y"),
2021+
resource.TestCheckResourceAttr(resourceName, "whitelisted_ips", "1.1.1.1/29"),
2022+
resource.TestCheckResourceAttrSet(resourceName, "state"),
2023+
resource.TestCheckResourceAttr(resourceName, "is_mtls_connection_required", "true"),
2024+
resource.TestCheckResourceAttr(resourceName, "connection_strings.0.profiles.#", "3"),
2025+
2026+
func(s *terraform.State) (err error) {
2027+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
2028+
if resId != resId2 {
2029+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
2030+
}
2031+
return err
2032+
},
2033+
),
2034+
},
2035+
2036+
//3. change network access to public
2037+
{
2038+
Config: config + compartmentIdVariableStr + AutonomousDatabasePrivateEndpointResourceDependencies +
2039+
acctest.GenerateResourceFromRepresentationMap("oci_database_autonomous_database", "test_autonomous_database", acctest.Optional, acctest.Update,
2040+
acctest.RepresentationCopyWithNewProperties(acctest.RepresentationCopyWithRemovedProperties(autonomousDatabasePEWithPublicAccessRepresentation, []string{"nsg_ids", "private_endpoint_label", "subnet_id"}), map[string]interface{}{
2041+
"nsg_ids": acctest.Representation{RepType: acctest.Optional, Create: []string{`${oci_core_network_security_group.test_network_security_group.id}`}, Update: []string{}},
2042+
"private_endpoint_label": acctest.Representation{RepType: acctest.Optional, Create: `null`},
2043+
"private_endpoint_ip": acctest.Representation{RepType: acctest.Optional, Create: `null`},
2044+
"subnet_id": acctest.Representation{RepType: acctest.Optional, Create: `null`},
2045+
"db_version": acctest.Representation{RepType: acctest.Optional, Create: `19c`, Update: `19c`},
2046+
})),
2047+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
2048+
resource.TestCheckResourceAttr(resourceName, "admin_password", "BEstrO0ng_#12"),
2049+
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
2050+
resource.TestCheckResourceAttr(resourceName, "cpu_core_count", "1"),
2051+
resource.TestCheckResourceAttr(resourceName, "data_storage_size_in_tbs", "1"),
2052+
resource.TestCheckResourceAttr(resourceName, "db_name", adbName),
2053+
resource.TestCheckResourceAttr(resourceName, "db_workload", "OLTP"),
2054+
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
2055+
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
2056+
resource.TestCheckResourceAttrSet(resourceName, "id"),
2057+
resource.TestCheckResourceAttr(resourceName, "is_auto_scaling_enabled", "false"),
2058+
resource.TestCheckResourceAttr(resourceName, "is_dedicated", "false"),
2059+
resource.TestCheckResourceAttr(resourceName, "is_preview_version_with_service_terms_accepted", "false"),
2060+
resource.TestCheckResourceAttr(resourceName, "license_model", "LICENSE_INCLUDED"),
2061+
resource.TestCheckResourceAttr(resourceName, "nsg_ids.#", "0"),
2062+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_ip", "null"),
2063+
resource.TestCheckResourceAttr(resourceName, "private_endpoint_label", "null"),
2064+
resource.TestCheckResourceAttrSet(resourceName, "state"),
2065+
resource.TestCheckResourceAttr(resourceName, "is_mtls_connection_required", "true"),
2066+
resource.TestCheckResourceAttr(resourceName, "connection_strings.0.profiles.#", "3"),
2067+
2068+
func(s *terraform.State) (err error) {
2069+
resId2, err = acctest.FromInstanceState(s, resourceName, "id")
2070+
if resId != resId2 {
2071+
return fmt.Errorf("Resource recreated when it was supposed to be updated.")
2072+
}
2073+
return err
2074+
},
2075+
),
2076+
},
2077+
})
2078+
}
2079+
19372080
// issue-routing-tag: database/dbaas-adb
19382081
func TestResourceDatabaseAutonomousDatabaseResource_dbVersion(t *testing.T) {
19392082
httpreplay.SetScenario("TestResourceDatabaseAutonomousDatabaseResource_dbVersion")

internal/service/database/database_autonomous_database_data_source.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,16 @@ func (s *DatabaseAutonomousDatabaseDataSourceCrud) SetData() error {
357357

358358
s.D.Set("provisionable_cpus", s.Res.ProvisionableCpus)
359359

360+
if s.Res.PublicConnectionUrls != nil {
361+
s.D.Set("public_connection_urls", []interface{}{AutonomousDatabaseConnectionUrlsToMap(s.Res.PublicConnectionUrls)})
362+
} else {
363+
s.D.Set("public_connection_urls", nil)
364+
}
365+
366+
if s.Res.PublicEndpoint != nil {
367+
s.D.Set("public_endpoint", *s.Res.PublicEndpoint)
368+
}
369+
360370
s.D.Set("refreshable_mode", s.Res.RefreshableMode)
361371

362372
s.D.Set("refreshable_status", s.Res.RefreshableStatus)

internal/service/database/database_autonomous_database_resource.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,55 @@ func DatabaseAutonomousDatabaseResource() *schema.Resource {
953953
Type: schema.TypeFloat,
954954
},
955955
},
956+
"public_connection_urls": {
957+
Type: schema.TypeList,
958+
Computed: true,
959+
Elem: &schema.Resource{
960+
Schema: map[string]*schema.Schema{
961+
// Required
962+
963+
// Optional
964+
965+
// Computed
966+
"apex_url": {
967+
Type: schema.TypeString,
968+
Computed: true,
969+
},
970+
"database_transforms_url": {
971+
Type: schema.TypeString,
972+
Computed: true,
973+
},
974+
"graph_studio_url": {
975+
Type: schema.TypeString,
976+
Computed: true,
977+
},
978+
"machine_learning_notebook_url": {
979+
Type: schema.TypeString,
980+
Computed: true,
981+
},
982+
"machine_learning_user_management_url": {
983+
Type: schema.TypeString,
984+
Computed: true,
985+
},
986+
"mongo_db_url": {
987+
Type: schema.TypeString,
988+
Computed: true,
989+
},
990+
"ords_url": {
991+
Type: schema.TypeString,
992+
Computed: true,
993+
},
994+
"sql_dev_web_url": {
995+
Type: schema.TypeString,
996+
Computed: true,
997+
},
998+
},
999+
},
1000+
},
1001+
"public_endpoint": {
1002+
Type: schema.TypeString,
1003+
Computed: true,
1004+
},
9561005
"refreshable_status": {
9571006
Type: schema.TypeString,
9581007
Computed: true,
@@ -2204,6 +2253,16 @@ func (s *DatabaseAutonomousDatabaseResourceCrud) SetData() error {
22042253

22052254
s.D.Set("provisionable_cpus", s.Res.ProvisionableCpus)
22062255

2256+
if s.Res.PublicConnectionUrls != nil {
2257+
s.D.Set("public_connection_urls", []interface{}{AutonomousDatabaseConnectionUrlsToMap(s.Res.PublicConnectionUrls)})
2258+
} else {
2259+
s.D.Set("public_connection_urls", nil)
2260+
}
2261+
2262+
if s.Res.PublicEndpoint != nil {
2263+
s.D.Set("public_endpoint", *s.Res.PublicEndpoint)
2264+
}
2265+
22072266
if s.Res.RefreshableMode != "" {
22082267
s.D.Set("refreshable_mode", s.Res.RefreshableMode)
22092268
}

internal/service/database/database_autonomous_databases_clones_data_source.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,55 @@ func DatabaseAutonomousDatabasesClonesDataSource() *schema.Resource {
638638
Type: schema.TypeFloat,
639639
},
640640
},
641+
"public_connection_urls": {
642+
Type: schema.TypeList,
643+
Computed: true,
644+
Elem: &schema.Resource{
645+
Schema: map[string]*schema.Schema{
646+
// Required
647+
648+
// Optional
649+
650+
// Computed
651+
"apex_url": {
652+
Type: schema.TypeString,
653+
Computed: true,
654+
},
655+
"database_transforms_url": {
656+
Type: schema.TypeString,
657+
Computed: true,
658+
},
659+
"graph_studio_url": {
660+
Type: schema.TypeString,
661+
Computed: true,
662+
},
663+
"machine_learning_notebook_url": {
664+
Type: schema.TypeString,
665+
Computed: true,
666+
},
667+
"machine_learning_user_management_url": {
668+
Type: schema.TypeString,
669+
Computed: true,
670+
},
671+
"mongo_db_url": {
672+
Type: schema.TypeString,
673+
Computed: true,
674+
},
675+
"ords_url": {
676+
Type: schema.TypeString,
677+
Computed: true,
678+
},
679+
"sql_dev_web_url": {
680+
Type: schema.TypeString,
681+
Computed: true,
682+
},
683+
},
684+
},
685+
},
686+
"public_endpoint": {
687+
Type: schema.TypeString,
688+
Computed: true,
689+
},
641690
"refreshable_mode": {
642691
Type: schema.TypeString,
643692
Computed: true,
@@ -1262,6 +1311,16 @@ func (s *DatabaseAutonomousDatabasesClonesDataSourceCrud) SetData() error {
12621311

12631312
autonomousDatabasesClone["provisionable_cpus"] = r.ProvisionableCpus
12641313

1314+
if r.PublicConnectionUrls != nil {
1315+
autonomousDatabasesClone["public_connection_urls"] = []interface{}{AutonomousDatabaseConnectionUrlsToMap(r.PublicConnectionUrls)}
1316+
} else {
1317+
autonomousDatabasesClone["public_connection_urls"] = nil
1318+
}
1319+
1320+
if r.PublicEndpoint != nil {
1321+
autonomousDatabasesClone["public_endpoint"] = *r.PublicEndpoint
1322+
}
1323+
12651324
autonomousDatabasesClone["refreshable_mode"] = r.RefreshableMode
12661325

12671326
autonomousDatabasesClone["refreshable_status"] = r.RefreshableStatus

internal/service/database/database_autonomous_databases_data_source.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,16 @@ func (s *DatabaseAutonomousDatabasesDataSourceCrud) SetData() error {
472472

473473
autonomousDatabase["provisionable_cpus"] = r.ProvisionableCpus
474474

475+
if r.PublicConnectionUrls != nil {
476+
autonomousDatabase["public_connection_urls"] = []interface{}{AutonomousDatabaseConnectionUrlsToMap(r.PublicConnectionUrls)}
477+
} else {
478+
autonomousDatabase["public_connection_urls"] = nil
479+
}
480+
481+
if r.PublicEndpoint != nil {
482+
autonomousDatabase["public_endpoint"] = *r.PublicEndpoint
483+
}
484+
475485
autonomousDatabase["refreshable_mode"] = r.RefreshableMode
476486

477487
autonomousDatabase["refreshable_status"] = r.RefreshableStatus

website/docs/d/database_autonomous_database.html.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ The following attributes are exported:
202202
* `private_endpoint_ip` - The private endpoint Ip address for the resource.
203203
* `private_endpoint_label` - The private endpoint label for the resource.
204204
* `provisionable_cpus` - An array of CPU values that an Autonomous Database can be scaled to.
205+
* `public_connection_urls` - The Public URLs of Private Endpoint database for accessing Oracle Application Express (APEX) and SQL Developer Web with a browser from a Compute instance within your VCN or that has a direct connection to your VCN.
206+
* `apex_url` - Oracle Application Express (APEX) URL.
207+
* `database_transforms_url` - The URL of the Database Transforms for the Autonomous Database.
208+
* `graph_studio_url` - The URL of the Graph Studio for the Autonomous Database.
209+
* `machine_learning_notebook_url` - The URL of the Oracle Machine Learning (OML) Notebook for the Autonomous Database.
210+
* `machine_learning_user_management_url` - Oracle Machine Learning user management URL.
211+
* `mongo_db_url` - The URL of the MongoDB API for the Autonomous Database.
212+
* `ords_url` - The Oracle REST Data Services (ORDS) URL of the Web Access for the Autonomous Database.
213+
* `sql_dev_web_url` - Oracle SQL Developer Web URL.
214+
* `public_endpoint` - The public endpoint for the private endpoint enabled resource.
205215
* `refreshable_mode` - The refresh mode of the clone. AUTOMATIC indicates that the clone is automatically being refreshed with data from the source Autonomous Database.
206216
* `refreshable_status` - The refresh status of the clone. REFRESHING indicates that the clone is currently being refreshed with data from the source Autonomous Database.
207217
* `remote_disaster_recovery_configuration` - Configurations of a Disaster Recovery.

website/docs/d/database_autonomous_databases.html.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ The following attributes are exported:
231231
* `private_endpoint_ip` - The private endpoint Ip address for the resource.
232232
* `private_endpoint_label` - The private endpoint label for the resource.
233233
* `provisionable_cpus` - An array of CPU values that an Autonomous Database can be scaled to.
234+
* `public_connection_urls` - The Public URLs of Private Endpoint database for accessing Oracle Application Express (APEX) and SQL Developer Web with a browser from a Compute instance within your VCN or that has a direct connection to your VCN.
235+
* `apex_url` - Oracle Application Express (APEX) URL.
236+
* `database_transforms_url` - The URL of the Database Transforms for the Autonomous Database.
237+
* `graph_studio_url` - The URL of the Graph Studio for the Autonomous Database.
238+
* `machine_learning_notebook_url` - The URL of the Oracle Machine Learning (OML) Notebook for the Autonomous Database.
239+
* `machine_learning_user_management_url` - Oracle Machine Learning user management URL.
240+
* `mongo_db_url` - The URL of the MongoDB API for the Autonomous Database.
241+
* `ords_url` - The Oracle REST Data Services (ORDS) URL of the Web Access for the Autonomous Database.
242+
* `sql_dev_web_url` - Oracle SQL Developer Web URL.
243+
* `public_endpoint` - The public endpoint for the private endpoint enabled resource.
234244
* `refreshable_mode` - The refresh mode of the clone. AUTOMATIC indicates that the clone is automatically being refreshed with data from the source Autonomous Database.
235245
* `refreshable_status` - The refresh status of the clone. REFRESHING indicates that the clone is currently being refreshed with data from the source Autonomous Database.
236246
* `remote_disaster_recovery_configuration` - Configurations of a Disaster Recovery.

0 commit comments

Comments
 (0)