Skip to content

Commit d1c22af

Browse files
committed
Use locals in terraform
1 parent 48cc17e commit d1c22af

File tree

6 files changed

+31
-71
lines changed

6 files changed

+31
-71
lines changed

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/function/oci-datasafe-audit-to-logging/func.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def main(ctx):
280280
lock_file_name = "lock.json"
281281
lastAuditEventRecordTime_attr = "lastAuditEventRecordTime"
282282
ds_dbaudit_events = pd.DataFrame()
283+
#Maximun number of audit events collected for each execution. The value 50000 is specific with function timeout equal to 5 mins.
283284
max_auditevents = 50000
284285

285286
try:

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ module "setup-network" {
4747
count = var.create_network ? 1 : 0
4848
compartment_ocid = var.compartment_ocid
4949
VCN-CIDR = var.VCN-CIDR
50-
fnsubnet-CIDR = var.fnsubnet-CIDR
50+
subnet-CIDR = var.subnet-CIDR
5151
}

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/modules/network/main.tf

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,23 @@
99
################################################################################
1010

1111

12+
locals {
13+
resource_nc = "-${var.deployment_name}-${var.region}-${var.purpose}-${random_id.tag.hex}"
14+
vcn_dns_label = "${var.vcndnslabelprefix}${local.resource_nc}"
15+
vcn_displayname = "${var.vcnnameprefix}${local.resource_nc}"
16+
service_gw_displayname = "${var.vcnnameservicegatewayprefix}${local.resource_nc}"
17+
vcnnameroutingtable_displayname = "${var.vcnnameroutingtableprefix}${local.resource_nc}"
18+
dhcpoptions_displayname = "${var.vcnnamedhcpopitonsprefix}${local.resource_nc}"
19+
subnet_displayname = "${var.subnetnameprefix}${local.resource_nc}"
20+
subnet_dns_label = "${var.subnetdnslabelprefix}${local.resource_nc}"
21+
vcn_securitylist_displayname = "${var.vcnnamesecuritylistprefix}${local.resource_nc}"
22+
}
23+
1224
resource "oci_core_virtual_network" "vcn" {
1325
cidr_block = var.VCN-CIDR
14-
dns_label = "${var.vcndnslabelprefix}${random_id.tag.hex}"
26+
dns_label = local.vcn_dns_label
1527
compartment_id = var.compartment_ocid
16-
display_name = "${var.vcnnameprefix}-${random_id.tag.hex}"
28+
display_name = local.vcn_displayname
1729
}
1830

1931
data "oci_core_services" "service_gateway_all_oci_services" {
@@ -31,19 +43,19 @@ resource "oci_core_service_gateway" "service_gw" {
3143
services {
3244
service_id = lookup(data.oci_core_services.service_gateway_all_oci_services.services[0], "id")
3345
}
34-
display_name = "${var.vcnnameservicegatewayprefix}-${random_id.tag.hex}"
46+
display_name = local.service_gw_displayname
3547
}
3648

3749
resource "oci_core_route_table" "rt_fn_subnet" {
3850
compartment_id = var.compartment_ocid
3951
vcn_id = oci_core_virtual_network.vcn.id
40-
display_name = "${var.vcnnameroutingtableprefix}-${random_id.tag.hex}"
52+
display_name = local.vcnnameroutingtable_displayname
4153

4254
route_rules {
4355
destination = lookup(data.oci_core_services.service_gateway_all_oci_services.services[0], "cidr_block")
4456
destination_type = "SERVICE_CIDR_BLOCK"
4557
network_entity_id = oci_core_service_gateway.service_gw.id
46-
description = "${var.vcnroutingtabledescriptionservicegw}-${random_id.tag.hex}"
58+
description = var.vcnroutingtabledescriptionservicegw
4759
}
4860

4961
}
@@ -53,17 +65,17 @@ resource "oci_core_route_table" "rt_fn_subnet" {
5365
resource "oci_core_dhcp_options" "dhcpoptions1" {
5466
compartment_id = var.compartment_ocid
5567
vcn_id = oci_core_virtual_network.vcn.id
56-
display_name = "${var.vcnnamedhcpopitonsprefix}-${random_id.tag.hex}"
68+
display_name = local.dhcpoptions_displayname
5769
options {
5870
type = "DomainNameServer"
5971
server_type = "VcnLocalPlusInternet"
6072
}
6173
}
6274

63-
resource "oci_core_subnet" "function_ds_log_vcn" {
75+
resource "oci_core_subnet" "vcn_subnet" {
6476
cidr_block = var.subnet-CIDR
65-
display_name = "${var.subnetnameprefix}-${random_id.tag.hex}"
66-
dns_label = "${var.subnetdnslabelprefix}${random_id.tag.hex}"
77+
display_name = local.subnet_displayname
78+
dns_label = local.subnet_dns_label
6779
compartment_id = var.compartment_ocid
6880
vcn_id = oci_core_virtual_network.vcn.id
6981
route_table_id = oci_core_route_table.rt_fn_subnet.id
@@ -76,7 +88,7 @@ resource "oci_core_subnet" "function_ds_log_vcn" {
7688
resource "oci_core_security_list" "vcn_security_list"{
7789
compartment_id = var.compartment_ocid
7890
vcn_id = oci_core_virtual_network.vcn.id
79-
display_name = "${var.vcnnamesecuritylistprefix}-${random_id.tag.hex}"
91+
display_name = local.vcn_securitylist_displayname
8092

8193
egress_security_rules {
8294
stateless = false

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/modules/network/output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
#
99
################################################################################
1010

11-
output "fnsubnet_ocid"{
12-
value = oci_core_subnet.function_ds_log_vcn.id
11+
output "subnet_ocid"{
12+
value = oci_core_subnet.vcn_subnet.id
1313
}

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/modules/network/variables.tf

Lines changed: 0 additions & 58 deletions
This file was deleted.

security/security-design/fn-datasafe-dbaudit-to-oci-logging/terraform/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ variable "region" {}
2828
variable "ocir_user_name" {}
2929
variable "ocir_user_password" {}
3030

31+
variable "purpose" {
32+
default ="fn_ds_to_ol"
33+
}
34+
35+
3136
variable "deployment_name" {
3237
default = "test"
3338
}

0 commit comments

Comments
 (0)