Skip to content

Commit b2ab7c9

Browse files
MWahane29sagarp337
authored andcommitted
Added - Support for IPV6 for BaseDB
1 parent 46cfbf4 commit b2ab7c9

File tree

11 files changed

+451
-10
lines changed

11 files changed

+451
-10
lines changed
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
3+
variable "tenancy_ocid" {
4+
}
5+
6+
variable "user_ocid" {
7+
}
8+
9+
variable "fingerprint" {
10+
}
11+
12+
variable "private_key_path" {
13+
}
14+
15+
variable "compartment_ocid" {
16+
}
17+
18+
variable "region" {
19+
}
20+
21+
variable "ssh_public_key" {
22+
}
23+
24+
provider "oci" {
25+
tenancy_ocid = var.tenancy_ocid
26+
user_ocid = var.user_ocid
27+
fingerprint = var.fingerprint
28+
private_key_path = var.private_key_path
29+
region = var.region
30+
}
31+
32+
data "oci_identity_availability_domain" "ad" {
33+
compartment_id = var.tenancy_ocid
34+
ad_number = 1
35+
}
36+
37+
data "oci_core_services" "test_services" {
38+
filter {
39+
name = "name"
40+
values = [".*Oracle.*Services.*Network"]
41+
regex = true
42+
}
43+
}
44+
45+
data "oci_identity_availability_domains" "test_availability_domains" {
46+
compartment_id = var.tenancy_ocid
47+
}
48+
49+
resource "oci_core_vcn" "test_vcn" {
50+
cidr_block = "10.0.0.0/16"
51+
compartment_id = var.compartment_ocid
52+
display_name = "TFExampleVCN"
53+
dns_label = "tfexamplevcn"
54+
ipv6private_cidr_blocks = ["fc00:1000::/52"]
55+
is_ipv6enabled = true
56+
}
57+
58+
resource "oci_core_service_gateway" "test_service_gateway" {
59+
compartment_id = var.compartment_ocid
60+
display_name = "test_service_gateway"
61+
vcn_id = oci_core_vcn.test_vcn.id
62+
63+
services {
64+
service_id = data.oci_core_services.test_services.services.0.id
65+
}
66+
67+
}
68+
69+
resource "oci_core_default_route_table" "test_vcn__default_route_table" {
70+
manage_default_resource_id = oci_core_vcn.test_vcn.default_route_table_id
71+
72+
route_rules {
73+
network_entity_id = oci_core_service_gateway.test_service_gateway.id
74+
75+
description = "Internal traffic for OCI Services"
76+
destination = data.oci_core_services.test_services.services[0].cidr_block
77+
destination_type = "SERVICE_CIDR_BLOCK"
78+
}
79+
}
80+
81+
resource "oci_core_route_table" "test_route_table" {
82+
compartment_id = var.compartment_ocid
83+
display_name = "test_subnet_rt"
84+
vcn_id = oci_core_vcn.test_vcn.id
85+
86+
route_rules {
87+
network_entity_id = oci_core_service_gateway.test_service_gateway.id
88+
89+
description = "Internal traffic for OCI Services"
90+
destination = data.oci_core_services.test_services.services[0].cidr_block
91+
destination_type = "SERVICE_CIDR_BLOCK"
92+
}
93+
}
94+
95+
resource "oci_core_security_list" "test_security_list" {
96+
compartment_id = var.compartment_ocid
97+
vcn_id = oci_core_vcn.test_vcn.id
98+
display_name = "test_security_list"
99+
100+
// allow outbound tcp traffic on all ports
101+
egress_security_rules {
102+
destination = "0.0.0.0/0"
103+
protocol = "6"
104+
}
105+
106+
ingress_security_rules {
107+
protocol = "6"
108+
source = "0.0.0.0/0"
109+
}
110+
}
111+
112+
resource "oci_core_subnet" "test_subnet" {
113+
cidr_block = "10.0.2.0/24"
114+
compartment_id = var.compartment_ocid
115+
vcn_id = oci_core_vcn.test_vcn.id
116+
display_name = "test_subnet"
117+
security_list_ids = [oci_core_security_list.test_security_list.id]
118+
route_table_id = oci_core_route_table.test_route_table.id
119+
dhcp_options_id = oci_core_vcn.test_vcn.default_dhcp_options_id
120+
dns_label = "tftestsubnet"
121+
prohibit_public_ip_on_vnic = "true"
122+
ipv6cidr_blocks = ["${substr(oci_core_vcn.test_vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.test_vcn.ipv6cidr_blocks[0]) - 2)}${64}"]
123+
}
124+
125+
126+
resource "oci_database_db_system" "test_db_system" {
127+
availability_domain = data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name
128+
compartment_id = var.compartment_ocid
129+
subnet_id = oci_core_subnet.test_subnet.id
130+
database_edition = "ENTERPRISE_EDITION"
131+
disk_redundancy = "NORMAL"
132+
shape = "VM.Standard2.1"
133+
ssh_public_keys = [var.ssh_public_key]
134+
domain = oci_core_subnet.test_subnet.subnet_domain_name
135+
hostname = "myOracleDB"
136+
data_storage_size_in_gb = "256"
137+
license_model = "LICENSE_INCLUDED"
138+
node_count = "1"
139+
display_name = "TFExampleDbSystem"
140+
141+
db_home {
142+
db_version = "12.1.0.2"
143+
display_name = "TFExampleDbHome"
144+
145+
database {
146+
admin_password = "BEstrO0ng_#11"
147+
db_name = "db1"
148+
}
149+
}
150+
}
151+
152+
data "oci_database_db_homes" "t" {
153+
compartment_id = var.compartment_ocid
154+
db_system_id = oci_database_db_system.test_db_system.id
155+
156+
filter {
157+
name = "display_name"
158+
values = ["TFExampleDbHome"]
159+
}
160+
}
161+
162+
data "oci_database_databases" "db" {
163+
compartment_id = var.compartment_ocid
164+
db_home_id = data.oci_database_db_homes.t.db_homes[0].db_home_id
165+
}
166+
167+
resource "oci_database_data_guard_association" "test_data_guard_association" {
168+
#Required
169+
creation_type = "NewDbSystem"
170+
database_admin_password = "BEstrO0ng_#11"
171+
database_id = data.oci_database_databases.db.databases[0].id
172+
protection_mode = "MAXIMUM_PERFORMANCE"
173+
transport_type = "ASYNC"
174+
delete_standby_db_home_on_delete = "true"
175+
176+
#required for NewDbSystem creation_type
177+
display_name = "TFExampleDataGuardAssociationVM"
178+
shape = "VM.Standard2.1"
179+
subnet_id = oci_core_subnet.test_subnet.id
180+
availability_domain = data.oci_identity_availability_domains.test_availability_domains.availability_domains.0.name
181+
nsg_ids = [oci_core_network_security_group.test_network_security_group.id]
182+
hostname = "ocidb"
183+
db_system_defined_tags = map("example-tag-namespace-all.example-tag", "dbSystemDefinedTags1")
184+
db_system_freeform_tags = {"dbSystemFreeformTagsK" = "dbSystemFreeformTagsV"}
185+
database_defined_tags = map("example-tag-namespace-all.example-tag", "databaseDefinedTags1")
186+
database_freeform_tags = {"databaseFreeformTagsK" = "databaseFreeformTagsV"}
187+
fault_domains = ["FAULT-DOMAIN-3"]
188+
license_model = "LICENSE_INCLUDED"
189+
node_count = "1"
190+
private_ip = "10.0.2.223"
191+
private_ip_v6 = "${substr(oci_core_vcn.test_vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.test_vcn.ipv6cidr_blocks[0]) - 4)}5901:cede:a617:8bba"
192+
time_zone = "US/Pacific"
193+
is_active_data_guard_enabled = "false"
194+
}
195+
196+
resource "oci_core_network_security_group" "test_network_security_group" {
197+
compartment_id = var.compartment_ocid
198+
vcn_id = oci_core_vcn.test_vcn.id
199+
display_name = "tf-example-nsg"
200+
}
201+

