Skip to content

Commit ef88ded

Browse files
Add policy for updating ATP NSG & Rename variable ocidb_existing_vcn_add_seclist (#113)
* Add policy for updating ATP NSG * Add policy for updating ATP NSG * Add policy for updating ATP NSG
1 parent ed69620 commit ef88ded

File tree

8 files changed

+36
-23
lines changed

8 files changed

+36
-23
lines changed

terraform/db_variables.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ variable "atp_db_password_id" {
141141

142142
variable "atp_db_network_compartment_id" {
143143
type = string
144-
description = "The OCID of the compartment in which the ATP database VCN is found"
144+
description = "The OCID of the compartment in which the ATP database private endpoint VCN is found"
145145
default = ""
146146
}
147147

@@ -158,10 +158,9 @@ variable "atp_db_uses_private_endpoint" {
158158
default = false
159159
}
160160

161-
#This variable is used for both oci db and ATP with private subnet
162-
#NOTE: this has not been renamed to support future cloning support
163-
variable "ocidb_existing_vcn_add_seclist" {
161+
#This variable is used for both OCI database and ATP database with private endpoint
162+
variable "db_existing_vcn_add_secrule" {
164163
type = bool
165-
description = "Set to true to add a security list to the database subnet (for OCI DB) when using existing VCN or network security group (for ATP with private endpoint) that allows connections from the WebLogic Server subnet"
164+
description = "Set to true to add a security list to the database subnet (for OCI DB) or a security rule to the network security group (for ATP with private endpoint) that allows connections from the WebLogic Server subnet"
166165
default = true
167166
}

terraform/locals.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ locals {
2828
db_password_id = local.is_atp_db ? var.atp_db_password_id : var.oci_db_password_id
2929
is_atp_db = trimspace(var.atp_db_id) != ""
3030
is_atp_with_private_endpoints = local.is_atp_db && (length(data.oci_database_autonomous_database.atp_db) != 0 ? data.oci_database_autonomous_database.atp_db[0].subnet_id != null : false)
31-
atp_db_network_compartment_id = local.is_atp_db && var.atp_db_network_compartment_id == "" ? var.atp_db_compartment_id : var.atp_db_network_compartment_id
31+
atp_db_network_compartment_id = local.is_atp_with_private_endpoints && var.atp_db_network_compartment_id == "" ? var.atp_db_compartment_id : var.atp_db_network_compartment_id
3232

3333
atp_db = {
34-
is_atp = local.is_atp_db
35-
compartment_id = var.atp_db_compartment_id
36-
password_id = var.atp_db_password_id
34+
is_atp = local.is_atp_db
35+
password_id = var.atp_db_password_id
36+
compartment_id = var.atp_db_compartment_id
37+
is_atp_with_private_endpoints = local.is_atp_with_private_endpoints
38+
network_compartment_id = local.atp_db_network_compartment_id
39+
existing_vcn_id = var.atp_db_existing_vcn_id
40+
existing_vcn_add_seclist = local.is_atp_with_private_endpoints ? var.db_existing_vcn_add_secrule : false
3741
}
3842
oci_db = {
3943
is_oci_db = local.is_oci_db
@@ -42,14 +46,14 @@ locals {
4246
network_compartment_id = local.oci_db_network_compartment_id
4347
existing_vcn_id = var.oci_db_existing_vcn_id
4448
oci_db_connection_string = var.oci_db_connection_string
45-
existing_vcn_add_seclist = local.is_oci_db ? var.ocidb_existing_vcn_add_seclist : false
49+
existing_vcn_add_seclist = local.is_oci_db ? var.db_existing_vcn_add_secrule : false
4650
}
4751

4852
is_oci_db = trimspace(var.oci_db_dbsystem_id) == "" ? false : true
4953
oci_db_compartment_id = var.oci_db_compartment_id == "" ? local.network_compartment_id : var.oci_db_compartment_id
5054
oci_db_network_compartment_id = local.is_oci_db && var.oci_db_network_compartment_id == "" ? var.oci_db_compartment_id : var.oci_db_network_compartment_id
5155

52-
db_network_compartment_id = local.is_atp_db ? local.atp_db_network_compartment_id : local.oci_db_network_compartment_id
56+
db_network_compartment_id = local.is_atp_with_private_endpoints ? local.atp_db_network_compartment_id : local.oci_db_network_compartment_id
5357

5458
# Locals used by outputs
5559
bastion_public_ip = element(coalescelist(module.bastion[*].public_ip, data.oci_core_instance.existing_bastion_instance.*.public_ip, [""]), 0)

terraform/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ module "compute" {
580580
mount_path = var.mount_path
581581
export_path = var.existing_export_path_id != "" ? element(concat(data.oci_file_storage_exports.export[*].exports[0].path, [""]), 0) : element(concat(module.fss[*].export_path, [""]), 0)
582582

583-
db_existing_vcn_add_seclist = var.ocidb_existing_vcn_add_seclist
583+
db_existing_vcn_add_seclist = var.db_existing_vcn_add_secrule
584584
jrf_parameters = {
585585
db_user = local.db_user
586586
db_password_id = local.db_password_id

terraform/modules/compute/wls_compute/db_variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ variable "jrf_parameters" {
6868
//Add security list to existing db vcn
6969
variable "db_existing_vcn_add_seclist" {
7070
type = bool
71-
description = "Set to true to add a security list to the database subnet (for OCI DB) when using existing VCN or network security group (for ATP with private endpoint) that allows connections from the WebLogic Server subnet"
71+
description = "Set to true to add a security list to the database subnet (for OCI DB) or a security rule to the network security group (for ATP with private endpoint) that allows connections from the WebLogic Server subnet"
7272
}

terraform/modules/policies/locals.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ locals {
2222
atp_policy_statement1 = (var.atp_db.is_atp && var.atp_db.password_id != "") ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to read secret-bundles in tenancy where target.secret.id = '${var.atp_db.password_id}'" : ""
2323
# This policy with "use autonomous-transaction-processing-family" verb is needed to download ATP db wallet
2424
atp_policy_statement2 = (var.atp_db.is_atp && var.atp_db.compartment_id != "") ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to use autonomous-transaction-processing-family in compartment id ${var.atp_db.compartment_id}" : ""
25+
# This policy with "manage network-security-groups" verb is needed to add security rule in the ATP db (with private endpoint) NSG in the ATP db VCN
26+
atp_policy_statement3 = (var.atp_db.is_atp_with_private_endpoints && var.atp_db.existing_vcn_add_seclist && var.atp_db.network_compartment_id != "") ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to manage network-security-groups in compartment id ${var.atp_db.network_compartment_id} where request.operation = 'AddNetworkSecurityGroupSecurityRules'" : ""
2527
oci_db_policy_statement1 = var.oci_db.password_id != "" ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to read secret-bundles in tenancy where target.secret.id = '${var.oci_db.password_id}'" : ""
2628
# This policy with "inspect virtual-network-family" verb is needed to read OCI DB VCN information like CIDR, etc, for VCN validation
2729
oci_db_policy_statement2 = (var.oci_db.network_compartment_id != "" && var.oci_db.existing_vcn_id != local.network_vcn_id) ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to inspect virtual-network-family in compartment id ${var.oci_db.network_compartment_id} where target.vcn.id = '${var.oci_db.existing_vcn_id}'" : ""
@@ -34,7 +36,7 @@ locals {
3436
# This policy with "use load_balancer" verb is needed to create load balancer for new vcn
3537
lb_policy_statement = var.add_load_balancer ? length(oci_identity_dynamic_group.wlsc_instance_principal_group) > 0 ? "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to use load-balancers in compartment id ${var.network_compartment_id}" : "" : ""
3638

37-
service_statements = compact([local.core_policy_statement1, local.core_policy_statement2, local.core_policy_statement3, local.network_policy_statement1, local.secrets_policy_statement1, local.secrets_policy_statement2, local.atp_policy_statement1, local.atp_policy_statement2, local.oci_db_policy_statement1, local.oci_db_policy_statement2, local.logging_policy, local.apm_domain_policy_statement, local.lb_policy_statement])
39+
service_statements = compact([local.core_policy_statement1, local.core_policy_statement2, local.core_policy_statement3, local.network_policy_statement1, local.secrets_policy_statement1, local.secrets_policy_statement2, local.atp_policy_statement1, local.atp_policy_statement2, local.atp_policy_statement3, local.oci_db_policy_statement1, local.oci_db_policy_statement2, local.logging_policy, local.apm_domain_policy_statement, local.lb_policy_statement])
3840

3941
cloning_policy_statement1 = "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to read orm-stacks in compartment id ${var.compartment_id}"
4042
cloning_policy_statement2 = "Allow dynamic-group ${oci_identity_dynamic_group.wlsc_instance_principal_group.name} to inspect compartments in tenancy"

terraform/modules/policies/variables.tf

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,23 @@ variable "wls_admin_password_id" {
9797

9898
variable "atp_db" {
9999
type = object({
100-
is_atp = bool
101-
compartment_id = string
102-
password_id = string
100+
is_atp = bool
101+
password_id = string
102+
compartment_id = string
103+
is_atp_with_private_endpoints = bool
104+
network_compartment_id = string
105+
existing_vcn_id = string
106+
existing_vcn_add_seclist = bool
103107
})
104108
description = <<-EOT
105109
atp_db = {
106110
is_atp: "Indicates if an ATP database is used to store the schemas of a JRF WebLogic domain"
107-
compartment_id: "The OCID of the compartment where the ATP database is located"
108111
password_id: "The OCID of the vault secret with the password of the database"
112+
compartment_id: "The OCID of the compartment where the ATP database is located"
113+
is_atp_with_private_endpoints: "Indicates if the ATP database uses private endpoint for network access"
114+
network_compartment_id: "The OCID of the compartment in which the ATP database private endpoint VCN is found"
115+
existing_vcn_id: "The OCID of the VCN used by the ATP database private endpoint"
116+
existing_vcn_add_seclist: "Set to true to add a security list to the network security group (for ATP with private endpoint) that allows connections from the WebLogic Server subnet"
109117
}
110118
EOT
111119
}
@@ -127,7 +135,7 @@ variable "oci_db" {
127135
compartment_id: "The OCID of the compartment where the OCI database is located"
128136
network_compartment_id: "The OCID of the compartment in which the DB System VCN is found"
129137
existing_vcn_id: "The OCID of the DB system VCN"
130-
existing_vcn_add_seclist: "Set to true to add a security list to the database subnet (for OCI DB) when using existing VCN that allows connections from the WebLogic Server subnet"
138+
existing_vcn_add_seclist: "Set to true to add a security list to the database subnet (for OCI DB) that allows connections from the WebLogic Server subnet"
131139
}
132140
EOT
133141
}

terraform/schema.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ groupings:
6363
- ${oci_db_secret_compartment_id}
6464
- ${oci_db_password_id}
6565
- ${oci_db_port}
66-
- ${ocidb_existing_vcn_add_seclist}
66+
- ${db_existing_vcn_add_secrule}
6767
- ${db_vcn_lpg_id}
6868
#End of JRF fields
6969
- ${deploy_sample_app}
@@ -1636,7 +1636,7 @@ variables:
16361636
description: The compartment in which the DB System Virtual Cloud Network is found.
16371637
default: ${compartment_ocid}
16381638

1639-
ocidb_existing_vcn_add_seclist:
1639+
db_existing_vcn_add_secrule:
16401640
visible:
16411641
and:
16421642
- ${orm_create_mode}
@@ -1650,7 +1650,7 @@ variables:
16501650
type: boolean
16511651
default: true
16521652
title: Create Database Security List
1653-
description: Add a security list to the DB subnet or Network Security Group for ATP Database with private endpoint that allows connections from the WebLogic Server subnet
1653+
description: Add a security list to the DB subnet or a security rule to the Network Security Group for ATP Database with private endpoint that allows connections from the WebLogic Server subnet
16541654

16551655
# OCI DB Configuration
16561656

terraform/schema_14110.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ groupings:
186186
- ${oci_db_compartment_id}
187187
- ${oci_db_network_compartment_id}
188188
- ${oci_db_existing_vcn_id}
189-
- ${ocidb_existing_vcn_add_seclist}
189+
- ${db_existing_vcn_add_secrule}
190190
- ${oci_db_dbsystem_id}
191191
- ${oci_db_dbhome_id}
192192
- ${oci_db_dbhome_major_version}

0 commit comments

Comments
 (0)