examples/database/db_systems/db_vm/main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ resource "oci_core_vcn" "vcn" {
171171
compartment_id = var.compartment_ocid
172172
display_name = "TFExampleVCNDBSystem"
173173
dns_label = "tfexvcndbsys"
174+
is_ipv6enabled = true
175+
ipv6private_cidr_blocks = ["fc00:1000::/52"]
174176
}
175177

176178
resource "oci_core_subnet" "subnet" {
@@ -183,6 +185,7 @@ resource "oci_core_subnet" "subnet" {
183185
vcn_id = oci_core_vcn.vcn.id
184186
route_table_id = oci_core_route_table.route_table.id
185187
dhcp_options_id = oci_core_vcn.vcn.default_dhcp_options_id
188+
ipv6cidr_blocks = ["${substr(oci_core_vcn.vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.vcn.ipv6cidr_blocks[0]) - 2)}${64}"]
186189
}
187190

188191
resource "oci_core_subnet" "subnet_backup" {
@@ -305,7 +308,7 @@ resource "oci_database_db_system" "test_db_system" {
305308
}
306309

307310
db_system_options {
308-
storage_management = "LVM"
311+
storage_management = "ASM"
309312
}
310313

311314
disk_redundancy = var.db_disk_redundancy
@@ -318,7 +321,7 @@ resource "oci_database_db_system" "test_db_system" {
318321
license_model = var.license_model
319322
node_count = data.oci_database_db_system_shapes.test_db_system_shapes.db_system_shapes[0]["minimum_node_count"]
320323
nsg_ids = [oci_core_network_security_group.test_network_security_group_backup.id, oci_core_network_security_group.test_network_security_group.id]
321-
324+
private_ip_v6 = "${substr(oci_core_vcn.vcn.ipv6cidr_blocks[0], 0, length(oci_core_vcn.vcn.ipv6cidr_blocks[0]) - 4)}5901:cede:a617:8bba"
322325
#To use defined_tags, set the values below to an existing tag namespace, refer to the identity example on how to create tag namespaces
323326
#defined_tags = {"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "value"}
324327

internal/integrationtest/core_vcn_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var (
2828
CoreVcnRequiredOnlyResource = CoreVcnRequiredOnlyResourceDependencies +
2929
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Required, acctest.Create, CoreVcnRepresentation)
3030

31-
CoreVcnResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, CoreVcnRepresentation)
31+
CoreVcnResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, CoreVcnRepresentation)
32+
CoreIpv6VcnResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, CoreIpv6VcnRepresentation)
3233

3334
CoreCoreVcnSingularDataSourceRepresentation = map[string]interface{}{
3435
"vcn_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_vcn.test_vcn.id}`},
@@ -55,6 +56,18 @@ var (
5556
"security_attributes": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"vcncp-canary-test-security-attribute-namespace-56.vcncp-canary-test-security-attribute-57.value": "somevalue", "vcncp-canary-test-security-attribute-namespace-56.vcncp-canary-test-security-attribute-57.mode": "enforce"}, Update: map[string]string{"vcncp-canary-test-security-attribute-namespace-56.vcncp-canary-test-security-attribute-57.value": "updatedValue", "vcncp-canary-test-security-attribute-namespace-56.vcncp-canary-test-security-attribute-57.mode": "enforce"}},
5657
}
5758

59+
CoreIpv6VcnRepresentation = map[string]interface{}{
60+
"cidr_block": acctest.Representation{RepType: acctest.Required, Create: `10.0.0.0/16`},
61+
"is_ipv6enabled": acctest.Representation{RepType: acctest.Required, Create: `true`},
62+
"ipv6private_cidr_blocks": acctest.Representation{RepType: acctest.Required, Create: []string{`fc00:1000::/56`}},
63+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
64+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
65+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`, Update: `displayName2`},
66+
"dns_label": acctest.Representation{RepType: acctest.Optional, Create: `dnslabel`},
67+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"Department": "Finance"}, Update: map[string]string{"Department": "Accounting"}},
68+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsChangesRep},
69+
}
70+
5871
CoreVcnRequiredOnlyResourceDependencies = ``
5972
VcnResourceDependencies = DefinedTagsDependencies
6073
)

internal/integrationtest/database_data_guard_association_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var (
7575

7676
DBSystemRepresentation = map[string]interface{}{
7777
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
78-
"display_name": acctest.Representation{RepType: acctest.Required, Create: `tfDbSystemDataguardAssociationPrimary`},
78+
"display_name": acctest.Representation{RepType: acctest.Required, Create: `TFTestDbSystemVM`},
7979
"subnet_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_subnet.test_subnet.id}`},
8080
"database_edition": acctest.Representation{RepType: acctest.Required, Create: `ENTERPRISE_EDITION`},
8181
"disk_redundancy": acctest.Representation{RepType: acctest.Required, Create: `NORMAL`},
@@ -202,6 +202,7 @@ var (
202202
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
203203
"vcn_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_vcn.test_vcn.id}`},
204204
"display_name": acctest.Representation{RepType: acctest.Required, Create: `test_subnet`},
205+
"ipv6cidr_blocks": acctest.Representation{RepType: acctest.Required, Create: []string{`2603:c022:0003:897e:0000:0000:0000:0000/64`}},
205206
"security_list_ids": acctest.Representation{RepType: acctest.Required, Create: []string{`${oci_core_security_list.test_security_list.id}`}},
206207
"route_table_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_route_table.test_route_table.id}`},
207208
"dhcp_options_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_core_vcn.test_vcn.default_dhcp_options_id}`},
@@ -216,8 +217,7 @@ var (
216217
"dns_label": acctest.Representation{RepType: acctest.Optional, Create: `dnslabel`},
217218
}
218219

219-
//ExternalDependenciesConfig = AvailabilityDomainConfig + DefinedTagsDependencies + CoreVcnResourceConfig
220-
ExternalDependenciesConfig = AvailabilityDomainConfig + DefinedTagsDependencies +
220+
ExternalDependenciesConfig = AvailabilityDomainConfig + DefinedTagsDependencies + CoreVcnResourceConfig +
221221
acctest.GenerateResourceFromRepresentationMap("oci_core_vcn", "test_vcn", acctest.Optional, acctest.Create, DataguardAssociationCoreVcnRepresentation)
222222

223223
DataSourceDependenciesConfig = ExternalDependenciesConfig +
@@ -275,6 +275,7 @@ func TestDatabaseDataGuardAssociationResource_basic(t *testing.T) {
275275
resource.TestCheckResourceAttr(resourceName, "license_model", "BRING_YOUR_OWN_LICENSE"),
276276
resource.TestCheckResourceAttr(resourceName, "node_count", "1"),
277277
resource.TestCheckResourceAttr(resourceName, "private_ip", "10.0.2.223"),
278+
resource.TestCheckResourceAttr(resourceName, "private_ip_v6", "2603:c022:3:897e:d53:b488:2394:d88c"),
278279
resource.TestCheckResourceAttr(resourceName, "time_zone", "US/Pacific"),
279280
resource.TestCheckResourceAttr(resourceName, "data_collection_options.#", "1"),
280281
resource.TestCheckResourceAttr(resourceName, "data_collection_options.0.is_diagnostics_events_enabled", "false"),
@@ -311,6 +312,7 @@ func TestDatabaseDataGuardAssociationResource_basic(t *testing.T) {
311312
resource.TestCheckResourceAttr(resourceName, "license_model", "BRING_YOUR_OWN_LICENSE"),
312313
resource.TestCheckResourceAttr(resourceName, "node_count", "1"),
313314
resource.TestCheckResourceAttr(resourceName, "private_ip", "10.0.2.223"),
315+
resource.TestCheckResourceAttr(resourceName, "private_ip_v6", "2603:c022:3:897e:d53:b488:2394:d88c"),
314316
resource.TestCheckResourceAttr(resourceName, "time_zone", "US/Pacific"),
315317
resource.TestCheckResourceAttr(resourceName, "data_collection_options.#", "1"),
316318
resource.TestCheckResourceAttr(resourceName, "data_collection_options.0.is_diagnostics_events_enabled", "false"),

0 commit comments

Comments
 (0)